Du Prog Slicing V2
Du Prog Slicing V2
The value printed will be whatever value was "left over" in the memory
location to which x has been assigned, not necessarily what the
programmer wanted or expected.
Introduction – Technique
Variables that contain data values have a
defined life cycle.
Killed (k) - data once defined has been undefined some how,
e.g. if it was a pointer , it may have been freed.
Predicate Uses and
Computation Uses
Data flow testing uses the control flow graph to explore the
unreasonable things that can happen to data (data flow
anomalies).
Data flow anomalies
Variable that is defined but never used
Second path
1
3
Find Bugs
Paths for y variable
Path
Find Bugs
Paths for z variable
Path 1
Find Bugs
Paths for z variable
Path 2
Issues Identified
Data flow Testing
The data flow testing process is to choose
enough test cases so that:
2. Program slicing
DU Testing
Define/Use Testing
1. Defining Node
Defining Node (n)
◦ Of variable v -> DEF(v, n)
Example:
◦ Input statement
◦ Assignment statement
◦ Loop control statement
◦ Procedure calls
Example:
◦ Output statement
◦ Conditional statement
◦ Loop control statement
◦ Assignment statements
(1, 2, 3, 5)
Example
1. void f() {
2. float x;
3. float y;
4. x = read();
5. y = read();
6. if (x > 0)
7. x += 10;
8. y = y / x;
9. write(x);
10. write(y);
11. }
Example
Variable define Use
1. void f() { X 4,7 6,7,8,9
2. float x;
3. float y; Y 5,8 8,10
4. x = read();
5. y = read();
6. if (x > 0)
7. x += 10;
8. y = y / x;
9. write(x);
10. write(y);
11. }
Example Variable define Use
X 4,7 6,7,8,9
1. void f() {
2. float x;
3. float y; DU paths for Can also be
4. x = read(); variable X written as
4,5,6 4-6
5. y = read();
4,5,6,7 4-7
6. if (x > 0) 4,5,6,7,8 4-8
7. x += 10; 4,5,6,7,8,9 4-9
8. y = y / x; 7,6 7-6
9. write(x); 7,7 7-7
Find paths?
Tell whether they are definition clear or not ?
Du path for locks
Path 1 : 13,14
Path 2: 13,14,15,16
Path 3: 19,20,14
Path 4: 19, 20, 14, 15, 16