0% found this document useful (0 votes)
65 views40 pages

CSCE 747 Software Testing and Quality Assurance

The document discusses dataflow testing, which focuses on the points where variables receive values (definitions) and where those values are used. It describes two main forms of dataflow testing: define-use testing and definition-clear path testing. Define-use testing involves identifying definition and use nodes for each variable and ensuring each variable definition has a corresponding use along each program path. Definition-clear paths ensure no other variable redefinitions occur between a variable's definition and use along a path. The document provides an example commission program and identifies its definition-use paths.

Uploaded by

Faraz Anjum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views40 pages

CSCE 747 Software Testing and Quality Assurance

The document discusses dataflow testing, which focuses on the points where variables receive values (definitions) and where those values are used. It describes two main forms of dataflow testing: define-use testing and definition-clear path testing. Define-use testing involves identifying definition and use nodes for each variable and ensuring each variable definition has a corresponding use along each program path. Definition-clear paths ensure no other variable redefinitions occur between a variable's definition and use along a path. The document provides an example commission program and identifies its definition-use paths.

Uploaded by

Faraz Anjum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

CSCE 747 Software Testing and

Quality Assurance
Lecture 07 – Dataflow Testing

Lec 07 Dataflow Testing - 1 9/1/2013 CSCE 747 Fall 2013


Last Time Today
 Lecture 06 Slides 1-19  Dataflow Testing
covered last time
 Case Study Question after
 Ch 10, pp 151-167
class
 Path Testing continued
 Ch 9 pp 131-149

Lec 07 Dataflow Testing - 2 Jorgensen, Paul C. Software Testing 2


A Craftsman Approach CSCE 747 Fall 2013
MSYSGIT

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 3 CSCE 747 Fall 2013
A Craftsman Approach
Dataflow Testing
 Dataflow testing refers to forms of structural
testing that focus on:
 the points at which variables receive values and
 the points at which these values are used
 Dataflow testing serves as a reality check on
path testing;

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 4 A Craftsman Approach CSCE 747 Fall 2013
Forms of dataflow testing
 Two main forms of dataflow testing:
 One provides a set of basic definitions and a
unifying structure of test coverage metrics
 The other based on a concept called a program
slice.
 Start with program graph but move back
towards functional testing

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 5 CSCE 747 Fall 2013
A Craftsman Approach
Define/Use of Variables
 Define/Use information
 x = y +3*z
 Define a new x; use variables y and z
 Concordances that list statement numbers in which
variable names occur

 Define/reference anomalies:
 A variable that is defined but never used
 A variable that is used before it is defined
 A variable that is defined twice before it is used
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 6 CSCE 747 Fall 2013
A Craftsman Approach
Static Analysis
 Static analysis: finding faults in source code
without executing it.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 7 CSCE 747 Fall 2013
A Craftsman Approach
Define/Use Testing
 define/use testing was done by
 Rapps and Weyuker, IEEE Transactions on
Software Engineering, Vol. SE-11, 1985
 Definitions: Given a program P
 G(P) – the program graph; single entry; single exit
 PATHS(P) – the set of all paths in P

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 8 CSCE 747 Fall 2013
A Craftsman Approach
“Definition” and “Usage” nodes for variable
 Definition: Node n ∈ G(P) is a defining node of the variable v ∈ V,
written as DEF(v, n)

 Definition: Node n ∈ G(P) is a usage node of the variable v ∈ V,


written as USE(v, n)
 Definitions(n) – variables v that are defined in statement n
 Usage(n) – variables that are used in statement n
 Definitions(v) – statements that define v
 Usage(v) – statements that use v
 Next-Use(n, v) – list of statements following n that use v

 Node n: statement fragment x = y + z


Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 9 CSCE 747 Fall 2013
A Craftsman Approach
Example (Commission)
10. totalLocks = 0
11. totalStocks = 0
12. totalBarrels = 0
13. Input(locks)
14.While NOT(locks = -1) ‘loop condition uses -1
15. Input(stocks, barrels)
16. totalLocks = totalLocks + locks
17. totalStocks = totalStocks + stocks
18. totalBarrels = totalBarrels + barrels
19. Input(locks)
20. EndWhile
21. Output(“Locks sold: “, totalLocks)

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 10 CSCE 747 Fall 2013
A Craftsman Approach
Predicate/Computation Use
 USE(v, n) can be ‘Step 2: Is A Triangle? Modified
classified as 6. t1 = b + c
 Predicate use (P-use) 7. t2 = a + c
 Computation use(C-use) 8. t3 = a + b
9. If (a < t1) AND (b < t2) AND(c < t3)
 USE(a, 7) ?
10. Then IsATriangle = True
 USE(a,9)?
11. Else IsATriangle = False
12. EndIf

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 11 CSCE 747 Fall 2013
A Craftsman Approach
definition-use path
 Definition: A definition-use path with respect to a
variable v (denoted du-path) is a path in PATHS(P)
such that
 for some v ∈ 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 of the path.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 12 CSCE 747 Fall 2013
A Craftsman Approach
Definition-Clear Path
 Definition: A definition-clear path with respect to a
variable v (denoted dc-path) is a definition-use path in
PATHS(P)
 with initial and final nodes DEF (v, m) and USE (v, n) such
that no other node in the path is a defining node of v
 Du-paths and dc-paths describe the flow of data across
source statements from points at which the values are
defined to points at which the values are used.
 Du-paths that are not definition-clear are potential
trouble spots.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 13 CSCE 747 Fall 2013
A Craftsman Approach
Compilers Again: Register Allocation

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 14 CSCE 747 Fall 2013
A Craftsman Approach
1. Program Commission (INPUT,OUTPUT) 23. Output(“Barrels sold: “, totalBarrels)
2. Dim … 24. lockSales = lockPrice * totalLocks
7. lockPrice = 45.0 25. stockSales = stockPrice * totalStocks
8. stockPrice = 30.0 26. barrelSales = barrelPrice * totalBarrels
9. barrelPrice = 25.0 27. sales = lockSales + stockSales + barrelSales
10. totalLocks = 0 28. Output(“Total sales: “, sales)
11. totalStocks = 0 29. If (sales > 1800.0)
30.
Then
12. totalBarrels = 0
31. commission = 0.10 * 1000.0
13. Input(locks)
32. commission = comm. + 0.15 * 800.0
14. While NOT(locks = -1)
33. comm. = comm. + .20 *(sales-1800.0)
15. Input(stocks, brrls) 34. Else If (sales > 1000.0)
16. totalLocks = totalLocks + locks 35. Then
17. totalStocks = totalStocks + stocks 36. commission = 0.10 * 1000.0
18. totalBarrels = totalBarrels + brrls 37. comm=comm + .15 *(sales-1000)
19. Input(locks) 38. Else
20.EndWhile 39. commission = 0.10 * sales
21. Output(“Locks sold: “, totalLocks) 40. EndIf
22. Output(“Stocks sold: “, totalStocks) 41. EndIf
42. Output(“Commission is $”, commission)
43. End Commission
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 15 CSCE 747 Fall 2013
A Craftsman Approach
DD-Paths in Figure 10.1
(previous slide)
 Table 10.1 DD-Paths in Figure 10.1
DD-Path Nodes
A 7, 8, 9, 10, 11, 12, 13
B 14
C 15, 16, 17, 18, 19,20
D 21, 22, 23, 24, 25, 26, 27, 28
E 29
F 30, 31, 32, 33
G 34
H 35, 36, 37
I 38, 39
J 40
K 41, 42, 43

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 16 CSCE 747 Fall 2013
A Craftsman Approach
Fig 10.1
program graph
for commission
program

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 17 CSCE 747 Fall 2013
A Craftsman Approach
Figure 10.2 DD-
Path graph of
the commission
program.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 18 CSCE 747 Fall 2013
A Craftsman Approach
10.1.2 du-Paths for Stocks
 Def(stocks, 15 )
 Use(stocks, 17 )

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 19 CSCE 747 Fall 2013
A Craftsman Approach
10.1.3 du-Paths for Locks
 p1 = <13, 14>
 p2 = <13, 14, 15, 16>
 p3 = <19, 20, 14>
 p4 = <19, 20, 14, 15, 16>

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 20 CSCE 747 Fall 2013
A Craftsman Approach
10.1.4 du-Paths for Total-Locks
 p6 = <10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
14, 21>
 p7 = <10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
14, 21, 22, 23, 24>
 p7 = < p6, 22, 23, 24>
 p8 = <16, 17, 18, 19, 20, 14, 21>
 p9 = <16, 17, 18, 19, 20, 14, 21, 22, 23, 24>

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 21 CSCE 747 Fall 2013
A Craftsman Approach
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 22 CSCE 747 Fall 2013
A Craftsman Approach
10.1.5 du-Paths for Sales
 p10 = <27, 28>
 p11 = <27, 28, 29>
 p12 = <27, 28, 29, 30, 31, 32, 33>

 p13 = <27, 28, 29, 34>


 p14 = <27, 28, 29, 34, 35, 36, 37>
 p15 = <27, 28, 29, 34, 38,39>

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 23 CSCE 747 Fall 2013
A Craftsman Approach
Du-Paths for
commission

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 24 CSCE 747 Fall 2013
A Craftsman Approach
Table 10.4 Define/Use Paths for Commission

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 25 CSCE 747 Fall 2013
A Craftsman Approach
10.1.7 du-Path Test Coverage Metrics
 Definition: The set T satisfies the All-Defs criterion for the
program P iff for every variable v ∈ V, T contains definition-
clear paths from every defining node of v to a use of v.
 Definition: The set T satisfies the All-Uses criterion for the
program P iff for every variable v ∈ V, T contains definition-
clear paths from every defining node of v to every use of v,
and to the successor node of each USE(v, n).
 Definition: The set T satisfies the All-P-Uses/Some C-Uses
criterion for the program P iff for every variable v ∈ V, T
contains definition-clear paths from every defining node of v
to every predicate use of v;
 if a definition of v has no P-uses, a definition-clear path leads
to at least one computation use.
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 26 CSCE 747 Fall 2013
A Craftsman Approach
Rapps–Weyuker hierarchy of dataflow
coverage metrics.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 27 CSCE 747 Fall 2013
A Craftsman Approach
 Definition: The set T satisfies the All-C-Uses/Some P-Uses
criterion for the program P iff for every variable v ∈ V, T
contains definition-clear paths from every defining node of v
to every computation use of v;
 if a definition of v has no C-uses, a definition-clear path leads
to at least one predicate use.
 Definition: The set T satisfies the All-du-paths criterion for
the program P iff for every variable v ∈ V, T contains
definition-clear 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 single-loop traversals or cycle-free.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 28 CSCE 747 Fall 2013
A Craftsman Approach
Slices
 Slices of History:
 American History
 Western Civ.
 Chinese History
 Russian History
 … history focusing on one group
 Slices of program
 “set of program statements that contributes to or
 affects a value for a variable at some point in the
program”
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 29 CSCE 747 Fall 2013
A Craftsman Approach
10.2 Slice-Based Testing
 Program slices have surfaced and submerged in software
engineering literature since the early 1980s.
 They were originally proposed in Weiser (1988), used as an
approach to software maintenance in Gallagher and Lyle
(1991), and more recently
 used to quantify functional cohesion in Bieman and Ott (1994)
 Part of this versatility is due to the natural, intuitively clear
intent of the program slice concept.
 Informally, a program slice is a set of program statements that
contributes to or affects a value for a variable at some point in
the program.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 30 CSCE 747 Fall 2013
A Craftsman Approach
slice on the variable set V
 Definition: Given a program P and a set V of
variables in P, a slice on the variable set V at
statement n, written S(V, n), is the set of all
statements in P prior to node n that
contribute to the values of variables in V at
node n.

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 31 CSCE 747 Fall 2013
A Craftsman Approach
Use nodes
 USE relationship pertains to five forms of usage:
 P-use Used in a predicate (decision)
 C-use Used in computation
 O-use Used for output
 L-use Used for location (pointers, subscripts)
 I-use Iteration (internal counters, loop indices)

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 32 CSCE 747 Fall 2013
A Craftsman Approach
Definition Nodes
 two forms of definition nodes:
 I-def Defined by input
 A-def Defined by assignment

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 33 CSCE 747 Fall 2013
A Craftsman Approach
 Slices on the locks
 S1: S(locks, 13) = {13}
 S2: S(locks, 14) = {13, 14, 19, 20}
 S3: S(locks, 16) = {13, 14, 19, 20}

 Jorgensen, Paul C. (2011-07-16). Software


Testing (Page 162). Auerbach Publications.
Kindle Edition.
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 34 CSCE 747 Fall 2013
A Craftsman Approach
Slices and Loops
 S9: S(totalLocks, 10) = {10}
 S10: S(totalLocks, 16) = {10, 13, 14, 16, 19, 20}
 S11: S(totalLocks, 21) = {10, 13, 14, 16, 19, 20}

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 35 CSCE 747 Fall 2013
A Craftsman Approach
 S12: S(totalStocks, 11) = {11}
 S13: S(totalStocks, 17) = {11, 13, 14, 15, 17, 19, 20}
 S14: S(totalStocks, 22) = {11, 13, 14, 15, 17, 19, 20}
 S15: S(totalBarrels, 12) = {12}
 S16: S(totalBarrels, 18) = {12, 13, 14, 15, 18, 19, 20}
 S17: S(totalBarrels, 23) = {12, 13, 14, 15, 18, 19, 20}

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 36 CSCE 747 Fall 2013
A Craftsman Approach
Lattice of Slices for Commission Problem
 S31: S(commission, 31) = {31}
 S32: S(commission, 32) = {31, 32}
 S33: S(commission, 33) = {7, 8, 9 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26, 27,
29, 30, 31, 32, 33}

 S34: S(commission, 36) = {36}

 S35: S(commission, 37) = {7, 8, 9 10, 11, 12,


13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26, 27,
36, 37}

 S36: S(commission, 39) = {7, 8, 9 10, 11, 12,


13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26, 27,
29, 34, 38, 39}

 S37: S(commission, 41) = {7, 8, 9 10, 11, 12,


13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26, 27,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39}

Jorgensen, Paul C. Software Testing


Lec 07 Dataflow Testing - 37 CSCE 747 Fall 2013
A Craftsman Approach
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 38 CSCE 747 Fall 2013
A Craftsman Approach
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 39 CSCE 747 Fall 2013
A Craftsman Approach
Jorgensen, Paul C. Software Testing
Lec 07 Dataflow Testing - 40 CSCE 747 Fall 2013
A Craftsman Approach

You might also like