testing abstraction theorem proving better together
play

Testing, Abstraction, Theorem Proving: Better Together Authors: - PowerPoint PPT Presentation

Testing, Abstraction, Theorem Proving: Better Together Authors: Greta Yorsh Thomas Ball Mooly Sagiv Presenter: Michael Rudolph Seminar Program Analysis and Software Testing University of Freiburg 2016 Motivation Program No Proof no error


  1. Testing, Abstraction, Theorem Proving: Better Together Authors: Greta Yorsh Thomas Ball Mooly Sagiv Presenter: Michael Rudolph Seminar Program Analysis and Software Testing University of Freiburg 2016

  2. Motivation Program No Proof no error Execute tests error Test set Real error Dynamic Analysis

  3. Motivation Proof no error Program Analysis Abstraction error Potential error Static Analysis

  4. False error Unreachable concrete states Reachable concrete states false error Abstract state = +

  5. Motivation Dynamic Analysis Static Analysis No Proof Real error Proof Potential error

  6. Motivation Dynamic Analysis Static Analysis No Proof Real error Proof Potential error solved by

  7. Motivation Dynamic Analysis Static Analysis No Proof Real error Proof Potential error solved by solved by

  8. Motivation ⇓ Idea: Combine both approaches.

  9. Table of Contents 1 Motivation 2 Overview method 3 Real error 4 Proof 5 False error 6 Conclusion

  10. Example Algorithm: foo(int x, int y) I int ∗ px = NULL ; A x = x + 1; B if x < 4 then px = & x ; C D if px == & y then x = x + 1; E F if x < 5 then ∗ px = ∗ px + 1; G (foo algorithm, G. Yorsh , T. Ball, and M. Sagiv , 2006.)

  11. Example Algorithm: foo(3, 0) I int ∗ px = NULL ; // (pc=I, x=3, y=0, px=NULL)

  12. Example Algorithm: foo(3, 0) I int ∗ px = NULL ; // (pc=I, x=3, y=0, px=NULL) A x = x + 1; // (pc=A, x=3, y=0, px=NULL)

  13. Example Algorithm: foo(3, 0) I int ∗ px = NULL ; // (pc=I, x=3, y=0, px=NULL) A x = x + 1; // (pc=A, x=3, y=0, px=NULL) B if x < 4 // (pc=B, x=4, y=0, px=NULL) then px = & x ; C

  14. Example Algorithm: foo(3, 0) I int ∗ px = NULL ; // (pc=I, x=3, y=0, px=NULL) A x = x + 1; // (pc=A, x=3, y=0, px=NULL) B if x < 4 // (pc=B, x=4, y=0, px=NULL) then px = & x ; C D if px == & y // (pc=D, x=4, y=0, px=NULL) then x = x + 1; // Dead code E

  15. Example Algorithm: foo(3, 0) I int ∗ px = NULL ; // (pc=I, x=3, y=0, px=NULL) A x = x + 1; // (pc=A, x=3, y=0, px=NULL) B if x < 4 // (pc=B, x=4, y=0, px=NULL) then px = & x ; C D if px == & y // (pc=D, x=4, y=0, px=NULL) then x = x + 1; // Dead code E F if x < 5 // (pc=F, x=4, y=0, px=NULL) then ∗ px = ∗ px + 1; // (pc=G, x=4, y=0, px=NULL) G

  16. Example Algorithm: foo(3, 0) I int ∗ px = NULL ; // (pc=I, x=3, y=0, px=NULL) A x = x + 1; // (pc=A, x=3, y=0, px=NULL) B if x < 4 // (pc=B, x=4, y=0, px=NULL) then px = & x ; C D if px == & y // (pc=D, x=4, y=0, px=NULL) then x = x + 1; // Dead code E F if x < 5 // (pc=F, x=4, y=0, px=NULL) then ∗ px = ∗ px + 1; // (pc=G, x=4, y=0, px=NULL) G ⇒ Null pointer dereference error =

  17. Execute program P test set T potential error Execute (Figure 1, G. Yorsh , T. Ball, and M. Sagiv , 2006.)

  18. Execute program P test set T potential error Execute (Figure 1, G. Yorsh , T. Ball, and M. Sagiv , 2006.)

  19. Execute Program P Test set foo(2,0) = foo (pc=I, x=2, y=0, px=NULL) An example input.

  20. Execute Algorithm: foo(2, 0) I int ∗ px = NULL ; // (pc=I, x=2, y=0, px=NULL)

  21. Execute Algorithm: foo(2, 0) I int ∗ px = NULL ; // (pc=I, x=2, y=0, px=NULL) A x = x + 1; // (pc=A, x=2, y=0, px=NULL)

  22. Execute Algorithm: foo(2, 0) I int ∗ px = NULL ; // (pc=I, x=2, y=0, px=NULL) A x = x + 1; // (pc=A, x=2, y=0, px=NULL) B if x < 4 // (pc=B, x=3, y=0, px=NULL) then px = & x ; // (pc=C, x=3, y=0, px=NULL) C

  23. Execute Algorithm: foo(2, 0) I int ∗ px = NULL ; // (pc=I, x=2, y=0, px=NULL) A x = x + 1; // (pc=A, x=2, y=0, px=NULL) B if x < 4 // (pc=B, x=3, y=0, px=NULL) then px = & x ; // (pc=C, x=3, y=0, px=NULL) C D if px == & y // (pc=D, x=3, y=0, px= ¬ NULL) then x = x + 1; E

  24. Execute Algorithm: foo(2, 0) I int ∗ px = NULL ; // (pc=I, x=2, y=0, px=NULL) A x = x + 1; // (pc=A, x=2, y=0, px=NULL) B if x < 4 // (pc=B, x=3, y=0, px=NULL) then px = & x ; // (pc=C, x=3, y=0, px=NULL) C D if px == & y // (pc=D, x=3, y=0, px= ¬ NULL) then x = x + 1; E F if x < 5 // (pc=F, x=3, y=0, px= ¬ NULL) then ∗ px = ∗ px + 1; // (pc=G, x=3, y=0, px= ¬ NULL) G

  25. Execute Execute test set ⇒ No Error. but Execute foo(3,0) ⇒ Error ⇓ Execute phase gives no proof.

  26. Abstract test set T program P potential error Execute C T Abstract

  27. Abstract Unreachable concrete states Reachable concrete states Abstract state = +

  28. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) I int ∗ px = NULL ;

  29. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) pc=A, x=2, y=0, px=NULL A, t, t I int ∗ px = NULL ; A x = x + 1;

  30. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) pc=A, x=2, y=0, px=NULL A, t, t I int ∗ px = NULL ; A x = x + 1; pc=B, x=3, y=0, px=NULL B, t, t B if x < 4 then px = & x ; C

  31. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) pc=A, x=2, y=0, px=NULL A, t, t I int ∗ px = NULL ; A x = x + 1; pc=B, x=3, y=0, px=NULL B, t, t B if x < 4 then px = & x ; C pc=C, x=3, y=0, px=NULL C, t, t

  32. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) pc=A, x=2, y=0, px=NULL A, t, t I int ∗ px = NULL ; A x = x + 1; pc=B, x=3, y=0, px=NULL B, t, t B if x < 4 then px = & x ; C pc=C, x=3, y=0, px=NULL C, t, t D if px == & y then x = x + 1; E pc=D, x=3, y=0, px= ¬ NULL D, t, f

  33. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) pc=A, x=2, y=0, px=NULL A, t, t I int ∗ px = NULL ; A x = x + 1; pc=B, x=3, y=0, px=NULL B, t, t B if x < 4 then px = & x ; C pc=C, x=3, y=0, px=NULL C, t, t D if px == & y then x = x + 1; E pc=D, x=3, y=0, px= ¬ NULL D, t, f F if x < 5 then ∗ px = ∗ px +1; G pc=F, x=3, y=0, px= ¬ NULL F, t, f

  34. Abstract α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } C T A T pc=I, x=2, y=0, px=NULL I, t, t Algorithm: foo(2,0) pc=A, x=2, y=0, px=NULL A, t, t I int ∗ px = NULL ; A x = x + 1; pc=B, x=3, y=0, px=NULL B, t, t B if x < 4 then px = & x ; C pc=C, x=3, y=0, px=NULL C, t, t D if px == & y then x = x + 1; E pc=D, x=3, y=0, px= ¬ NULL D, t, f F if x < 5 then ∗ px = ∗ px +1; G pc=F, x=3, y=0, px= ¬ NULL F, t, f pc=G, x=3, y=0, px= ¬ NULL G, t, f

  35. Check adequacy test set T program P potential error Execute C T Abstract A T Check adequacy

  36. Check adequacy What are successor states ? Let’s look at our example. Algorithm: part of foo(int x, int y) A x = x + 1; B if x < 4 then px = & x ; // If B is true. C D if px == & y // If B is false. then x = x + 1; E F if x < 5 then ∗ px = ∗ px + 1; G Successor states of B

  37. Check adequacy A set of tests T is adequate under a given abstraction ⇔ for all concrete states which are represented by A T it holds that their successor states are covered by A T , too. � A T : abstract states covered by T concrete state c successor states of c

  38. Check adequacy A set of tests T is adequate under a given abstraction ⇔ for all concrete states which are represented by A T it holds that their successor states are covered by A T , too. A T : abstract states covered by T concrete state c successor states of c

  39. Check adequacy α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } A T I, t, t Algorithm: foo(int x, int y) A, t, t I int ∗ px = NULL ; A x = x + 1; B, t, t B if x < 4 then px = & x ; // (pc=C, x<4, px=Null) C C, t, t D if px == & y then D, t, f x = x + 1; E F if x < 5 then F, t, f ∗ px = ∗ px + 1; G G, t, f

  40. Check adequacy α ( C ) = { ( pc , x < 5 , px = NULL ) | ( pc , x , y , px ) ∈ C } A T I, t, t Algorithm: foo(int x, int y) A, t, t I int ∗ px = NULL ; A x = x + 1; B, t, t B if x < 4 then px = & x ; C C, t, t D if px == & y // (pc=D, x>=4, px=NULL) then D, t, f x = x + 1; E F if x < 5 then F, t, f ∗ px = ∗ px + 1; G G, t, f

  41. Check adequacy The successor state (D,4,0,NULL) is not covered by A T ⇓ adequacy check fails.

  42. Fabricate test test set T program P potential error Execute C T Abstract ′ A T T Check adequacy Fabricate test failed

  43. Fabricate test The successor state (D,4,0,NULL) is not covered by A T ⇓ adequacy check fails. ⇓ model generator fabricates a pair of concrete states, e.g. (B,4,0,NULL), (D,4,0,NULL) concrete states need not to be reachable. ⇓ extend test set T by the generated concrete states.

  44. Check safety property program P test set T potential error C T Execute Abstract ′ A T T Check adequacy Fabricate test failed adequate potential error Check safety verified properties

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