concolic testing
play

Concolic Testing Dynamic Symbolic Execution Marco Probst - PowerPoint PPT Presentation

Concolic Testing Dynamic Symbolic Execution Marco Probst Albert-Ludwigs-Universitt Freiburg January 25th, 2016 Marco Probst Concolic Testing 1 / 22 Overview Code Example 1 Unit Testing 2 Random Testing Symbolic Execution Concolic


  1. Concolic Testing Dynamic Symbolic Execution Marco Probst Albert-Ludwigs-Universität Freiburg January 25th, 2016 Marco Probst Concolic Testing 1 / 22

  2. Overview Code Example 1 Unit Testing 2 Random Testing Symbolic Execution Concolic Testing 3 DART Summary 4 Marco Probst Concolic Testing 2 / 22

  3. Overview Code Example 1 Unit Testing 2 Random Testing Symbolic Execution Concolic Testing 3 DART Summary 4 Marco Probst Concolic Testing 3 / 22

  4. Program Under Test Developers writing code [1] . . . 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Marco Probst Concolic Testing 4 / 22

  5. Program Under Test Developers writing code [1] . . . 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } . . . need to test Marco Probst Concolic Testing 4 / 22

  6. Overview Code Example 1 Unit Testing 2 Random Testing Symbolic Execution Concolic Testing 3 DART Summary 4 Marco Probst Concolic Testing 5 / 22

  7. Unit Testing Ensure overall software quality Individual components (e.g. functions) Marco Probst Concolic Testing 6 / 22

  8. Unit Testing Ensure overall software quality Individual components (e.g. functions) Goals ◮ Detect errors ◮ Check corner cases ◮ Provide high code coverage (e.g. path coverage) Marco Probst Concolic Testing 6 / 22

  9. Path Coverage Marco Probst Concolic Testing 7 / 22

  10. Path Coverage Code Example ⇒ Control Flow ⇒ Execution Paths 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Marco Probst Concolic Testing 7 / 22

  11. Path Coverage Code Example ⇒ Control Flow ⇒ Execution Paths 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Marco Probst Concolic Testing 7 / 22

  12. Path Coverage Code Example ⇒ Control Flow ⇒ Execution Paths 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Marco Probst Concolic Testing 7 / 22

  13. Path Coverage Code Example ⇒ Control Flow ⇒ Execution Paths 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Marco Probst Concolic Testing 7 / 22

  14. Path Coverage Code Example ⇒ Control Flow ⇒ Execution Paths 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Marco Probst Concolic Testing 7 / 22

  15. Path Coverage Code Example ⇒ Control Flow ⇒ Execution Paths 1 f(int x, int y) { if (x*x*x > 0) { 2 if (x > 0 && y == 10) { 3 fail(); 4 } 5 } else { 6 if (x > 0 && y == 20) { 7 fail(); 8 } 9 } 10 11 complete(); 12 13 } Contradiction: x <= 0 && x > 0 ⇒ not executable Marco Probst Concolic Testing 7 / 22

  16. Path Coverage 3 possible execution paths Corresponding path conditions Marco Probst Concolic Testing 7 / 22

  17. Path Coverage 3 possible execution paths Corresponding path conditions Optimal: cover all paths Find input set to run program along different paths Marco Probst Concolic Testing 7 / 22

  18. Random Testing Marco Probst Concolic Testing 8 / 22

  19. Random Testing Most naive way of testing Generate random inputs Concrete input values Dynamic execution of program Observe behavior Compare against expected behavior e.g. output or "do not crash" Marco Probst Concolic Testing 8 / 22

  20. Random Testing on Code Example Marco Probst Concolic Testing 9 / 22

  21. Random Testing on Code Example Random inputs for f(int x, int y) Marco Probst Concolic Testing 9 / 22

  22. Random Testing on Code Example Random inputs for f(int x, int y) x = 700, y = 500 Marco Probst Concolic Testing 9 / 22

  23. Random Testing on Code Example Random inputs for f(int x, int y) x = 700, y = 500 x = -700, y = 500 Marco Probst Concolic Testing 9 / 22

  24. Random Testing on Code Example Random inputs for f(int x, int y) x = 700, y = 500 x = -700, y = 500 Similar values are very likely Marco Probst Concolic Testing 9 / 22

  25. Random Testing on Code Example Necessary inputs x > 0, y = 10 Marco Probst Concolic Testing 9 / 22

  26. Random Testing on Code Example Necessary inputs x > 0, y = 10 Assume 32-bit integers ⇒ 1 out of 2 32 Marco Probst Concolic Testing 9 / 22

  27. Random Testing on Code Example Necessary inputs x > 0, y = 10 Assume 32-bit integers ⇒ 1 out of 2 32 Very low probability Marco Probst Concolic Testing 9 / 22

  28. Random Testing on Code Example Necessary inputs x > 0, y = 10 Assume 32-bit integers ⇒ 1 out of 2 32 Very low probability Long run . . . � Marco Probst Concolic Testing 9 / 22

  29. Random Testing on Code Example Necessary inputs x > 0, y = 10 Assume 32-bit integers ⇒ 1 out of 2 32 Very low probability Long run . . . � Another technique! Marco Probst Concolic Testing 9 / 22

  30. Symbolic Execution [2] & [3] Symbols instead of concrete values Marco Probst Concolic Testing 10 / 22

  31. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Marco Probst Concolic Testing 10 / 22

  32. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Marco Probst Concolic Testing 10 / 22

  33. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values 1 y = read(); 2 y = 2 * y; 3 4 if (y == 12) { fail(); 5 6 } 7 8 complete(); Marco Probst Concolic Testing 10 / 22

  34. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; 3 4 if (y == 12) { fail(); 5 6 } 7 8 complete(); Marco Probst Concolic Testing 10 / 22

  35. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; y = 2 * y ⇒ y = 2 * s 3 4 if (y == 12) { fail(); 5 6 } 7 8 complete(); Marco Probst Concolic Testing 10 / 22

  36. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; y = 2 * y ⇒ y = 2 * s 3 4 if (y == 12) { Branching point in line 4 fail(); 5 y == 12 ⇒ 2 * s == 12 6 } y != 12 ⇒ 2 * s != 12 7 8 complete(); Marco Probst Concolic Testing 10 / 22

  37. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; y = 2 * y ⇒ y = 2 * s 3 4 if (y == 12) { Branching point in line 4 fail(); 5 y == 12 ⇒ 2 * s == 12 6 } y != 12 ⇒ 2 * s != 12 7 8 complete(); Marco Probst Concolic Testing 10 / 22

  38. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; y = 2 * y ⇒ y = 2 * s 3 4 if (y == 12) { Branching point in line 4 fail(); 5 y == 12 ⇒ 2 * s == 12 6 } y != 12 ⇒ 2 * s != 12 7 8 complete(); Marco Probst Concolic Testing 10 / 22

  39. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; y = 2 * y ⇒ y = 2 * s 3 4 if (y == 12) { Branching point in line 4 fail(); 5 y == 12 ⇒ 2 * s == 12 6 } y != 12 ⇒ 2 * s != 12 7 8 complete(); Which input leads to fail() ? Marco Probst Concolic Testing 10 / 22

  40. Symbolic Execution [2] & [3] Symbols instead of concrete values Connected to path constraints (or path conditions) Constraint solver computes concrete values Introduces symbol s for read() y = read() ⇒ y = s 1 y = read(); 2 y = 2 * y; y = 2 * y ⇒ y = 2 * s 3 4 if (y == 12) { Branching point in line 4 fail(); 5 y == 12 ⇒ 2 * s == 12 6 } y != 12 ⇒ 2 * s != 12 7 8 complete(); Which input leads to fail() ? Constraint solver yields 6 Marco Probst Concolic Testing 10 / 22

Recommend


More recommend