White box testing techniques ii
This presentation is the property of its rightful owner.
Sponsored Links
1 / 70

White-Box Testing Techniques II PowerPoint PPT Presentation


  • 91 Views
  • Uploaded on
  • Presentation posted in: General

White-Box Testing Techniques II. Dataflow Testing. Originals prepared by Stephen M. Thebaut, Ph.D. University of Florida. White-Box Testing Topics. Logic coverage Dataflow coverage Path conditions and symbolic execution (lecture III) Other white-box testing strategies

Download Presentation

White-Box Testing Techniques II

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


White box testing techniques ii

White-Box Testing Techniques II

Dataflow Testing

Originals prepared by

Stephen M. Thebaut, Ph.D.

University of Florida


White box testing topics

White-Box Testing Topics

  • Logic coverage

  • Dataflow coverage

  • Path conditions and symbolic execution (lecture III)

  • Other white-box testing strategies

    • e.g. fault-based testing


Dataflow coverage

Dataflow Coverage

  • Basic idea:

    • Program paths along which variables are defined and then used should be covered

  • A family of path selection criteria has been defined, each providing a different degree of coverage

  • CASE tool support is very desirable


Variable definition

Variable Definition

  • A program variable is DEFINED when it appears:

    • on the left hand side of an assignment statement egy = 17

    • in an input statementeg read(y)

    • as an call-by-reference parameter in a subroutine call egupdate(x, &y);


Variable use

Variable Use

  • A program variable is USED when it appears:

    • on the right hand side of an assignment statement eg y = x+17

    • as an call-by-value parameter in a subroutine or function call eg y = sqrt(x)

    • in the predicate of a branch statement eg if ( x > 0 ) { … }


Variable use p use and c use

Variable Use: p-use and c-use

  • Use in the predicate of a branch statement is a predicate-use or “p-use”

  • Any other use is a computation-use or “c-use”

  • For example, in the program fragment:

    if ( x > 0 ) {

    print(y); }

    there is a p-use ofxand a c-use ofy


Variable use1

Variable Use

  • A variable can also be used and then re-defined in a single statement when it appears:

    • on both sides of an assignment statement eg y = y + x

    • as an call-by-reference parameter in a subroutine call eg increment( &y )


More dataflow terms and definitions

More Dataflow Terms and Definitions

  • A path is definition clear(“def-clear”) with respect to a variable v if it has no variable re-definition of v on the path

  • A complete pathis a path whose initial node is a start node and whose final node is an exit node


Dataflow terms and definitions

Dataflow Terms and Definitions

  • A definition-use pair(“du-pair”) with respect to a variable v is a double (d,u) such that

    • d is a node in the program’s flow graph at which v is defined,

    • u is a node or edge at which v is used and

    • there is a def-clear path with respect to vfrom d to u

  • Note that the definition of a du-pair does not require the existence of a feasibledef-clear path from d to u


Example 1

Example 1

1. input(A,B)

if (B>1) {

2. A = A+7

}

3. if (A>10) {

4. B = A+B

}

5. output(A,B)

input(A,B)

1

B>1

B1

2

A = A+7

3

A>10

A10

4

B = A+B

5

output(A,B)


Identifying du pairs variable a

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a1

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a2

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a3

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a4

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a5

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a6

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a7

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a8

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a9

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a10

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable a11

Identifying DU-Pairs – Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Identifying du pairs variable b

Identifying DU-Pairs – Variable B

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Dataflow test coverage criteria

Dataflow Test Coverage Criteria

  • All-Defs for every program variable v, at least onedef-clear path from every definition of vto at least one c-use or one p-use of v must be covered


Dataflow test coverage criteria1

Dataflow Test Coverage Criteria

  • Consider a test case executing path:

    1. <1,2,3,4,5>

  • Identify all def-clear paths covered (ie subsumed) by this path for each variable

  • Are all definitions for each variable associated with at least one of the subsumed def-clear paths?


Def clear paths subsumed by 1 2 3 4 5 for variable a

Def-Clear Paths subsumed by <1,2,3,4,5> for Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Def clear paths subsumed by 1 2 3 4 5 for variable b

Def-Clear Paths Subsumed by <1,2,3,4,5> for Variable B

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Dataflow test coverage criteria2

Dataflow Test Coverage Criteria

  • Since<1,2,3,4,5>covers at least one def-clear path from every definition of A or B to at least one c-use or p-use of A or B, All-Defs coverage is achieved


Dataflow test coverage criteria3

Dataflow Test Coverage Criteria

  • All-Uses: for every program variable v,at least onedef-clear pathfrom everydefinition of v to everyc-use and every p-use of v must be covered

  • Consider additional test cases executing paths:

    2. <1,3,4,5>

    3. <1,2,3,5>

  • Do all three test cases provide All-Uses coverage?


Def clear paths subsumed by 1 3 4 5 for variable a

Def-Clear Paths Subsumed by <1,3,4,5> for Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Def clear paths subsumed by 1 3 4 5 for variable b

Def-Clear Paths Subsumed by <1,3,4,5> for Variable B

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Def clear paths subsumed by 1 2 3 5 for variable a

Def-Clear Paths Subsumed by <1,2,3,5> for Variable A

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Def clear paths subsumed by 1 2 3 5 for variable b

Def-Clear Paths Subsumed by <1,2,3,5> for Variable B

input(A,B)

1

B>1

B1

2

A := A+7

3

A>10

A10

4

B := A+B

5

output(A,B)


Dataflow test coverage criteria4

Dataflow Test Coverage Criteria

  • None of the three test cases covers the du-pair (1,<3,5>) for variable A,

  • All-Uses Coverage is not achieved


Example 2

Example 2

1. input(X,Y)

2. while (Y>0) {

3. if (X>0)

4. Y := Y-X

else

5. input(X)

6. }

7. output(X,Y)

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x1

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x2

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x3

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x4

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x5

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x6

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x7

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x8

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x9

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x10

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x11

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x12

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y = Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x13

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x14

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x15

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x16

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x17

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x18

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x19

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x20

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x21

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x22

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x23

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x24

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x25

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


Identifying du pairs variable x26

Identifying DU-Pairs – Variable X

1

input(X,Y))

2

Y>0

Y0

3

X0

X>0

input(X)

5

4

Y := Y-X

6

Y0

Y>0

7

output(X,Y)


More dataflow terms and definitions1

More Dataflow Terms and Definitions

  • A path (either partial or complete) is simpleif all edges within the path are distinct ie different

  • A path is loop-freeif all nodes within the path are distinct ie different


Simple and loop free paths

Simple and Loop-Free Paths


More dataflow terms and definitions2

More Dataflow Terms and Definitions

A path <n1,n2,...,nj,nk> is a du-pathwith respect to a variable v if v is defined at node n1 and either:

  • there is a c-use of v at node nk and <n1,n2,...,nj,nk> is a def-clear simplepath, or

  • there is a p-use of v at edge <nj,nk> and <n1,n2,...nj> is a def-clear loop-freepath.


More dataflow terms and definitions3

More Dataflow Terms and Definitions

A path <n1,n2,...,nj,nk> is a du-pathwith respect to a variable v if v is defined at node n1 and either:

  • there is a c-use of v at node nk and <n1,n2,...,nj,nk> is a def-clear simplepath, or

  • there is a p-use of v at edge <nj,nk> and <n1,n2,...nj> is a def-clear loop-freepath.

NOTE!


Identifying du paths

Identifying du-paths


Another dataflow test coverage criterion

Another Dataflow Test Coverage Criterion

  • All-DU-Paths:for every program variable v,every du-path from every definition of v to every c-use and every p-use of v must be covered


Exercise

Exercise

  • Identify all c-uses and p-uses for variable Y in Example 2

  • For each c-use or p-use, identify (using the “ * ” notation) all def-clear paths

  • Identify whether or not each def-clear path is feasible, and whether or not it is a du-path


White box coverage subsumption relationships

White-Box Coverage Subsumption Relationships

Path

Compound Condition

All du-paths

Branch / Condition

Basis Paths

All-Uses

Loop

Condition

Branch

All-Defs

Statement


  • Login