1 / 72

CUTE: A Concolic Unit Testing Engine for C Technical Report

CUTE: A Concolic Unit Testing Engine for C Technical Report. Koushik Sen Darko Marinov Gul Agha University of Illinois Urbana-Champaign. 5. Goal. Automated Scalable Unit Testing of real-world C Programs Generate test inputs Execute unit under test on generated test inputs

cleta
Download Presentation

CUTE: A Concolic Unit Testing Engine for C Technical Report

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CUTE: A Concolic Unit Testing Engine for CTechnical Report Koushik SenDarko Marinov Gul Agha University of Illinois Urbana-Champaign

  2. 5

  3. Goal • Automated Scalable Unit Testing of real-world C Programs • Generate test inputs • Execute unit under test on generated test inputs • so that all reachable statements are executed • Any assertion violation gets caught

  4. Goal • Automated Scalable Unit Testing of real-world C Programs • Generate test inputs • Execute unit under test on generated test inputs • so that all reachable statements are executed • Any assertion violation gets caught • Our Approach: • Explore all execution paths of an Unit for all possible inputs • Exploring all execution paths ensure that all reachable statements are executed

  5. 1 0 1 0 1 0 0 1 1 1 0 1 Execution Paths of a Program • Can be seen as a binary tree with possibly infinite depth • Computation tree • Each node represents the execution of a “if then else” statement • Each edge represents the execution of a sequence of non-conditional statements • Each path in the tree represents an equivalence class of inputs

  6. 2*x==y x!=y+10 Example of Computation Tree void test_me(int x, int y) { if(2*x==y){ if(x != y+10){ printf(“I am fine here”); } else { printf(“I should not reach here”); ERROR; } } } N Y N Y ERROR

  7. Random testing generate random inputs execute the program on generated inputs Probability of reaching an error can be astronomically less test_me(int x){ if(x==94389){ ERROR; } } Probability of hitting ERROR = 1/232 Existing Approach I

  8. Symbolic Execution use symbolic values for input variables execute the program symbolically on symbolic input values collect symbolic path constraints use theorem prover to check if a branch can be taken Does not scale for large programs test_me(int x){ if((x%10)*4!=17){ ERROR; } else { ERROR; } } Symbolic execution will say both branches are reachable: False positive Existing Approach II

  9. Approach • Combine concrete and symbolic execution for unit testing • Concrete + Symbolic = Concolic • In a nutshell • Use concrete execution over a concrete input to guide symbolic execution • Concrete execution helps Symbolic execution to simplify complex and unmanageable symbolic expressions • by replacing symbolic values by concrete values • Achieves Scalability • Higher branch coverage than random testing • No false positives or scalability issue like in symbolic execution based testing

  10. Example typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } • Random Test Driver: • random memory graph reachable from p • random value for x • Probability of reaching abort( ) is extremely low

  11. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; }

  12. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; }

  13. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0

  14. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 !(p0!=NULL)

  15. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } solve: x0>0 and p0NULL x0>0 p0=NULL

  16. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } solve: x0>0 and p0NULL x0=236, p0 NULL x0>0 p0=NULL

  17. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; }

  18. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0

  19. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL

  20. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL 2x0+1v0

  21. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL 2x0+1v0

  22. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } solve: x0>0 and p0NULL and 2x0+1=v0 x0>0 p0NULL 2x0+1v0

  23. concrete state symbolic state constraints p , x=236 NULL p=p0, x=x0,p->v =v0,p->next=n0 634 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } solve: x0>0 and p0NULL and 2x0+1=v0 x0=1, p0 NULL x0>0 p0NULL 2x0+1v0

  24. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; }

  25. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0

  26. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL

  27. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL 2x0+1=v0

  28. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL 2x0+1=v0 n0p0

  29. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL 2x0+1=v0 n0p0

  30. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } solve: x0>0 and p0NULL and 2x0+1=v0 and n0=p0 . x0>0 p0NULL 2x0+1=v0 n0p0

  31. concrete state symbolic state constraints p , x=1 NULL p=p0, x=x0,p->v =v0,p->next=n0 3 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } solve: x0>0 and p0NULL and 2x0+1=v0 and n0=p0 x0=1, p0 x0>0 p0NULL 2x0+1=v0 n0p0

  32. concrete state symbolic state constraints 3 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } p , x=1 p=p0, x=x0,p->v =v0,p->next=n0

  33. concrete state symbolic state constraints 3 p , x=1 p=p0, x=x0,p->v =v0,p->next=n0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0

  34. concrete state symbolic state constraints 3 p , x=1 p=p0, x=x0,p->v =v0,p->next=n0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL

  35. concrete state symbolic state constraints 3 p , x=1 p=p0, x=x0,p->v =v0,p->next=n0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } x0>0 p0NULL 2x0+1=v0

  36. concrete state symbolic state constraints 3 p , x=1 p=p0, x=x0,p->v =v0,p->next=n0 CUTE Approach Concrete Execution Symbolic Execution typedef struct cell { int v; struct cell *next; } cell; int f(int v) { return 2*v + 1; } int testme(cell *p, int x) { if (x > 0) if (p != NULL) if (f(x) == p->v) if (p->next == p) abort(); return 0; } Program Error x0>0 p0NULL 2x0+1=v0 n0=p0

  37. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  38. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  39. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  40. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  41. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  42. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  43. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  44. Traverse all execution paths one by one to detect errors check for assertion violations check for program crash combine with valgrind to discover memory leaks detect invariants 1 0 1 0 1 0 0 1 1 1 0 1 Explicit Path (not State) Model Checking

  45. CUTE in a Nutshell • Generate concrete inputs one by one • each input leads program along a different path

  46. CUTE in a Nutshell • Generate concrete inputs one by one • each input leads program along a different path • On each input execute program both concretely and symbolically

More Related