0% found this document useful (0 votes)
36 views

Data Flow Testing

The document defines data flow testing and describes how to construct program slices based on variables. It provides examples of defining and using nodes, definition-use paths, and slices for a sample commission calculation program.

Uploaded by

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

Data Flow Testing

The document defines data flow testing and describes how to construct program slices based on variables. It provides examples of defining and using nodes, definition-use paths, and slices for a sample commission calculation program.

Uploaded by

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

Data Flow Testing

• A program P that has a program graph G(P) and a set of program


variables V. The program graph G(P) is constructed, with statement
fragments as nodes and edges that represent node sequences. G(P) has
a single-entry node and a single-exit node.

• Definition
• Node n ∈ G(P) is a defining node of the variable v ∈ V, written as
DEF(v, n), if and only if the value of variable v is defined as the
statement fragment corresponding to node n.
• Input statements, assignment statements, loop control statements, and
procedure calls are all examples of statements that are defining nodes.
Definition
• Node n ∈ G(P) is a usage node of the variable v ∈ V, written as
USE(v, n), if and only if the value of the variable v is used as the
statement fragment corresponding to node n.
• Output statements, assignment statements, conditional statements,
loop control statements, and procedure calls are all examples of
statements that are usage nodes.
Definition
• A usage node USE(v, n) is a predicate use (denoted as P-use) if and
only if the statement n is a predicate statement; otherwise, USE(v, n) is
a computation use (denoted C-use).
• The nodes corresponding to predicate uses always have an outdegree ≥
2, and nodes corresponding to computation uses always have an
outdegree ≤ 1.
• 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.

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.
Examples: Commission Problem
• du_paths for stock:DEF(Stocks,15) and USE(stock,17)
path<15,17>

• du-paths for Locks:DEF(locks,13),DEF(locks,19),USE(locks,14) &


USE(locks,16)
p1=<13,14>, p2=<13,14,15,16>,p3=<19,20,14>,p4=<19,20,14,5,16>

• du-paths for totalLocks:DEF(totalLocks,10),DEF(totalLocks 16),


USE(totalLock,16), USE(totalLock,21) and USE(totalLocks,24)
P5=<10,11,12,13,14,15,16,17,18,19,20,14,21>, p7=<p6,22,23 24>
P8=<16,17,18,19,20,14,21>,p9=<16,17,18,19,20,14,21,22,23,24>
• du-paths for sales:Only one defining node(27) is used 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,39>

• du-paths for Commission:DEF( commission,33),DEF(commission,37)


• and DEF(commission,42).only one usage is used:USE(commission, 42).
Agenda
 Slice-Based Testing Definitions
 Slice-Based Testing Examples

A program slice is a set of program statements that


contributes to or effects a value for a variable at some
point in the program.

27
Slice-Based Testing Definitions
 Given a program P, and a set V of variables in P, the slice on the variable set V at statement
fragment n, written S(V,n), is of all statement fragments in P prior to node n that contribute to
the values of variables in V at node n.
 Listing element of a slice S(V,n) will be cumbersome bcz the elements are program statement.

 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 “prior to” in the dynamic sense,so a slice captures the

28
Slice-Based Testing Definitions
• The “contribute” part is more complex. In a sense, data declaration statements have an
effect onthe value of a variable.The notion of contribution is partially clarified by
predicate(P-use) and computation(C-usage) .
 Five forms of usage nodes
 P-use (used in a predicate (decision))
 C-use (used in computation)
 O-use (used for output, e.g. writeln())
 L-use (used for location, e.g. pointers)
 I-use (iteration, e.g. internal counters)
 Two forms of definition nodes
 I-def (defined by input, e.g. readln())
 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
29
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 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

 O-use, L-use, and I-use nodes are excluded from slices

 Consider making slices compilable

30
Example
• Slice on the locks:P-use at node 14,C-use at node 16, the I-
dedefs at node 13 &19
S1:S(locks,13)={13},
s2:S(locks,14)={13,14,19,20},
S3:S(locks,16)={13,14,19,20}, S4:S(locks 19)={19}

• Slice for stocks and barrels


S5:S(stock,15)={13,14,15,19,20}
S6:S(stock,17)={13,14,15,19,20}
S7:S(barrels,15)={13,14,15,19,20}
S8:S(barrels,18)={13,14 ,15,19,20}
• Slice on totalLocks and totalStocks
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}
S12:S(totalStocks,11)={11}
S13:S(totalLocks,17)={11,13,14,15,17,19,20}
S14:S(totalStock,22)={11,13,14,15,17,19,20}

• Slice on total barrels


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}
• S18:S(lockPrice,24)={7}
S19:S(stockPrice,25)={8}
S20:S(barrelprice,26)={9}
S21:S(lockPrice,24)={7,10,13,14,16,19,20,24}
S22;S(stockSales,25)={8,11,13,14,15,17,19,20,25}
S23:S(barrelSales,26)={9,12,13,14,15,18,19,20,26}

• Slice on sales

S24:S(sales,27)={7,8,9,10,11,12,13,14,15,16,17,18,19,20,24,25,26,27}
The above slice is same for node 28,29,33 34,37 and 39.
Slice on commission

S13: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,39,31,32,33,34,35 36,37,38,39}
Thank You

You might also like