Title: ASTReNet Workshop
1ASTReNet Workshop
- Automated Test Data Generation
- Bogdan Korel
- Department of Computer Science
- Illinois Institute of Technology
- Chicago, IL USA
2Summary
- Introduction to test data generation
- Application of test data generation
- Test data generation methods
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach
- Data dependence oriented test generation
- Conclusions
3Test Data Generation Problem
- Given a target
- Goal find a program input on which the target
is executed
4Application of Test Data Generation
- Code-based (white-box) testing
- Identification of program properties
- Specification-based testing
- Testing specification conformance
-
5Application of Test Data Generation
- Code-based (white-box) testing
- There exists many code-based testing coverage
techniques - Statement testing
- Branch testing
- Path testing
- Data flow testing
- Multiple-condition testing
- .
6Application of Test Data Generation
- Testers are interested in finding program inputs
to execute never-executed elements, e.g., - Statements
- Branches
- Paths
- Data flows
- Multiple-conditions
- .
7Test Data Generation Problem
Find input x on which the target statement is
executed!!
program
Target statement
8Application of Test Data Generation
- Identification of program properties
- Programmers may be interested in program
properties inside or outside of the program - These properties are expressed as assertions that
describe relationships between program variables. - Assertion (max lt min)
9Application of Test Data Generation
Find input x on which Assertion A is satisfied!!
program
Assertion A
10Application of Test Data Generation
- Specification-based testing
- Equivalence class partitioning
- Input equivalence partitioning
- Output equivalence partitioning
11Application of Test Data Generation
- Specification-based testing
- Equivalence class partitioning
- Input equivalence partitioning
- Output equivalence partitioning
12Application of Test Data Generation
Find input x on which y101
program
Test y101
output y
13Test Data Generation Problem
- Given a target
- Goal find a program input on which the target
is executed
14Target
- A statement
- A branch
- A path
- A data flow
- A multiple condition
- An assertion
- A specific output value
-
15Automated Test Data Generation
- It may be very hard to find manually program
inputs to execute the target - We are interested in automated test data
generation
16Test data generators
- Test generators can automatically find program
inputs (test data) on which the target is
executed - A test case generator automatically generates
test data from - Source code
- Specification
17Test Data Generators
- Two types of test generators
- Code-based test generators
- Specification-based test generators
18Test Data Generators
- Two types of test generators
- Code-based test generators
- Specification-based test generators
19Classical Test Data Generation Problem
- Given a target statement
- Goal find a program input on which the target
statement is executed
20Test Data Generation Problem
Find input x on which the target statement is
executed!!
program
Target statement
21Automated Test Data Generation
- The problem of finding such input is an
un-decidable problem - It is not possible to design an algorithm that
can solve the test generation problem for any
program. - It is not possible to build a Test Generator that
can find a program input on which a target is
executed for any program.
22Automated Test Data Generation
- All test generation algorithms are heuristic
algorithms - They can frequently generate test data for which
a selected target is executed, - but
- These algorithms cannot guarantee to generate an
input (test) to execute a selected target for any
program.
23Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
24Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
25Random Test Generation
- Test data (inputs) are generated randomly
26Random Test Generation
Find input x on which the target statement is
executed!!
Target statement
27Random Test Generation
execute program on any input
Randomly generated inputs
28Random Test Generation
- Advantages
- The approach is easy to develop for any program
- Major failures may be detected (e.g., crashes)
during the search (generation) - Disadvantages
- Effectiveness??
- To increase the effectiveness semi-random methods
are used, but they have to be developed manually
29Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
30Path-Oriented Test Generation
Target statement S
Select path P to target statement S
Find input to execute path P
no
An input to execute path P and target statement S
yes
Input found?
31Path-Oriented Test Generation
1. Select a path
2. Find input to execute the path
Failure!!
1. Select another path
32Path-Oriented Test Generation
1. Select a path
2. Find input to execute the path
Failure!!
1. Select another path
2. Find input to execute the path
33Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
34Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
35Path-Oriented Test Generation
Target statement S
Select path P to target statement S
Symbolically execute program for path P
Solve equalities and inequalities
no
Solution is an input to execute path P and target
statement S
yes
Solution found?
36Symbolic execution
- Regular program execution is based on specific
input data - Symbolic execution
- program is executed using only symbols
- during symbolic execution input symbols rather
than input data are used - program is symbolically executed along the
selected path
37Example
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
38Path selection
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
39Path selection
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
1 input (a,n) 2 maxa1 3 mina1 4 i2
5 while (iltn) 6 if (maxltai) 8 if
(mingtai) 10 ii1 5 while (iltn) 11 output(m
in,max)
40Path selection
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6 if (maxltai)
- 8 if (mingtai)
- 10 ii1
- 5 while (iltn)
- 11 output(min,max)
41Symbolic execution
input symbols a0, n0
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6 if (maxltai)
- 8 if (mingtai)
- 10 ii1
- 5 while (iltn)
- 11 output(min,max)
aa0, nn0 maxa01 mina01 i2 (2ltn0) (a01
lta02) (a01gta02) i213 (3ltn0) output(a01
, a01)
42Symbolic execution
input symbols a0, n0
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6 if (maxltai)
- 8 if (mingtai)
- 10 ii1
- 5 while (iltn)
- 11 output(min,max)
aa0, nn0 maxa01 mina01 i2 (2ltn0) (a01
lta02) (a01gta02) i213 (3ltn0) output(a01
, a01)
43Symbolic execution
input symbols a0, n0
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6 if (maxltai)
- 8 if (mingtai)
- 10 ii1
- 5 while (iltn)
- 11 output(min,max)
aa0, nn0 maxa01 mina01 i2 (2ltn0) (a01
lta02) (a01gta02) i213 (3ltn0) output(a01
, a01)
T
F
F
F
44Symbolic execution
input symbols a0, n0
(2ltn0) (a01lta02) (a01gta02) (3ltn0)
T
F
F
F
45Symbolic execution
input symbols a0, n0
(2ltn0) (a01lta02) (a01gta02) (3ltn0)
T
F
F
F
SOLVE IT!!
46Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
47Execution-Oriented Test Generation
- Based on actual program execution
- It solves problems (sub-goals) along the selected
path as they occur to reach the target statement
48Execution-Oriented Test Generation
int F(x)
yx4
target statement
F
T
ylt1
F
T
ylt2
z0
T
F
z1
ygt7
find value of x on which target statement is
executed
z2
z3
return z
49Execution-Oriented Test Generation
int F(x)
find a new value of x to execute False branch
Initial input
yx4
x -57
F
T
ylt1
F
T
ylt2
z0
T
F
z1
ygt7
z2
z3
return z
50Execution-Oriented Test Generation
int F(x)
find a new value of x to execute False branch
Initial input
yx4
x -57
F
T
ylt1
F
T
ylt2
z0
T
F
z1
ygt7
z2
z3
return z
51Execution-Oriented Test Generation
- A predicate of the conditional statement is used
to construct a fitness function - The fitness function is used by the search engine
52Execution-Oriented Test Generation
- A predicate
- y lt 1
- is currently True
- but we want to be False, i.e., y ? 1
- A fitness function
- G 1- y
- Find a new input x on which
- G ? 0
53Execution-Oriented Test Generation
int F(x)
Initial input
G1-y
yx4
x -57
F
T
ylt1
G 54
F
T
ylt2
z0
T
F
z1
ygt7
z2
z3
return z
54Execution-Oriented Test Generation
- There are many searching algorithms that can be
used to find a new program input based on the
fitness function - Hill-climbing algorithm
- Simulated annealing
- Evolutionary algorithm
55Execution-Oriented Test Generators
- Hill-climbing algorithm
- Exploratory moves
- To determine the direction of search
- Increase input variable by small ?
- Decrease input variable by small ?
- Pattern moves
- Based on the identified direction
increase/decrease input variable by a big step
56Execution-Oriented Test Generators
G1-y
exploratory moves
x
-57
-58
43
-56
-7
direction of search
57Execution-Oriented Test Generation
int F(x)
find a new value of x to execute False branch
Input
yx4
x 43
F
T
ylt1
F
T
ylt2
z0
T
F
z1
ygt7
z2
z3
return z
58Execution-Oriented Test Generation
int F(x)
find a new value of x to execute False branch
Initial input
yx4
x 43
F
T
ylt1
F
T
ylt2
z0
T
F
z1
ygt7
z2
z3
return z
59Execution-Oriented Test Generators
- The shape of a fitness function is unknown
- Problems with local minimum
60Execution-Oriented Test Generators
G
exploratory moves
fitness function
x
-57
-58
-56
direction of search
61Execution-Oriented Test Generators
G
exploratory moves
fitness function
local minimum
x
-57
-58
-56
direction of search
62Execution-Oriented Test Generators
- The shape of a fitness function is unknown
- Problems with local minimum
- Repeat search for different initial inputs
- Evolutionary algorithms
63Execution-Oriented Test Generators
G
initially generated inputs
this initial input will lead to the solution
x
64Path-Oriented Test Generation
- Problems
- Selected paths are frequently non-executable
- It is considered a restrictive in the presence of
loops - A lot of search effort is wasted on
non-executable paths
65Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
66Goal-Oriented Test Generation
- Paths are not selected
- Based on actual program execution
- A control graph of the program is used
- It solves problems (sub-goals) as they occur to
reach the target statement
67Goal-Oriented Test Generation
target statement
68Goal-Oriented Test Generation
execute program on any input
Success input found!!!
69Goal-Oriented Test Generation
execute program on any input
70Goal-Oriented Test Generation
execute program on any input
71Goal-Oriented Test Generation
execute program on any input
problem node
this execution may lead to the target
this execution does not lead to the target
72Goal-Oriented Test Generators
execute program on any input
problem node
We want to find a new program input so execution
follows this branch
73Goal-Oriented Test Generators
execute program on any input
problem node
We want to find a new program input so execution
follows this branch
74Goal-Oriented Test Generation
- A predicate of the conditional statement is used
to construct a fitness function - The fitness function is used by the search engine
75Sample program and its control graph
en
1
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
2
3
4
5
6
7
8
9
10
11
ex
76Goal-Oriented Test Generation
en
1
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
2
3
4
5
6
7
8
9
10
11
ex
77Goal-Oriented Test Generation
en
1
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
2
3
4
5
6
7
8
9
10
11
ex
78Goal-Oriented Test Generation
en
1
2
3
4
5
6
7
8
9
10
11
ex
79Goal-Oriented Test Generation
en
1
2
3
4
5
6
7
8
9
10
11
ex
80Goal-Oriented Test Generation
- Branch classification
- OK branches
- Critical branches
- Semi-critical branches
81Goal-Oriented Test Generation
target
82Goal-Oriented Test Generation
OK branch
acyclic path
target
83Goal-Oriented Test Generation
critical branch
there is no path to the target
target
84Goal-Oriented Test Generation
Semi-critical branch
acyclic path
target
no acyclic path to target
85Goal-Oriented Test Generation
en
1
2
3
4
5
6
7
8
9
10
11
ex
86Goal-Oriented Test Generation
en
OK branch
1
critical branch
2
semi-critical branch
3
4
5
6
7
8
9
10
11
ex
87Goal-Oriented Test Generation
- OK branch
- Continue execution
- Critical branch
- Stop execution
- Search for new input to execute an alternative
branch - If the search fails, the search failure is
declared - Semi-critical branch
- Stop execution
- Search for new input to execute an alternative
branch - If the search fails, continue execution through
the semi-critical branch
88Goal-Oriented Test Generation
en
OK branch
1
critical branch
2
semi-critical branch
3
4
5
6
7
8
9
10
11
ex
89Goal-Oriented Test Generation
- The goal-oriented approach may significantly
increase chances of finding inputs as compared to
path-oriented methods - A control graph of the program is only used
during the search - For some programs using a control graph may not
be sufficient to find a solution (an input to
execute the target statement)
90Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
91Chaining Approach
- The chaining approach is an extension of the
goal-oriented approach - The chaining approach uses
- Control flow graph
- Data flow (data dependence) information
92Data flow (data dependence) concepts
- A definition of variable v is a statement that
assigns a value to variable v - v15
- input (v)
- An use of variable v is a statement (or
predicate) that uses (references) variable v - yv1
- print(v)
- if (vlt0)
- vv1
93Data flow (data dependence) concepts
- There exists a data flow (data dependence)
between statement S1 and S2 if - S1 is a definition of variable v
- S2 is an use of variable v
- There exists a path in the program from S1 to S2
along which v is not modified
94Data flow (data dependence) concepts
S1 v
S2 yv1
95Sample program and its control graph
en
1
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) maxai
- 8,9 if (mingtai) minai
- 10 ii1
-
- 11 output(min,max)
2
3
4
5
6
7
8
9
10
11
ex
96Sample data flows w.r.t. variable max
en
1
- 1 input (a,n)
- 2 maxa1
- 3 mina1
- 4 i2
- 5 while (iltn)
- 6,7 if (maxltai) then maxai
- 8,9 if (mingtai) then minai
- 10 ii1
-
- 11 output(min,max)
2
3
4
5
6
7
8
9
10
11
ex
97Chaining Approach
Goal-oriented search fails at a critical branch
98Chaining Approach
Goal-oriented search fails at a critical branch
99Chaining Approach
- The goal-oriented approach may fail because
- A fitness function cannot be constructed from a
predicate, e.g., when Booelan flags are used - if (flag)
- A control flow graph alone is not sufficient to
find a new input to executed an alternative
branch to a critical branch
100Chaining Approach
The chaining approach uses data flows (data
dependences) to identify such statements
Which statements influence the predicate?
The chaining approach uses data dependences to
identify such statements
101Chaining Approach
p
vgt0
target
102Chaining Approach
v..
S2
v..
v..
S1
S3
p
vgt0
target
103Chaining Approach
- A chain is a sequence of statements.
104Chaining Approach
Variable v should not be modified between S1 and p
105Sample program
en
- 1 input (a,x)
- 2 flag1
- 3 i1
- 4 while (ilt10)
- 5,6 if (ailtgtx) flag0
- 7 ii1
-
- 8,9 if (flag) target
1
2
3
4
5
6
7
8
9
ex
106Sample program
en
- 1 input (a,x)
- 2 flag1
- 3 i1
- 4 while (ilt10)
- 5,6 if (ailtgtx) flag0
- 7 ii1
-
- 8,9 if (flag) target
1
2
3
4
5
6
7
problem statement
8
9
ex
107Sample program
en
- 1 input (a,x)
- 2 flag1
- 3 i1
- 4 while (ilt10)
- 5,6 if (ailtgtx) flag0
- 7 ii1
-
- 8,9 if (flag) target
1
2
3
4
5
6
7
8
9
ex
108Chaining Approach
109Chaining Approach
Branch classification
110Sample program
en
- 1 input (a,x)
- 2 flag1
- 3 i1
- 4 while (ilt10)
- 5,6 if (ailtgtx) flag0
- 7 ii1
-
- 8,9 if (flag) target
1
2
3
4
5
6
7
8
9
ex
111Sample program
en
- 1 input (a,x)
- 2 flag1
- 3 i1
- 4 while (ilt10)
- 5,6 if (ailtgtx) flag0
- 7 ii1
-
- 8,9 if (flag) target
1
2
3
4
5
6
7
8
9
ex
112Sample program
en
- 1 input (a,x)
- 2 flag1
- 3 i1
- 4 while (ilt10)
- 5,6 if (ailtgtx) flag0
- 7 ii1
-
- 8,9 if (flag) target
OK branch
1
critical branch
2
semi-critical branch
3
4
5
6
7
8
9
ex
113Chaining Approach
Chain expansion
a new problem statement may be encountered
between S1 and p
114Chaining Approach
Chain expansion
v
v
p1
en
S1
p
target
a new problem statement may be encountered
between S1 and p
115Chaining Approach
Chain expansion
v
v
p1
en
S1
p
target
Suppose there are data dependences
between statement A1 and p1 statement A2 and p1
with respect to variable x
116Chaining Approach
v
v
p1
en
S1
p
target
Chain expansion
v
v,x
v
p1
en
S1
p
target
A1
x
v,x
v
p1
en
A2
p
target
S1
117Chaining Approach
- It may significantly increase chances of finding
inputs over the goal-oriented approach - It can partially alleviate problems associated
with programs with flags - It relies on direct data dependences related to
problem statements - The search depends on the sequence of problems
statements that are identified during the search - The chaining approach does not have a global
view of dependences in the program
118Test Data Generation Methods
- Random test generation
- Path-oriented test generation
- Symbolic execution oriented test generation
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach of test generation
- Data dependence based test generation
- Simulated annealing
- Evolutionary algorithms
-
119Data Dependence Based Generation
- The data dependence based test generation is an
extension of the chaining approach - The data dependence based test generation uses a
data dependence graph rather than individual data
dependences during the search
1201 void F(int A, int C) int i, j, top,
f_exit 2 i1 3 j 1 4 top 0
5 f_exit0 6 while (Cjlt5) 7 j j 1
8 if (Cj 1) 9 i i 1 10
if (Ai gt 0) 11,12 top
top 1 ARtop Ai 13
if (Cj 2) 14 if (topgt0) 15,16
write(ARtop) top top - 1
17 if (Cj3) 18,19 if (topgt100)
write(1) 20 else write(0)
//endwhile
1211 void F(int A, int C) int i, j, top,
f_exit 2 i1 3 j 1 4 top 0
5 f_exit0 6 while (Cjlt5) 7 j j 1
8 if (Cj 1) 9 i i 1 10
if (Ai gt 0) 11,12 top
top 1 ARtop Ai 13
if (Cj 2) 14 if (topgt0) 15,16
write(ARtop) top top - 1
17 if (Cj3) 18,19 if (topgt100)
write(1) 20 else write(0)
//endwhile
target statement
1221 void F(int A, int C) int i, j, top,
f_exit 2 i1 3 j 1 4 top 0
5 f_exit0 6 while (Cjlt5) 7 j j 1
8 if (Cj 1) 9 i i 1 10
if (Ai gt 0) 11,12 top
top 1 ARtop Ai 13
if (Cj 2) 14 if (topgt0) 15,16
write(ARtop) top top - 1
17 if (Cj3) 18,19 if (topgt100)
write(1) 20 else write(0)
//endwhile
problem statement
1231 void F(int A, int C) int i, j, top,
f_exit 2 i1 3 j 1 4 top 0
5 f_exit0 6 while (Cjlt5) 7 j j 1
8 if (Cj 1) 9 i i 1 10
if (Ai gt 0) 11,12 top
top 1 ARtop Ai 13
if (Cj 2) 14 if (topgt0) 15,16
write(ARtop) top top - 1
17 if (Cj3) 18,19 if (topgt100)
write(1) 20 else write(0)
//endwhile
1241 void F(int A, int C) int i, j, top,
f_exit 2 i1 3 j 1 4 top 0
5 f_exit0 6 while (Cjlt5) 7 j j 1
8 if (Cj 1) 9 i i 1 10
if (Ai gt 0) 11,12 top
top 1 ARtop Ai 13
if (Cj 2) 14 if (topgt0) 15,16
write(ARtop) top top - 1
17 if (Cj3) 18,19 if (topgt100)
write(1) 20 else write(0)
//endwhile
125Data Dependence Based Generation
4
11
16
18
Data-dependence graph
126Data Dependence Based Generation
4
11
16
18
Chaining approach
127Data Dependence Based Generation
4
11
16
18
Data-dependence graph
128Data Dependence Based Generation
- The data dependence based test generation
identifies and explores different paths in the
data-dependence graph leading to the problem
statement - This approach tries to identify data-dependence
paths for which the fitness function evaluates to
the target value
129Data Dependence Based Generation
4
11
16
18
130Data Dependence Based Generation
4
11
16
18
en, 4, 11, 18
131Data Dependence Based Generation
132Data Dependence Based Generation
4
11
16
18
en, 4, 11, 16, 11, 18
133Data Dependence Based Generation
- Many different paths (chains) can be generated
from the data dependence graph for exploration - P1 en, 4, 18
- P2 en, 4, 11, 18
- P3 en, 4, 16, 18
- P4 en, 4, 11, 16, 18
- P5 en, 4, 16, 11, 18
-
134Data Dependence Based Generation
- It may be expensive to explore all these paths
(chains) in the original program - We are looking for paths for which the fitness
function evaluates to the target value
1351 void F(int A, int C) int i, j, top,
f_exit 2 i1 3 j 1 4 top 0
5 f_exit0 6 while (Cjlt5) 7 j j 1
8 if (Cj 1) 9 i i 1 10
if (Ai gt 0) 11,12 top
top 1 ARtop Ai 13
if (Cj 2) 14 if (topgt0) 15,16
write(ARtop) top top - 1
17 if (Cj3) 18,19 if (topgt100)
write(1) 20 else write(0)
//endwhile
136Data Dependence Based Generation
- The idea is to explore these paths not in the
original program - but
- in a transformed program in which it should be
much easier to determine whether the fitness
function may evaluate to the target value
137Data Dependence Based Generation
- Testability transformation
- A data dependence graph is used to construct a
corresponding (transformed) - The transformed program is used to identify paths
for which the fitness function evaluates to the
target value - These promising paths are then used on the
original program to find the solution
138Data Dependence Based Generation
- The input to the transformed program are
- A data-dependence path (chain)
- The output of the transformed program is the
value of the fitness function
139Data Dependence Based Generation
4
11
16
18
140float TransFunc(int PathSize, int S, int R)
int i, j, top 2 i1 3 while (iltPathSize)
4 switch (Si) 5 case 4 top 0 //
4 6 break 7 case 11 top top 1 // 11
8 for (j1jltRij) top top 1 9
break 10 case 16 top top - 1 //
16 11 for (j1jltRij) top top -
1 12 break 13 14
i 15 16 return 100-top //computation of
the fitness function at node 18
141Data Dependence Based Generation
4
11
16
18
en, 4, 11, 18
142Data Dependence Based Generation
- PathSize2
- S(4,11)
- R(?,?)
- GTransFunc(PathSize, S, R)
- Find R(?,?) such that G ? 0
- Solution R(1,101)
143Data Dependence Based Generation
- The solution can be found by exploring a very
small number of data dependence paths
144Conclusions
- Test data generation methods
- Execution-oriented test generation
- Goal-oriented test generation
- Chaining approach
- Data dependence oriented test generation
- These methods depend on
- A fitness function
- A control flow graph
- Data dependences/data dependence graph
145Conclusions
- Research challenges
- Programs with flags
- Programs for which a fitness function cannot be
constructed - Programs with many constraints
- Search in the presence of local minimum
- Comprehensive experimental study comparing the
existing methods
146Questions?