Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 453, Prof. Kontogiannis University of Waterloo 1 Data Flow Testing Slice-Based Testing Winter 2006 Presented by Nikos Giannopoulos

Similar presentations


Presentation on theme: "ECE 453, Prof. Kontogiannis University of Waterloo 1 Data Flow Testing Slice-Based Testing Winter 2006 Presented by Nikos Giannopoulos"— Presentation transcript:

1 ECE 453, Prof. Kontogiannis University of Waterloo 1 Data Flow Testing Slice-Based Testing Winter 2006 Presented by Nikos Giannopoulos nikos@swen.uwaterloo.ca

2 ECE 453, Prof. Kontogiannis 2University of Waterloo Agenda Slice-Based Testing Definitions Slice-Based Testing Definitions Slice-Based Testing Examples Slice-Based Testing Examples

3 ECE 453, Prof. Kontogiannis 3University of Waterloo Agenda  Slice-Based Testing Definitions Slice-Based Testing Examples Slice-Based Testing Examples

4 ECE 453, Prof. Kontogiannis 4University of Waterloo Slice-Based Testing Definitions Given a program P, and a program graph G(P) in which statements and statement fragments are numbered, and a set V of variables in P, the slice on the variable set V at statement fragment n, written S(V,n), is the set node numbers of all statement fragments in P prior to n that contribute to the values of variables in V at statement fragment n Given a program P, and a program graph G(P) in which statements and statement fragments are numbered, and a set V of variables in P, the slice on the variable set V at statement fragment n, written S(V,n), is the set node numbers of all statement fragments in P prior to n that contribute to the values of variables in V at statement fragment n The idea of slices is to separate a program into components that have some useful meaning The idea of slices is to separate a program into components that have some useful meaning

5 ECE 453, Prof. Kontogiannis 5University of Waterloo Slice-Based Testing Definitions We will include CONST declarations in slices We will include CONST declarations in slices Five forms of usage nodes Five forms of usage nodes P-use (used in a predicate (decision)) P-use (used in a predicate (decision)) C-use (used in computation) C-use (used in computation) O-use (used for output, e.g. writeln()) O-use (used for output, e.g. writeln()) L-use (used for location, e.g. pointers) L-use (used for location, e.g. pointers) I-use (iteration, e.g. internal counters) I-use (iteration, e.g. internal counters) Two forms of definition nodes Two forms of definition nodes I-def (defined by input, e.g. readln()) I-def (defined by input, e.g. readln()) A-def (defined by assignment) A-def (defined by assignment) For now, we presume that the slice S(V,n) is a slice on one variable, that is, the set V consists of a single variable, v For now, we presume that the slice S(V,n) is a slice on one variable, that is, the set V consists of a single variable, v

6 ECE 453, Prof. Kontogiannis 6University of Waterloo Slice-Based Testing Definitions If statement fragment n (in S(V,n)) is a defining node for v, then n is included in the slice If statement fragment n (in S(V,n)) is a defining node for v, then n is included in the slice If statement fragment n (in S(V,n)) is a usage node for v, then n is not included in the slice If statement fragment n (in S(V,n)) is a usage node for v, then n is not included in the slice P-uses and C-uses of other variables are included to the extent that their execution affects the value of the variable v P-uses and C-uses of other variables are included to the extent that their execution affects the value of the variable v O-use, L-use, and I-use nodes are excluded from slices O-use, L-use, and I-use nodes are excluded from slices Consider making slices compilable Consider making slices compilable

7 ECE 453, Prof. Kontogiannis 7University of Waterloo Agenda Slice-Based Testing Definitions Slice-Based Testing Definitions  Slice-Based Testing Examples

8 ECE 453, Prof. Kontogiannis 8University of Waterloo Slice-Based Testing Examples Find the following program slices Find the following program slices S(commission,48) S(commission,48) S(commission,40) S(commission,40) S(commission,39) S(commission,39) S(commission,38) S(commission,38) S(sales,35) S(sales,35) S(num_locks,34) S(num_locks,34) S(num_stocks,34) S(num_stocks,34) S(num_barrels,34) S(num_barrels,34)

9 ECE 453, Prof. Kontogiannis 9University of Waterloo Slice-Based Testing Examples S(commission,48) S(commission,48) {1-5,8-11,13,14, 19-30,36,47,48,53} {1-5,8-11,13,14, 19-30,36,47,48,53} S(commission,40), S(commission,39), S(commission,38) S(commission,40), S(commission,39), S(commission,38) {Ø} {Ø} S(sales,35) S(sales,35) {Ø} {Ø}

10 ECE 453, Prof. Kontogiannis 10University of Waterloo Slice-Based Testing Examples S(num_locks,34) S(num_locks,34) {1,8,9,10,13,14,19, 22,23,24,26,29,30, 53} {1,8,9,10,13,14,19, 22,23,24,26,29,30, 53}

11 ECE 453, Prof. Kontogiannis 11University of Waterloo Slice-Based Testing Examples S(num_stocks,34) S(num_stocks,34) {1,8,9,10,13,14,20, 22-25,27,29,30,53} {1,8,9,10,13,14,20, 22-25,27,29,30,53}

12 ECE 453, Prof. Kontogiannis 12University of Waterloo Slice-Based Testing Examples S(num_barrels,34) S(num_barrels,34) {1,8,9,10,13,14, 21-25,28,29,30,53} {1,8,9,10,13,14, 21-25,28,29,30,53}

13 ECE 453, Prof. Kontogiannis 13University of Waterloo Slice-Based Testing Examples Find the program slice on FinalUse(low). Use the Program Dependency Graph approach Find the program slice on FinalUse(low). Use the Program Dependency Graph approach int binSearch(int x, int v[], int n) { {1} int low = 0; {2} int high = n – 1; {3} int mid; {4} while (low <= high) { {5} mid = (low + high) / 2; {6} mid = (low + high) / 2; {6} if (x < v[mid]) {7} if (x < v[mid]) {7} high = mid – 1; {8} else if (x > v[mid]) {9} else if (x > v[mid]) {9} low = mid + 1; {10} else {11} else {11} return mid; {12} } {13} return -1; {14} } {15}

14 ECE 453, Prof. Kontogiannis 14University of Waterloo Slice-Based Testing Examples Program Dependency Graph

15 ECE 453, Prof. Kontogiannis 15University of Waterloo Slice-Based Testing Examples Slice based on the criterion FinalUse(low)

16 ECE 453, Prof. Kontogiannis 16University of Waterloo Slice-Based Testing Examples int binSearch(int x, int v[], int n) { {1} int low = 0; {2} int high = n – 1; {3} int mid; {4} while (low <= high) { {5} mid = (low + high) / 2; {6} mid = (low + high) / 2; {6} if (x < v[mid]) {7} if (x < v[mid]) {7} high = mid – 1; {8} else if (x > v[mid]) {9} else if (x > v[mid]) {9} low = mid + 1; {10} else {11} else {11} return mid; {12} } {13} return -1; {14} } {15} int binSearch(int x, int v[], int n) { {1} int low = 0; {2} int high = n – 1; {3} int mid; {4} while (low <= high) { {5} mid = (low + high) / 2; {6} mid = (low + high) / 2; {6} if (x < v[mid]) {7} if (x < v[mid]) {7} high = mid – 1; {8} else if (x > v[mid]) {9} else if (x > v[mid]) {9} low = mid + 1; {10} } {13} } {15} → Slice on FinalUse(low)

17 ECE 453, Prof. Kontogiannis 17University of Waterloo Agenda Slice-Based Testing Definitions Slice-Based Testing Definitions Slice-Based Testing Examples Slice-Based Testing Examples

18 ECE 453, Prof. Kontogiannis 18University of Waterloo References Software Testing A Craftsman's Approach 2nd edition, Paul C. Jorgensen, CRC Press (Chapter 10 (10.2)) Software Testing A Craftsman's Approach 2nd edition, Paul C. Jorgensen, CRC Press (Chapter 10 (10.2))


Download ppt "ECE 453, Prof. Kontogiannis University of Waterloo 1 Data Flow Testing Slice-Based Testing Winter 2006 Presented by Nikos Giannopoulos"

Similar presentations


Ads by Google