Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.

Similar presentations


Presentation on theme: "1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis."— Presentation transcript:

1 1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis

2 2 Overview  Structural Testing  Introduction – General Concepts  Flow Graph Testing  Data Flow Testing  Definitions  Some Basic Data Flow Analysis Algorithms  Define/use Testing  Slice Based Testing  Guidelines and Observations  Hybrid Methods  Retrospective on Structural Testing

3 3 Data Flow Testing – Basic Idea Data-flow testing involves selecting entry/exit paths with the objective of covering certain data definition and use patterns, commonly known as data-flow criteria An outline of data-flow testing is as follows: –Draw a data flow graph for the program –Select data-flow testing criteria –Identify paths in the data-flow graph to satisfy the selection criteria (i.e. all-defs, all-uses, all-P-uses/some-C-uses etc.) –Produce test cases for the selected paths

4 4 Some Definitions (1) Node n in the CFG of program P is a defining node of the variable v V, written as DEF(v, n), iff the value of the variable v is unambiguously defined at the statement fragment corresponding to node n. Node n in the CFG of program P is a usage node of the variable v V, written as USE(v, n), iff the value of the variable v is used at the statement fragment corresponding to node n.

5 5 Some Definitions (2) A usage node USE(v, n), is a predicate use (denoted as P-use) iff the statement n is a predicate statement, otherwise USE(v, n) is a computation use or C-use The nodes corresponding to predicate uses have always an outdegree ≥ 2, and nodes corresponding to computation uses always have outdegree ≤ 1

6 6 Some Definitions (3) A definition-use (sub)path with respect to a variable v (denoted as du-path) is a (sub)path in PATHS(P), where PATHS(P) is the set of all possible paths in the CFG of program P, such that, for some v in V, there are define and usage nodes DEF(v, m) and USE(v, n) such that m, and n are the initial and final nodes in the path respectively. A definition-clear (sub)path with respect to a variable v (denoted as dc-path) is a definition-use path in PATHS(P) with initial nodes DEF(v, m) and USE(v, n) such that there no other node in the path is a defining node for v

7 7 Some Definitions (4) A global definition is a definition of a variable x in node n if there is a definition of x in node n and there is a definition-clear path from n to some node m containing a global c-use of x, or containing a p-use of x. Note x is live at n A global c-use of variable x in node n is a c-use of variable x in node n and x has been defined in a node other than n

8 8 Some Definitions (5) Simple path is a path in which all nodes except possibly the first and the last are distinct Loop free path is a path in which all nodes are distinct Complete path is a path from the entry node to the exit node of the CFG Du-Path with respect to variable x at node n 1 is a path [n 1, n 2, …. n k ] where n 1 has a global definition of x and either –Node n k has a global c-use of x and [n 1 ….n k ] is def-clear simple path with respect to x or, –Node n k has a p-use of x and [n 1 ….nj] is a def-clear loop-free path with respect to x

9 9 Define / Use Information Example VariableDefined atUsed atComment locks9Declaration locks22READ locks23Predicate use locks26Computation Use stocks9READ stocks27Computation Use num_locks26Assignment num_locks26Computation Use num_locks33WRITE

10 10 DU-Path Test Coverage Criteria The basic idea is to use def-use information as defined in the previous slides and specific criteria in order to obtain specific paths in the CFG graph. These paths will then help us define specific test cases Let T be a set of feasible complete paths in the program’s P CFG, and V be the set of all variables in the program P

11 11 DU-Path Coverage Criteria (1) The set T satisfies the All-Defs criterion for a program P iff for every variable v in V, T contains definition clear (sub)paths from every defining node of v to a use of v. Note: Reaching definitions set) The set T satisfies the All-Uses criterion for the program P iff for every variable v in V, T contains definition-clear (sub)paths from every defining node of v to every use of v, and to the successor node of each USE(v, n) Note: def-use chains set We can distinguish between an All-C-Uses, or an All-P- Uses set

12 12 DU-Path Coverage Criteria (2) The set T satisfies the All-P-Uses/Some-C-Uses criterion for a program P iff for every variable v in V, T contains definition-clear (sub)paths from every defining node of v to every p-use of v, and if a definition of v has no p-uses, there is a definition-clear path to at least one c-use The set T satisfies the All-C-Uses/Some-P-Uses criterion for a program P iff for every variable v in V, T contains definition-clear (sub)paths from every defining node of v to every c-use of v, and if a definition of v has no c-uses, there is a definition-clear path to at least one p-use The set T satisfies the All-DU-Paths criterion for the program P iff for every variable v in V, T contains definition-clear (sub)paths from every defining node of v to every use of v, and to the successor node of each USE(v, n), and that these paths are either

13 13 Example public static double ReturnAverage(int value[], int AS, int MIN, int MAX) { int i, ti, tv, sum; double av; i = 0; ti = 0; tv = 0; sum = 0; while (ti < AS && value [i] != -999) { ti++; if (value[i] >= MIN && value[i} <= MAX) { tv++; sum = sum + value[i]; } i++; } if (tv > 0) av = (double) sum/tv; else av = (double) -999; return (av) }

14 14 Example Initialize: value[] AS, MIN, MAX i=0; ti=0; tv=0, sum=0 ((ti < AS) && (value[i] != -999)) tv > 0 av = (double) -999 av = (double) sum/tv return(av) ti++; (value[i] >= MIN && value[i] <= MAX) F F F T T T tv++; sum= sum+value[i] i++ 1 2 3 4 5 6 7 8 10 9

15 15 Examples Global c-use of variable tv : node 9 (tv is defined in nodes 2 and 5) Def-clear paths with respect to variable tv: 2-3-4-5, 2-3-4-6 Simple paths: 2-3-4-5 and 3-4-6-3 All-defs criterion paths for tv: –1-2-3-4-5-6-3-7-9-10, and with p-uses –1-2-3-7-8-10 and 1-2-3-4-5-6-3-7-9-10 All-c-uses criterion paths for ti: –1-2-3-4-5-6-3-7-8-10, –1-2-3-4-5-6-3-7-9-10, –1-2-3-4-6-3-7-8-10, –1-2-3-4-6-3-7-9-10 All-p-uses criterion paths for tv: –1-2-3-7-8-10 –1-2-3-7-9-10 –1-2-3-4-5-6-3-7-8-10 –1-2-3-4-5-6-3-7-9-10 All-p-uses/some-c-uses criterion paths for i: 1-2-3-4-5-6-3-7-9-10 All-c-uses/some-p-uses criterion paths for AS: 1-2-3-4-5-6-3-7-9-10 All-uses: Conjuction of all-c-uses and all-p-uses All-du-paths for tv: 1-2-3-4-5-6-3-7-8-10 …. 1-2-3-7-9-10


Download ppt "1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis."

Similar presentations


Ads by Google