1 / 9

WLP for Automated Testing

WLP for Automated Testing. Wishnu Prasetya wishnu@cs.uu.nl www.cs.uu.nl/docs/vakken/pv. Testing problem. Give test-cases that would cover all 4 paths in the above program.

dyani
Télécharger la présentation

WLP for Automated Testing

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. WLP for Automated Testing Wishnu Prasetya wishnu@cs.uu.nl www.cs.uu.nl/docs/vakken/pv

  2. Testing problem • Give test-cases that would cover all 4 paths in the above program. • Observation: any input satisfying the wlp of a post-condition Q, specifies a test-case leading a terminal state satisfying Q. • Idea : use Q to specify the target path. tax(rate, income | tax) { if(income  10000) tax := 0 ; if (income  20000) tax := income / rate.low ; tax := tax + income / rate.high ; }

  3. Wedge • A wedge is a finite path of primitive (non-composite) statements in the program, from the program’s start, where we replace guard conditions with the corresponding assert. The concept is from Tomb & Flanagan, Detecting Inconsistencies via Universal Reachability Analysis, ISSTA, 2012. They use assume. For our purpose, we need to turn them to assert. • We can use wedges to re-express coverage problem (e.g. cover this spot, or cover this path). • Then we can calculate the wlp of each wedge.

  4. Wedge & coverage cover this • a wedge covering assert income  10000 ; tax := 0 ;assertincome  20000 ; • a wedge covering without passing (unfeasible) assert income  10000 ; tax := 0 ;assertincome > 20000 ; tax(rate, income | tax) { if(income  10000) tax := 0 ; if (income  20000) tax := income / rate.low ; tax := tax + income / rate.high ; }

  5. wlp of a wedge • Let p be a target path to cover in the CFG of Pr(x). Let w(x) be a wedge such that any execution of w is also an execution of Pr that covers p. • Calculate p = wlpw true. • Check the satisfiability of p; a witness to that is basically an instance of input x for Pr that would cover p.

  6. Covering by solving wlp • if (x>9) { x := x+y ;if (x+y 0) { y := 0 ; if (x8) { cover-this ... } • a wedge to cover assert x>9 ; x := x+y ;assertx+y < 0 ; y := 0 ; assert x 8 • wlp : x>9 /\ x+2y0 /\ x+y8

  7. Concolic approach • Problems: • A long wedge has more constraints; the wlp may be difficult for your theorem prover to solve. • What to do with loops? • Combined concrete and symbolic calculation to incrementally solve the wedge. • Imagine the wedge :w(x,y) = assert p1; x:=x+y; assert p2; y:=0; assert p3 • wlp: p = p1 /\ p2[x+y/x] /\ p3[0/y][x+y/x]

  8. Concolic approach • wlp: p = p1 /\ p2[x+y/x] /\ p3[0/y][x+y/x] • Execute w, e.g. w(0,9). Suppose this manages to pass the guards p1 and p2 but fails on p3 . • Try to solve p[0/x] or p[9/y] instead. • This at least simplifies the formula to solve. • Not necessarily leads to a solution.

  9. Wedge “passing” a loop • Consider : whilegdoS ; ifhthen {  cover this } ... • A wedge to cover  has to do some iterations of S. How many iteration? • Note that arbitrarily choosing k iterations may turn out to be infeasible  leading to unsatisfiablewlp. • Run a concrete execution; suppose it iterates n times, but fails to pass h • we know that at least iterating n times is feasible • construct a wedge with n unfoldingand solve it

More Related