Relational symbolic execution of SQL code for unit testing of database programs
File(s) scp15-marcozzi.pdf (511.99 KB)
Accepted version
Author(s)
Marcozzi, Michael
Vanhoof, Wim
Hainaut, Jean-Luc
Type
Journal Article
Abstract
Symbolic execution is a technique enabling the automatic generation of test inputs that exercise a set of execution paths within a code unit to be tested. If the paths cover a sufficient part of the code under test, the test data offer a representative view of the actual behaviour of this code. This notably enables detecting errors and correcting faults. Relational databases are ubiquitous in software, but symbolic execution of code units that manipulate them remains a non-trivial problem, particularly because of the complex structure of such databases and the complex behaviour of SQL statements. Finding errors in such code units is yet critical, as it can avoid corrupting important data. In this work, we define a symbolic execution translating database manipulation code directly into constraints and integrate it with a more traditional symbolic execution of normal program code. The database tables are represented by relational symbols and the SQL statements by relational constraints over these symbols. An algorithm based on these principles is presented for the symbolic execution of simple Java methods that implement transactional use cases by reading and writing in a relational database, the latter subject to data integrity constraints. The algorithm is integrated in a test generation tool and experimented over sample code. The target language for the constraints produced by the tool is the SMT-Lib standard and the used solver is Microsoft Z3. The results show that the proposed approach enables generating meaningful test data, including valid database content, in reasonable time. In particular, the Z3 solver is shown to be more scalable than the Alloy solver, used in our previous work, for solving relational constraints.
Date Issued
2015-07-01
Date Acceptance
2015-03-26
Citation
Science of Computer Programming, 2015, 105, pp.44-72
ISSN
0167-6423
Publisher
Elsevier
Start Page
44
End Page
72
Journal / Book Title
Science of Computer Programming
Volume
105
Copyright Statement
© 2015, Elsevier. Licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International http://creativecommons.org/licenses/by-nc-nd/4.0/
Subjects
Science & Technology
Technology
Computer Science, Software Engineering
Computer Science
Software testing
Symbolic execution
Satisfiability modulo theories (SMT)
Database
Structured query language (SQL)
COVERAGE
GENERATION
QUERIES
SYSTEMS
AGENDA
SOLVER
Publication Status
Published
