Title: White-Box Testing Techniques II
1White-Box Testing Techniques II
Dataflow Testing
- Originals prepared by
- Stephen M. Thebaut, Ph.D.
- University of Florida
2White-Box Testing Topics
- Logic coverage
- Dataflow coverage
- Path conditions and symbolic execution (lecture
III) - Other white-box testing strategies
- e.g. fault-based testing
3Dataflow 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
4Variable 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)
5Variable Use
- A program variable is USED when it appears
- on the right hand side of an assignment statement
eg y x17 - 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
gt 0 )
6Variable 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 gt 0 )
- print(y)
- there is a p-use of x and a c-use of y
7Variable 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 )
8More 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
9Dataflow 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 programs 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
10Example 1
- 1. input(A,B)
- if (Bgt1)
- 2. A A7
-
- 3. if (Agt10)
- 4. B AB
-
- 5. output(A,B)
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
11Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
12Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
13Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
14Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
15Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
16Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
17Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
18Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
19Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
20Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
21Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
22Identifying DU-Pairs Variable A
du-pair path(s)
(1,2) lt1,2gt
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt
(2,5) lt2,3,4,5gt
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
23Identifying DU-Pairs Variable B
input(A,B)
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,3,4gt
(1,5) lt1,2,3,5gt
lt1,3,5gt
(1,lt1,2gt) lt1,2gt
(1,lt1,3gt) lt1,3gt
(4,5) lt4,5gt
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
24Dataflow 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
25Dataflow Test Coverage Criteria
- Consider a test case executing path
- 1. lt1,2,3,4,5gt
- 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?
26Def-Clear Paths subsumed by lt1,2,3,4,5gt for
Variable A
du-pair path(s)
(1,2) lt1,2gt ?
(1,4) lt1,3,4gt
(1,5) lt1,3,4,5gt
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt ?
(2,5) lt2,3,4,5gt ?
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt ?
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
27Def-Clear Paths Subsumed by lt1,2,3,4,5gt for
Variable B
input(A,B)
du-pair path(s)
(1,4) lt1,2,3,4gt ?
lt1,3,4gt
(1,5) lt1,2,3,5gt
lt1,3,5gt
(4,5) lt4,5gt ?
(1,lt1,2gt) lt1,2gt ?
(1,lt1,3gt) lt1,3gt
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
28Dataflow Test Coverage Criteria
- Since lt1,2,3,4,5gt 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
29Dataflow 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. lt1,3,4,5gt
- 3. lt1,2,3,5gt
- Do all three test cases provide All-Uses coverage?
30Def-Clear Paths Subsumed by lt1,3,4,5gt for
Variable A
du-pair path(s)
(1,2) lt1,2gt ?
(1,4) lt1,3,4gt ?
(1,5) lt1,3,4,5gt ?
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt ?
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt ?
(2,5) lt2,3,4,5gt ?
lt2,3,5gt
(2,lt3,4gt) lt2,3,4gt ?
(2,lt3,5gt) lt2,3,5gt
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
31Def-Clear Paths Subsumed by lt1,3,4,5gt for
Variable B
input(A,B)
du-pair path(s)
(1,4) lt1,2,3,4gt ?
lt1,3,4gt ?
(1,5) lt1,2,3,5gt
lt1,3,5gt
(4,5) lt4,5gt ??
(1,lt1,2gt) lt1,2gt ?
(1,lt1,3gt) lt1,3gt ?
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
32Def-Clear Paths Subsumed by lt1,2,3,5gt for
Variable A
du-pair path(s)
(1,2) lt1,2gt ? ?
(1,4) lt1,3,4gt ?
(1,5) lt1,3,4,5gt ?
lt1,3,5gt
(1,lt3,4gt) lt1,3,4gt ?
(1,lt3,5gt) lt1,3,5gt
(2,4) lt2,3,4gt ?
(2,5) lt2,3,4,5gt ?
lt2,3,5gt ?
(2,lt3,4gt) lt2,3,4gt ?
(2,lt3,5gt) lt2,3,5gt ?
input(A,B)
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
33Def-Clear Paths Subsumed by lt1,2,3,5gt for
Variable B
input(A,B)
du-pair path(s)
(1,4) lt1,2,3,4gt ?
lt1,3,4gt ?
(1,5) lt1,2,3,5gt ?
lt1,3,5gt
(4,5) lt4,5gt ??
(1,lt1,2gt) lt1,2gt ? ?
(1,lt1,3gt) lt1,3gt ?
1
Bgt1
2
A A7
B?1
3
Agt10
4
B AB
A?10
5
output(A,B)
34Dataflow Test Coverage Criteria
- None of the three test cases covers the du-pair
(1,lt3,5gt) for variable A, - All-Uses Coverage is not achieved
35Example 2
- 1. input(X,Y)
- 2. while (Ygt0)
- 3. if (Xgt0)
- 4. Y Y-X
- else
- 5. input(X)
- 6.
- 7. output(X,Y)
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
36Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
37Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
38Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
39Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
40Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
41Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
42Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
43Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
44Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
45Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
46Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
47Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
48Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
49Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
50Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
51Identifying DU-Pairs Variable X
du-pair path(s)
(1,4) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,7) lt1,2,7gt
lt1,2,3,4,6,7gt
lt1,2,3,4,6,(3,4,6),7gt
(1,lt3,4gt) lt1,2,3,4gt
lt1,2,3,4,(6,3,4)gt
(1,lt3,5gt) lt1,2,3,5gt
(5,4) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
52Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
53Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
54Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
55Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
56Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
57Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
58Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
59Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6)7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
60Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6)7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
61Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6)7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
62Identifying DU-Pairs Variable X
du-pair path(s)
(5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6)7gt
(5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
(5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
1
input(X,Y))
2
Ygt0
Y?0
3
Xgt0
X?0
Y Y-X
input(X)
4
5
6
Y?0
Ygt0
7
output(X,Y)
63More 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
64Simple and Loop-Free Paths
path Simple? Loop-free?
lt1,3,4,2gt
lt1,2,3,2gt
lt1,2,3,1,2gt
lt1,2,3,2,4gt
65More Dataflow Terms and Definitions
- A path ltn1,n2,...,nj,nkgt is a du-path with
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
ltn1,n2,...,nj,nkgt is a def-clear simple path, or - there is a p-use of v at edge ltnj,nkgt and
ltn1,n2,...njgt is a def-clear loop-free path.
66More Dataflow Terms and Definitions
- A path ltn1,n2,...,nj,nkgt is a du-path with
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
ltn1,n2,...,nj,nkgt is a def-clear simple path, or - there is a p-use of v at edge ltnj,nkgt and
ltn1,n2,...njgt is a def-clear loop-free path.
NOTE!
67Identifying du-paths
du-pair path(s) du-path?
X (5,7) lt5,6,7gt
lt5,6,3,4,6,7gt
lt5,6,3,4,6,(3,4,6),7gt
X (5,lt3,4gt) lt5,6,3,4gt
lt5,6,3,4,(6,3,4)gt
X (5,lt3,5gt) lt5,6,3,5gt
lt5,6,3,4,6,3,5gt
lt5,6,3,4,6,(3,4,6),3,5gt
infeasible infeasible
68Another 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
69Exercise
- 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
70White-Box Coverage Subsumption Relationships
Path
Compound Condition
All du-paths
Branch / Condition
All-Uses
Basis Paths
Loop
Condition
Branch
All-Defs
Statement