70
White-Box Testing Techniques II Originals prepared by Stephen M. Thebaut, Ph.D. University of Florida Dataflow Testing

White-Box Testing Techniques II

  • Upload
    yan

  • View
    51

  • Download
    0

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: White-Box Testing Techniques II

White-Box Testing Techniques II

Originals prepared by

Stephen M. Thebaut, Ph.D.

University of Florida

Dataflow Testing

Page 2: White-Box Testing Techniques II

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

Page 3: White-Box Testing Techniques II

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

Page 4: White-Box Testing Techniques II

Variable Definition

• A program variable is DEFINED when it appears:

– on the left hand side of an assignment statement eg y = 17

– in an input statement eg read(y)

– as an call-by-reference parameter in a subroutine call eg update(x, &y);

Page 5: White-Box Testing Techniques II

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 ) { … }

Page 6: White-Box Testing Techniques II

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 of x and a c-use of y

Page 7: White-Box Testing Techniques II

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 )

Page 8: White-Box Testing Techniques II

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 path is a path whose initial node is a start node and whose final node is an exit node

Page 9: White-Box Testing Techniques II

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 v from d to u

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

Page 10: White-Box Testing Techniques II

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)

1

2

3

4

5

input(A,B)

A = A+7

B = A+B

B>1

B1

A>10

A10

output(A,B)

Page 11: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 12: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2)

<1,2>

(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 13: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 14: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 15: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 16: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 17: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 18: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4)

<2,3,4>

(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 19: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 20: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 21: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 22: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Adu-pair path(s)

(1,2) <1,2>(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4) <2,3,4>(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 23: White-Box Testing Techniques II

Identifying DU-Pairs – Variable B

du-pair path(s)

(1,4)

<1,2,3,4><1,3,4>

(1,5)

<1,2,3,5>

<1,3,5>

(1,<1,2>)

<1,2>

(1,<1,3>)

<1,3>

(4,5)

<4,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 24: White-Box Testing Techniques II

Dataflow Test Coverage Criteria

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

Page 25: White-Box Testing Techniques II

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?

Page 26: White-Box Testing Techniques II

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

du-pair path(s)

(1,2)

<1,2>

(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4)

<2,3,4>

(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 27: White-Box Testing Techniques II

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

du-pair path(s)

(1,4)

<1,2,3,4>

<1,3,4>

(1,5)

<1,2,3,5>

<1,3,5>

(4,5)

<4,5>

(1,<1,2>)

<1,2>

(1,<1,3>)

<1,3>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 28: White-Box Testing Techniques II

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

Page 29: White-Box Testing Techniques II

Dataflow Test Coverage Criteria• All-Uses:

for every program variable v, at least one def-clear path from every definition of v to every c-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?

Page 30: White-Box Testing Techniques II

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

du-pair path(s)

(1,2)

<1,2>

(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4)

<2,3,4>

(2,5)

<2,3,4,5>

<2,3,5>(2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 31: White-Box Testing Techniques II

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

du-pair path(s)

(1,4)

<1,2,3,4>

<1,3,4>

(1,5)

<1,2,3,5>

<1,3,5>

(4,5)

<4,5>

(1,<1,2>)

<1,2>

(1,<1,3>)

<1,3>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 32: White-Box Testing Techniques II

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

du-pair path(s)

(1,2)

<1,2>

(1,4)

<1,3,4>

(1,5)

<1,3,4,5>

<1,3,5>

(1,<3,4>)

<1,3,4>

(1,<3,5>)

<1,3,5>

(2,4)

<2,3,4>

(2,5)

<2,3,4,5>

<2,3,5> (2,<3,4>)

<2,3,4>

(2,<3,5>)

<2,3,5>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 33: White-Box Testing Techniques II

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

du-pair path(s)

(1,4)

<1,2,3,4>

<1,3,4>

(1,5)

<1,2,3,5>

<1,3,5>

(4,5)

<4,5>

(1,<1,2>)

<1,2>

(1,<1,3>)

<1,3>

1

2

3

4

5

input(A,B)

A := A+7

B := A+B

B>1

B1

A>10

A10

output(A,B)

Page 34: White-Box Testing Techniques II

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

Page 35: White-Box Testing Techniques II

Example 2

1. input(X,Y)2. while (Y>0) {3. if (X>0)4. Y := Y-X else5. input(X)6. }7. output(X,Y)

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 36: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 37: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 38: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 39: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 40: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-Xinput(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 41: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-Xinput(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 42: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-Xinput(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 43: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-Xinput(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 44: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 45: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 46: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 47: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 48: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y = Y-Xinput(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 49: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 50: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 51: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(1,4)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,7)

<1,2,7>

<1,2,3,4,6,7>

<1,2,3,4,6,(3,4,6)*,7>

(1,<3,4>)

<1,2,3,4>

<1,2,3,4,(6,3,4)*>

(1,<3,5>)

<1,2,3,5>

(5,4) <5,6,3,4>

<5,6,3,4,(6,3,4)*>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 52: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7>

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 53: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 54: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 55: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 56: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 57: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 58: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 59: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 60: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5>

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 61: White-Box Testing Techniques II

Identifying DU-Pairs – Variable Xdu-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5> †

<5,6,3,4,6,(3,4,6)*,3,5>

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 62: White-Box Testing Techniques II

Identifying DU-Pairs – Variable X

du-pair path(s)

(5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*7>

(5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

(5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5> †

<5,6,3,4,6,(3,4,6)*,3,5> †

† infeasible

1

3

input(X,Y))

Y := Y-X

input(X)

Y>0

Y0

X>0

output(X,Y)

X0

2

45

6

7Y>0

Y0

Page 63: White-Box Testing Techniques II

More Dataflow Terms and Definitions

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

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

Page 64: White-Box Testing Techniques II

Simple and Loop-Free Paths

path Simple? Loop-free?

<1,3,4,2>

<1,2,3,2>

<1,2,3,1,2>

<1,2,3,2,4>

Page 65: White-Box Testing Techniques II

More Dataflow Terms and Definitions

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

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

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

Page 66: White-Box Testing Techniques II

More Dataflow Terms and Definitions

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

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

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

NOTE!

Page 67: White-Box Testing Techniques II

Identifying du-paths

du-pair path(s) du-path?

X: (5,7)

<5,6,7> †

<5,6,3,4,6,7>

<5,6,3,4,6,(3,4,6)*,7>

X: (5,<3,4>)

<5,6,3,4>

<5,6,3,4,(6,3,4)*>

X: (5,<3,5>)

<5,6,3,5>

<5,6,3,4,6,3,5> †

<5,6,3,4,6,(3,4,6)*,3,5> †

† infeasible

Page 68: White-Box Testing Techniques II

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

Page 69: White-Box Testing Techniques II

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

Page 70: White-Box Testing Techniques II

White-Box Coverage Subsumption Relationships

Path

All du-paths

All-Uses

All-Defs

Compound Condition

Branch / Condition Basis Paths Loop

Condition

Statement

Branch