dynamic symbolic database application testing
play

Dynamic Symbolic Database Application Testing Chengkai Li, - PowerPoint PPT Presentation

Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Dynamic Symbolic Database Application Testing Chengkai Li, Christoph Csallner University of Texas at Arlington June 7, 2010 DBTest 2010 Chengkai Li,


  1. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Dynamic Symbolic Database Application Testing Chengkai Li, Christoph Csallner University of Texas at Arlington June 7, 2010 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 1/30

  2. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Motivation Maximizing code coverage is an important goal in testing. Database applications: input can be user-supplied queries. Query results will be used as program values in program logic. Different queries thus result in different execution paths. To maximize code coverage: we need to enumerate queries in an effective way. DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 2/30

  3. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Our Method Generate queries dynamically by inverting branching conditions in existing program execution paths. Monitor the program’s execution paths by dynamic symbolic 1 execution (e.g., Dart, Pex). Invert a branching condition on some covered path → a new test 2 query. Execute the query, bring in new tuples. 3 The new tuples will cover new paths. 4 Do 1-4 iteratively. 5 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 3/30

  4. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea After the initial query q 1 = c 1 ∧ c 2 Execution tree (maintained by dynamic symbolic engine): each path to a leaf node represents an execution path, encountered for tuples satisfying the branching conditions on the path. true if (z > 0) { // c1 c1 if (z < 100) // c2 c2 (q1) // .. } c3 c4 !c4 c5 !c5 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 4/30

  5. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea After the initial query, the candidate queries Each dashed edge represents an inversed branching condition, thus a candidate query. true c1 !c1 c2 !c2 (q1) c3 !c3 c4 !c4 c5 !c5 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 5/30

  6. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea The second test query q 2 = ! c 1 true c1 !c1 (q2) c2 !c2 (q1) c3 !c3 c4 !c4 c5 !c5 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 6/30

  7. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea After the second test query q 2 = ! c 1 candidate queries are again dashed. true c1 !c1 (q2) c2 (q1) !c2 c6 !c6 c3 !c3 c7 !c7 c4 !c4 c11 !c11 c5 !c5 c12 !c12 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 7/30

  8. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea The third test query q 3 = ! c 1 ∧ c 6 ∧ c 7 true c1 !c1 (q2) c2 !c2 c6 !c6 (q1) c3 !c3 c7 (q3) !c7 c4 !c4 c11 !c11 c5 !c5 c12 !c12 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 8/30

  9. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea After the third test query q 3 = ! c 1 ∧ c 6 ∧ c 7 true c1 !c1 (q2) c2 !c2 c6 !c6 (q1) c3 !c3 c7 !c7 (q3) c4 !c4 c8 !c8 c11 !c11 c5 !c5 c9 !c9 c10 !c10 c12 !c12 DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 9/30

  10. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea The fourth test query q 4 = ! c 1 ∧ c 6 ∧ ! c 7 ∧ ! c 11 ∧ ! c 12 true c1 !c1 (q2) c2 !c2 c6 !c6 (q1) c3 !c3 c7 !c7 (q3) c4 !c4 c8 !c8 c11 !c11 c5 !c5 c9 !c9 c10 !c10 c12 !c12 (q4) DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 10/30

  11. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Illustration of the Idea After the fourth test query q 4 = ! c 1 ∧ c 6 ∧ ! c 7 ∧ ! c 11 ∧ ! c 12 true c1 !c1 (q2) c2 !c2 c6 !c6 (q1) c3 !c3 c7 !c7 (q3) c4 !c4 c8 !c8 c11 !c11 c5 !c5 c9 !c9 c10 !c10 c12 !c12 (q4) DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 11/30

  12. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Advantages of the Proposed Method Real data, no mock database (which can be hard to generate). No need to worry about if the mock database is representative. Given large space of possible program paths, we only test those that can be encountered for real data. This is especially useful for applications that only read existing data. DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 12/30

  13. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Alternative Method 1: Brute force Test for every tuple in database. Too costly Limited resources in testing. Many tuples result in the same execution path. Thus efforts wasted. May not be possible to get all the tuples Security constraint. Query capability constraint. (e.g., deep-Web databases) DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 13/30

  14. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Alternative Method 2: Sample the existing database Do sampling first, then test for every tuple in the sample. A presentative database sample may not trigger a set of program execution paths that is representative of the paths encountered in production use. E.g., a column with 1 million distinct values; several particular values will trigger some paths. Ours can be viewed as a sampling technique that is aware of the program structure. DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 14/30

  15. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Alternative Method 3: Generate custom mock databases Generate a mock database such that its data will expose a bug in the program Will expose potential program bugs. But users may not care about them. Because many “bugs” will never occur in practice. Because the mock database generator typically cannot generate fully realistic databases. DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 15/30

  16. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Alternative Method 4: Static Analysis Static program analysis is typically: (+) Fast (-) Imprecise: misses bugs and gives false alarms Our approach: Test = execute the program (dynamic analysis) (+) Fully precise: no false alarms (-) Resource-hungry, will still miss bugs Our (dynamic) analysis reasons about program + existing database contents. We are not aware of any static analysis that does that. DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 16/30

  17. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Assumptions/Limitations Queries single-relation conjunctive selection query. Each conjunct is a ⊙ v , where a is an attribute, v is a constant value, and ⊙ can be < , ≤ , > , ≥ , = , or ∕ = . no grouping, aggregation, join, insertion, deletion, updates. Programs follow tuple-wise semantics. if a branching condition depends on a database tuple, the condition can be rewritten to the same form of the query conjuncts: a ⊙ v . DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 17/30

  18. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Iterative Testing Method 1: q ← define an initial test query; 풬 ← { q } 2: repeat 풯 ← run q and get the first n q result tuples 3: for each tuple t in 풯 do 4: run the program over t and update the execution tree tree 풬 5: with encountered new execution paths tree 풬 ← the complement tree of tree 풬 6: 풬 c ← get the candidate queries based on tree 풬 7: q ← select a query from 풬 c 8: 풬 ← 풬 ∪ { q } 9: 10: until stopping criteria satisfied DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 18/30

  19. Overview Alternative Methods Details of the Method Implementation Ongoing and Future Work Challenges How to decide how many tuples to retrieve for a query? choose the next test query? design stopping condition for testing? DBTest 2010 Chengkai Li, Christoph Csallner Dynamic Symbolic Database Application Testing: 19/30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend