0% found this document useful (0 votes)
79 views20 pages

STM-R16 - UNIT-3 (Ref-2) - 16-35

This document discusses various concepts related to software testing methodologies, specifically focusing on paths, path products, path expressions, path sums, and loops in flowgraphs. It outlines the definitions, rules, and procedures for path representation and reduction, as well as the arithmetic for calculating maximum path counts. Additionally, it provides examples and illustrations to clarify these concepts and their applications in debugging and path expression simplification.

Uploaded by

ramanareddy20009
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)
79 views20 pages

STM-R16 - UNIT-3 (Ref-2) - 16-35

This document discusses various concepts related to software testing methodologies, specifically focusing on paths, path products, path expressions, path sums, and loops in flowgraphs. It outlines the definitions, rules, and procedures for path representation and reduction, as well as the arithmetic for calculating maximum path counts. Additionally, it provides examples and illustrations to clarify these concepts and their applications in debugging and path expression simplification.

Uploaded by

ramanareddy20009
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

Software Testing Methodologies Unit III

PATHS, PATH PRODUCTS AND REGULAR EXPRESSIONS


(1) Path products & path expression:
(1) Explain Paths, Path products, Path expressions, path sums and loops?
(a) Paths:
 A sequence of statements which starts at an entry and ends at an exit and passes all the
decisions, junctions & processes is known as path.
 A path represents different links and we can give a simplest weight to a link is a name.
 Using link names, we can convert the graphical flowgraph into an equivalent algebraic
expression.
 The link name will be denoted by lower case italic letters.
 In traversing a path, we traverse link names that give the name of the path.
 If you traverse links a, b, c, d then the name for that path is abcd.
 This path name is also called a path product. The following are some examples of paths.
a c

e f
1 3 4 5 2

b d
The different paths are: eacf, eadf, ebcf, ebdf
m
j k l
f g h i

a b c d e
The different paths are: abcde, abgjfbcde, abcdimfbcde

b
1 a 3 c 2

The different paths are: ac, abc, abbc, abbbc, abbbbc


c
1 a 3 4 2
b d
The different paths are: abd, abcbd, abcbcbd, abcbcbcbd
(b) Path Products:
 The concatenation of names of two consecutive path segments is called a path product.
 For example if X and Y are defined as X = abcde and Y = fghij then
XY = abcdefghij YX = fghijabcde
aX = aabcde Xa = abcdea XaX = abcdeaabcde .
 Another example is if X = abc + def + ghi and Y = uvw + z then
XY = abcuvw + defuvw + ghiuvw + abcz + defz + ghiz
If X = abcde then X1 = abcde
X2 = (abcde)2 = abcdeabcde

 The path product is not commutative that is XY does not necessarily equal to YX.

Page 16

www.Jntufastupdates.com 16
Software Testing Methodologies Unit III
 The path product is associative that is (XY)Z = X(YZ).
(c) Path expression:
 Path expression is defined as an expression which represents set of all possible paths
between an entry and exit nodes. For example:
u
v
x w
f y g h k
d i
j
 The path expression to the above figure is: f (x + y + d) g (u + v + w + h + i + j) k
(d) Path sums:
 The path sum is the sum of all the parallel links between two nodes or sum of all parallel
paths between two nodes. Path sum is denoted by ‘+’.
 Ex (i)
a c

e f
1 3 4 5 2

b d
 In the above figure, links a & b are parallel, so these parallel paths are denoted by a + b.
 Similarly c and d are parallel & these parallel paths are denoted by c + d.
 The set of parallel paths between 1 and 2 nodes are eacf + eadf + ebcf + ebdf.
 Ex (ii)
u
v
x w
f y g h k
d i
j
 The first set of parallel path is denoted by X + Y + d and second by u + v + w + h + i + j.
 The set of all paths in this flowgraph is f (X + Y + d) g(u + v + w + h + i + j) k
 Path sum is commutative and associative. Commutative is X + Y = Y + X
Associative is (X+Y)+Z=X+(Y+Z)
(e) Loops:
 If a single link or path expression is traversed indefinite no of times leading to infinite no of
parallel paths then it is called a loop. For example the loop consists of a single link b, then
the set of all paths through that loop is b0 + b1 + b2 + ….bn
b0
b1
b2
b3
...
bn
 This infinite sum is denoted by b*. So b*= b 0 + b1 + b2 + ….bn.
 If the loop is taken at least once then it is denoted by b +.

Page 17

www.Jntufastupdates.com 17
Software Testing Methodologies Unit III
 Ex (i)
b
1 a 3 c 2
The path expression is: ab*c = a(b0)c + a(b1)c + a(b2)c + a(b3)c+…….
= ac + abc + a bbc + a bbbc + ……
Ex (ii)
c
1 a 3 4 2
b d
The path expression is: a(bc)*bd = a(bc)bd + a(bc)bd + a(bc)bd + …….
=abd + abcbd + abcbcbd + …
(2) Discuss all the rules in path representation of graphs?
Rule 1:
A(BC)=(AB)C=ABC
Rule 2:
X+Y=Y+X
Rule 3:
(X + Y) + Z = X + (Y + Z) = X + Y + Z
A(BC)=(AB)C=ABC
Rule 4:
 Distributive laws are A(B+C) = AB + AC
(B + C) D = BD + CD.
 For example:
a c
e f
1 3 4 5 2
b d

e(a+b)(c+d)f = e(ac+ad+bc+bd)f = eacf + eadf + ebcf + ebdf


Rule 5:
 The absorption rule is, if X and Y denote the same set paths, then the union of these sets is
not changed. Ex: X + X = X.
 Another example is: if X = a + aa + abc + abcd + def then
X + a = X + aa = X + abc = X + abcd = X + def = X
Rule 6:
Xn + Xm = Xn if n is bigger than m
= Xm if m is bigger than n
Rule 7:
XnXm = Xn+m
Rule 8:
XnX* = X*Xn = X*
Rule 9:
XnX+ = X+Xn = X+
Rule 10:
X*X+ = X+X* = X+
Identity elements:(Rule 11 to Rule 17)
 a0, X0 denote the path whose length is zero. The rules are
Rule 11:
1+1=1

Page 18

www.Jntufastupdates.com 18
Software Testing Methodologies Unit III
Rule 12:
1X = X1 = X
Rule 13:
1n = 1n = 1* = 1+ = 1
Rule 14:
1+ + 1 = 1* = 1
Rule 15:
X+0=0+X=X
Rule 16:
X0 = 0X = 0
Rule 17:
0* = 1 + 01 + 02 + . . . = 1
(2) A Reduction Procedure:
(1) Write the steps involved in Node Reduction Procedure. Illustrate all the steps with
the help of neat labeled diagrams?
Node Reduction Procedure:
 The main aim of Node Reduction Procedure is to remove all the intermediate nodes
between entry and exit nodes. This procedure is helpful in debugging process. i.e. Instead
of gathering information about path expression of all the intermediate nodes for debugging;
it is easy to debug only the path expression between entry and exit nodes.
Procedure:
1. Combine all serial links by multiplying their path expressions.
2. Combine all parallel links by adding their path expressions.
3. Remove all self loops by replacing them with a link of the form x*, where x is the path
expression of the link in that loop.
4. Choose the node which is to be removed other than initial and final node. The path
expression of the inlink and outlink of this node is multiplied and a direct link is applied with
the product of path expression. This step-4 is called Cross-Term Step.
5. Combine any remaining serial links by multiplying their path expressions.
6. Combine all parallel links by adding their path expressions. This Step-6 is called Parallel
Term Step.
7. Remove all self-loops as in step 3. This Step-7 is called Loop Term Step.
8. If the graph consists of a single link between the entry and the exit node, then the path
expression for that link is a required path expression. Otherwise return to step 4.
Example:
 Consider the following graph.
a b c d
1 3 4 5 2

e f g h

i j
6 7 8
 First remove node 8 by applying step 4 (cross-term step) and combine by step 5.
a b c d
1 3 4 5 2

e gj
f gh
6 i 7 8
Page 19

www.Jntufastupdates.com 19
Software Testing Methodologies Unit III
 Remove node 7 by applying step 4 (cross-term step) and combine by step 5.
a b c d
1 3 4 5 2

e
gjf gh
6 7 gji

 Remove node 6 by applying step 4 (cross-term step) and combine by step 5.


a b c d
1 3 4 5 2

gjf gh
6 gjie
 Add parallel links between node 5 and node 2 by applying parallel term step.
a b c d + gh
1 3 4 5 2

gjf
gjie
 Remove node 5 by applying step 4 (cross-term step) and combine by step 5.
cgjf
a b c(d + gh)
1 3 4 2
cgjie
 Remove self loop at node 4 by applying loop term step.
a b [cgjf]*c(d + gh)
1 3 4 2

[cgjf]*cgjie
 Remove node 4by applying step 4 (cross-term step) and combine by step 5.
b[cgjf]*cgjie

a b[cgjf]*c(d + gh)
1 3 2
 Remove self loop at node 3 by applying loop term step.
a [b[cgjf]*cgjie]*b[cgjf]*c(d + gh)
1 3 2
 Remove node 3 by applying step 4.
a([b[cgjf]*cgjie]*b[cgjf]*c(d + gh))
1 2
(3) Applications:
(1) How many paths in a Flowgraph:
Q. Explain maximum path count arithmetic of a flowgraph with an example?
Maximum Path Count Arithmetic:
 Here each link is represented by a link weight. There are three arithmetic cases that are
considered here.
 They are

Page 20

www.Jntufastupdates.com 20
Software Testing Methodologies Unit III
 (i) Parallel rule:
 Each term of the path expression A is added with each term of the path expression B if
there are two path expressions A and B. So it is A+B. If there are W A paths in A and W B
paths in B then there are W A + W B paths in its combination.
(ii) Series rule:
 Each term of the path expression A is multiplied with each term of the path expression B
if there are two path expressions A and B. So it is AB. If there are W A paths in A and W B
paths in B then there are W A W B paths in its combination.
(iii) Loop rule:
 Loop rule is evaluated by considering number of times that the path is iterated.
CASE PATH WEIGHT
EXPRESSION EXPRESSION
PARALLEL A+B WA + WB
SERIES AB W AW B
LOOP An n
∑ WA i
i=0
Example:
 Determine the path expression to the following figure.
m

k l j
b i
a d e f g h
c
 The path expression is given by
a(b +c) d [e(fi)*fgj(m + l)k]*e(fi)*fgh
 Let each link represents a single link and is given by a link weight 1.
 Assume that the outer loop will be taken exactly four times and the inner loop can be taken
zero to three times.
 The reduction is as follows.
1

1 1
1
1 1 {0-3} {4-4}

1 1 1 1 1 1
1
 Now apply parallel rule.
1+1=2

1 1
1 {0-3} {4-4}

1 1+1=2 1 1 1 1 1
 Now apply series rule.

Page 21

www.Jntufastupdates.com 21
Software Testing Methodologies Unit III
1x2x1=2

1 {0-3} {4-4}

1x2x1=2 1 1 1 1
 Now create inner self loop & Apply loop rule for removing inner self loop.
2 2
1(1)=1 {4-4} {4-4}
{0-3}
2 1 1x1=1 1 2 1 10+11+12+13=4 1 1

 Now apply series rule.


2
{4-4}
2 1x4x1=4 1

 Now create outer self loop.


2(4)=8
{4-4}
2 4x1=4
 Apply loop rule to remove the self loop.
2 84 4

 Apply series rule.


2 x 84 x 4 32768

 Alternatively we can calculate the maximum number of paths as follows.


 The path expression is given by
a(b +c) d [e(fi)*fgj(m + l)k]*e(fi)*fgh
 In the above expression each link is substituted by 1.
1(1+1)1[1(1x1)3 1x1x1 (1+1)1]4 1(1x1)3 1x1x1
=1(2)[13 x 2]4 1x13
=2[4x2]4 x 4 [since 13 = 10 +11 + 12 + 13 =4]
=2 x [8]4 x 4 = 32,768..
(2) Approximate Minimum number of paths:
Q. Define structured code. Explain about lower path count arithmetic?
Structured code:
 A structured flowgraph is one that can be reduced to a single link by successive application
of transformations.
 Based on the path expression obtained by node-by-node reduction procedure we can
determine whether the given flow graph is a structured or unstructured.
 That is if the resultant expression is large and ugly then the graph is unstructured one
otherwise the graph is structured one.
Lower path count arithmetic:
 The lowest number of paths in a structured flowgraph can be approximately known; it may
or may not be accurate because there is every possibility of a path being unachievable
which further lowers the number count.
 Here each link is represented by a link weight. Loops are always problematic.

Page 22

www.Jntufastupdates.com 22
Software Testing Methodologies Unit III
 So it must be traversed only one time or zero times to achieve the coverage. There are
three arithmetic cases here. They are.
 (i) Parallel rule:
 Each term of the path expression A is added with each term of the path expression B if
there are two path expressions A and B. So it is A+B. If there are W A paths in A and W B
paths in B then there are W A + W B paths in its combination.
(ii) Series rule:
 Each term of the path expression A is multiplied with each term of the path expression B
if there are two path expressions A and B. So it is AB.
 If there are W A paths in A and W B paths in B then there are MAX (W A, W B) paths in its
combination.
(iii) Loop rule:
 Loop rule is taken either by considering only one time that the path is iterated or zero
times the path is iterated. So it gives the value 1 or its link weight.
CASE PATH WEIGHT
EXPRESSION EXPRESSION
PARALLEL A+B WA + WB
SERIES AB MAX(W A,W B)
n
LOOP A 1,W 1
Example:
 Determine the path expression to the following figure.
m

l j
k
b i
a d e f g h
c
 The path expression is given by a(b +c) d [e(fi)*fgj(m + l)k]*e(fi)*fgh
 Let each link represents by a link weight 1. Assume that the outer loop will be taken exactly
four times and the inner loop can be taken zero to three times. The reduction is as follows.
1
1 1
1
1 1 {0-3} {4-4}

1 1 1 1 1 1
1
 Now apply parallel rule.
2
1 1
1 {0-3} {4-4}
1 2 1 1 1 1 1

 Now apply series rule.


2
{4-4}
1 {0-3}
2 1 1 1 1

Page 23

www.Jntufastupdates.com 23
Software Testing Methodologies Unit III

 Now create inner self loop & apply loop rule for removing inner self loop.
2 2
1(1)=1 {4-4} {4-4}
{0-3}
2 1 1 1 2 1 1 1 1
 Now apply series rule.
2 {4-4}
2 1 1

 Now create outer self loop.


2(1)=2
{4-4}
2 1
 Apply loop rule to remove self loop.
2 2 1

 Apply series rule.


2
 Alternatively we can calculate the minimum number of paths as follows.
 The path expression is given bya(b +c) d [e(fi)*fgj(m + l)k]*e(fi)*fgh
 In the above expression each link is substituted by 1.
1(1+1)1[1(1x1)0 1x1x1 (1+1)1]0 1(1x1)0 1x1x1
=1(2)[10 x 2]0 1x10 =2x1 = 2
(3) The probability of getting there:
Q. What is the probability of path expressions? Write arithmetic rules. Explain with an
example.
Probability of path expressions:
 Specify each out link of a node equal to the probability of that link. The sum of the out link
probabilities is equal to 1. For a simple loop, if the loop is taken N times then the looping
probability is N/(N+1) and non looping probability is 1/(N+1).
 There are three arithmetic cases here. They are
Parallel rule:
 Each term of the path expression A is added with each term of the path expression B if
there are two path expressions A and B. So it is A+B.
 If there is a path expression A with Probability PA and path expression B with Probability
PB then the resultant probability is PA + PB.
Series rule:
 Each term of the path expression A is multiplied with each term of the path expression B
if there are two path expressions A and B. So it is AB. If there is a path expression A
with Probability PA and path expression B with Probability PB then the resultant
probability is PA PB
Loop rule:
 If the probability of looping node is PL and the probability of link leaving the loop node is
PA then PA + PL=1. So PA = 1- PL

Page 24

www.Jntufastupdates.com 24
Software Testing Methodologies Unit III

CASE PATH WEIGHT


EXPRESSION EXPRESSION
PARALLEL A+B PA + PB
SERIES AB PAPB
n
LOOP A PA/(1-PL)
Example (i)
PL
PA
PA = 1 - PL
New Probability PNEW = PA / (1-PL) = (1-PL) / (1-PL) = 1

Example (ii)
PA
PL 1- PL
PB
PA
1- PL
PB
PC PC
1- PL
Here PL + PA + PB + PC =1
1 - PL = PA + PB + PC
PA / (1 - PL) + PB / (1 - PL) + PC / (1 - PL) = (PA + PB + PC) / (1 - PL)
= (PA + PB + PC) / (PA + PB + PC) = 1
Example:
 Consider the following flowgraph.
.8
.2
A
.01 .99
.1 .2
.3 .2
B
.05 .5
.6
.85 .4
.9 .8
.1

C
 Calculate the probabilities of cases A, B, C.

Page 25

www.Jntufastupdates.com 25
Software Testing Methodologies Unit III

First consider case A:


.8
.2
A
.01 .99
.1 .2
.3
.05
 In the above flowgraph if the link weight is not specified then it is specified by 1 and also
represents its nodes as follows.
.8
4 1 5 1 6 1 7 .2 2 A
.01
.1 .2 .99
9

1 3 8 .3
1 .05
 The above flowgraph is also taken by
.8

1 1 1 .2
1 1 3 .1 4 5 6 7 2 A

.2 .01
.05
.99
.3
8 9
 Remove self loop by applying loop rule
.8

1 1 1 .2
1 1 3 .1 4 5 6 7 2 A

.05 .2
1
.3
8 9
 Remove node 9 by applying series rule
.8

1 1 1 .2
1 1 3 .1 4 5 6 7 2 A

.05 .2
.3
8
 Remove node 8 by applying series rule
.8

1 .1 1 1 1 .2
1 3 4 5 6 7 2 A
.01
.015
 Remove node 5 by applying series rule

Page 26

www.Jntufastupdates.com 26
Software Testing Methodologies Unit III
.8

1 .1 1 1 .2
1 3 4 6 7 2 A
.01

.015
 Add parallel links between node 3 and node 6 by applying parallel rule
.8
1 .1 1 1 .2
1 3 4 6 7 2 A
.025
 Remove node 7 by applying series rule
.8
1 .1 1 .2
1 3 4 6 2 A
.025
 Remove node 4 by applying series rule
.8
1 .1 .2
1 3 6 2 A
.025
 Add parallel links between node 3 and node 6 by applying parallel rule
.8
1 .125 .2
1 3 6 2 A
 Remove self loop at node 6 by applying loop rule
1 .125 .1
1 3 6 2 A
 Remove node 3 and node 6 by applying loop rule
.125
1 2 A
Consider case B:
.05 .5 .2
B
.6
.85 .4
.9
 In the above flowgraph if the link weight is not specified then it is specified by 1 and also
represents its nodes as follows.
1 .05 .5 1 1 .2
1 3 4 5 6 7 2 B

.85 .6 .4
.9
8 9
 Remove node 9 by applying series rule.
1 .05 .5 1 1 .2
1 3 4 5 6 7 2 B

.85 .54 .36


8
 Remove node 8 by applying series rule.
Page 27

www.Jntufastupdates.com 27
Software Testing Methodologies Unit III
1 .05 .5 1 1 .2
1 3 4 5 6 7 2 B

.459 .306

 Remove node 4 and node 7 by applying series rule.


1 .025 1 .2
1 3 5 6 2 B

.459 .306

 Add parallel links between node 3 and node 5 by applying parallel rule
1 .484 1 .2
1 3 5 6 2 B

.306
 Remove node 5 by applying series rule.
1 .484 .2
1 3 6 2 B
.306
 Add parallel links between node 3 and node 5 by applying parallel rule
1 .79 .2
1 3 6 2 B
 Remove node 5 by applying series rule.
.158
1 2 B
Consider case C.
.05 .5
.6
.85 .4
.9 .8

.1
C
 In the above flowgraph if the link weight is not specified then it is specified by 1 and also
represents its nodes as follows.
1 .05 .5 1 1
1 3 4 5 6 7
.6 .4
.85
.9 .8
8 9

.1
1
10 2 C
 Remove node 9 by applying series rule.
1 .05 .5 1 1
1 3 4 5 6 7

.85 .54 .36


8 .8

.1
1
10 2 C
 Remove node 10 by applying series rule.

Page 28

www.Jntufastupdates.com 28
Software Testing Methodologies Unit III
1 .05 .5 1 1
1 3 4 5 6 7

.85 .54 .36


8 .8

.1
2 C
 Remove node 8 by applying series rule.
1 .05 .5 1 1 .8
1 3 4 5 6 7 2 C
.459
.306
.085

 Remove node 7 & node 4 by applying series rule.


1 .025 1 .8
1 3 5 6 2 C
.459
.306
.085

 Add parallel links between node 3 and node 5 by applying parallel rule
1 .484 1 .8
1 3 5 6 2 C

.306 .085

 Remove node 5 by applying series rule


1 .484 .8
1 3 6 2 C

.306
.085

 Add parallel links between node 3 and node 6 by applying parallel rule
1 .79 .8
1 3 6 2 C

.085
 Remove node 6 by applying series rule
1 .632
1 3 2 C

.085
 Add parallel links between node 3 and node 2 by applying parallel rule
1 .717
1 3 2 C
 Remove node 3 by applying series rule
.717
1 2 C
Cross check:
 Sum of case A + case B + case C = .125 + .158 + .717 =1.
(4) The mean processing time of a routine
Q. What is the mean processing time of a routine? Write arithmetic rules. Explain with
an example.
Mean processing time of a routine:
 Here every link has two weights.

Page 29

www.Jntufastupdates.com 29
Software Testing Methodologies Unit III
 One is the processing time for that link denoted by T, & other one is the probability of that
link denoted by P.
 There are three arithmetic cases here.
 They are
Parallel rule:
 It is the arithmetic mean of all processing time over all parallel links.
Series rule:
 It is the sum of two processing times.
Loop rule:
 It is evaluated by considering number of times the path is iterated
CASE PATH WEIGHT EXPRESSION
EXPRESSION
PARALLEL A+B TA+B = (PATA+PBTB)/(PA+PB)
PA+B = PA + PB
SERIES AB TAB =TA + TB
PAB = PA PB
TA = (TL PL)/(1-PL) + TA
LOOP A* PA = PA/(1-PL)
Example:
 The following figure is represented by, loop probabilities, and processing time for each link.
The probabilities are given in parentheses.
20 (.95)

300
14 (.05) 15
(.3) 25 12 (.3)
16 10 (.6)
10 8 5 7
(.4) (.7)
(.7) 40
 Apply parallel rule.
34
14 15
12 (.3)
10 (.6)
10 35.5 16 8 5 7
(.4) (.7)
 .Apply series rule.
63

12 (.3)
10 (.6)
61.5 8 5 7
(.4) (.7)
 Now create inner self loop.
63

20
(.6) (.3)
61.5 10 13 7
(.4) (.7)
 Remove the inner self loop by applying loop rule.

Page 30

www.Jntufastupdates.com 30
Software Testing Methodologies Unit III
63
(.3)
61.5 10 30 13 7
(.7)
 Apply series rule.
63
(.3)
61.5 53 7
(.7)
 Create the outer self loop.
116
(.3)
61.5 60
(.7)
 Remove the outer self loop by applying loop rule.
61.5 49.714 60
 Apply series rule
171.214
 .
(5) Push/Pop, Get/Return
Q. What is Push/Pop, Get/Return? Write arithmetic rules. Explain with an example.
Push/Pop:
 Here PUSH operation is used to insert elements into the stack. POP operation is used to
remove elements from the stack.
 Apart from PUSH/POP other operations are GET/RETURN, OPEN/CLOSE and
START/STOP.
 There are three arithmetic cases here.
 They are
Parallel rule:
 Each term of the path expression A is added with each term of the path expression B if
there are two path expressions A and B. So it is A+B. If there are W A paths in A and W B
paths in B then there are W A + W B paths in its combination.
Series rule:
 Each term of the path expression A is multiplied with each term of the path expression B
if there are two path expressions A and B. So it is AB. If there are W A paths in A and W B
paths in B then there are W A W B paths in its combination.
Loop rule:
 It is evaluated by considering number of times the path is iterated.
CASE PATH WEIGHT
EXPRESSION EXPRESSION
PARALLEL A+B WA + WB
SERIES AB WA WB
LOOP A* W *A
 PUSH/POP operations satisfy commutative, associative, and distributive law of addition
and multiplication.
 The arithmetic tables for PUSH/POP are given by

Page 31

www.Jntufastupdates.com 31
Software Testing Methodologies Unit III
PUSH/POP MULTIPLICATION TABLE PUSH/POP ADDITION TABLE

X H P 1 + H P 1

2
H H 1 H H H P+H H+1

P 1 P2 P P P+H P P+1

1 H P 1 1 H+1 P+1 1

 These tables are used to determine the weight of addition and multiplication operation.
 Here H represents the PUSH operation, P represents the POP operation and 1 represents
NO operation.
Example:
 Consider the following flowgraph.
P

H
1 1
P H (n2)
P (n1)
P 1 H P H
1
 Path expression for the above flowgraph is.
P(P+1)1[P(HH)n1 HP1(P+H)1]n2 P(HH)n1HPH
 Simplifying by using the arithmetic tables
PUSH/POP = (P2 + P)[P(HH)n1(P+H)]n2(HH)n1
= (P2+P)[H2n1(P2+1)]n2H2n1
 Let us consider M1,M2 represents the two looping terms. i.e. M1 represents the number of
times the inner loop is considered, M2 represents the number of times the outer loop is
considered.
CASE (i)
Consider M1=0, M2 =0 (i.e. n1=0, n2=0)
PUSH/POP= (P+P2)[H0(P2+1)]0H0 = P + P2
CASE (ii)
Consider M1=0, M2 =1 (i.e. n1=0, n2=1)
PUSH/POP= (P+P2)[H0(P2+1)]1H0
= (P + P2)[1+P2] = P + P2 + P3 + P4
 For different combination of M1, M2 values the following table is obtained.

M1 0 0 0 0 1 1 1 1 2 2 2 2
M2 0 1 2 3 0 1 2 3 0 1 2 3
PUSH P + P2 P + P2 + 6 8 3 5 7 7 11 16
/POP P +P3 4
∑P i
∑P i
1+H ∑H i
∑H i
∑H i 2
H +H 3
∑H i
∑H i
∑ Hi
1 1 0 0 0 4 6 8
Get/Return:
 The arithmetic tables for GET/RETURN are.

Page 32

www.Jntufastupdates.com 32
Software Testing Methodologies Unit III
GET/RETURN MULTIPLICATION TABLE GET/RETURN ADDITION TABLE

X G R 1 + G R 1

G G2 1 G G G G+R G+1

R 1 R2 R R G+R R R+1

1 G R 1 1 G+1 R+1 1

 The arithmetic table for GET/RETURN is same as that of PUSH/POP.


Example:
 Consider the following flowgraph.
R
G R
G G G G R
R

 Path expression for the above flowgraph is. G(G+R) G(GR)* GGR* R
 Simplifying by using the arithmetic tables
GET/RETURN = G(G+R)G3 R*R
= (G+R) G3 R* = (G4 + G3R) R* = (G4 + G2GR)R* = (G4 + G2)R*
(6) Limitations and Solutions
Q. What are the limitations and solutions of the applications?
 The main limitation to these applications is the problem of unachievable paths.
 The node-by-node reduction procedure and most graph-theory based algorithms work well
when all paths are achievable, but may provide misleading results when some paths are
unachievable.
 The solution to handling unachievable paths is to partition the graph into subgraphs so that
all paths in each of the subgraphs are achievable. But the resulting sub graphs may
overlap, because one path may be common to several different subgraphs.
 Each predicate’s truth value splits the graph into two subgraphs.
 For n predicates there may be 2n sub graphs. Here there is an algorithm for one predicate.
1. Set the value of the predicate to TRUE and strike out all FALSE links for that predicate.
2. Discard any node, other than an entry or exit node, that has no incoming links. Discard
all links that leave such nodes. If there is no exit node, the routine has a bug because there
is a predicate value that forces an endless loop or the equivalent.
3. Repeat step 2 until there are no more links or nodes to discard. The resulting graph is
the subgraph corresponding to a TRUE predicate value.
4. Change “TRUE” to “FALSE” in the above steps and repeat. The resulting graph is the
subgraph that corresponds to a FALSE predicate value.
 Only correlated predicates should be included in this analysis not all predicates that may
control the program flow.
(4) Regular expressions and flow anomaly detection:
Q. Explain about Regular expression and Flow-Anomaly detection?
(i) The Problem:
 The generic flow-anomaly detection problem is used to search for a specific sequence of
operations considering all possible paths through a routine.
 Let’s say the operations are SET and RESET, denoted by s and r respectively, and we
want to know if there is a SET followed immediately by a SET or a RESET followed
immediately by a RESET (i.e, an ss or an rr sequence).

Page 33

www.Jntufastupdates.com 33
Software Testing Methodologies Unit III
 Flow anomaly detection is used to know if particular sequence occurred, but not to know
the total impact of the procedure.
 It is used to detect the bug sequence in the following situations.
1. A file can be opened (o), closed (c), read (r), or written (w). If the file is read or written to
after it is closed, then it is anomalous. i.e. cr and cw are anomalous. Similarly, if the file is
read before it’s been written, just after opening, we may have a bug. Therefore, or is also
anomalous.
2. The operations performed by tape transport device are read(r), write(w), rewind (d),
forward (f), skip (k) and stop (p). In a tape-transport device rewind and forward operations
cannot be performed one after the other without performing stop operation. So the following
sequences are anomalous: df, dr, dw, fd, and fr.
3. With the help of generic flow anomaly detection, it is possible to detect the data flow
bugs sequence such as dd, dk, kk, and ku.
4. A bug that occur only if two operations a and b occurred in the order aba or bab.
(ii) Huang Theorem:
 Annotate each link in the graph with the appropriate operator or the null operator 1.
 Simplify things using a + a = a and 12 = 1.
 The regular expression obtained should be simplified carefully, as null operations cannot be
combined with other operations.
 For example, 1a may not be the same thing as a alone. Huang theorem is used to simplify
the regular expression and to examine the specific operation sequence.
 Let A, B, C, be nonempty sets of character sequences whose smallest string is at least
one character long. Let T be a two-character string of characters.
 Then if T is a substring of ABnC, then T will appear in AB2C.
 As an example, let A = pp B = srr C = rp T = ss
 The theorem states that if ss is a substring of pp(srr)nrp then ss will appear in pp(srr)2rp.
 Similarly let A = p + pp + ps B = psr + ps(r + ps) C = rp T = P4
 If p4 is a substring of ABnC then p4 will appear in AB2C (p + pp + ps)[psr + ps(r + ps)]2rp
 Huang theorem is also useful in test design.
 Further Huang shows that if you substitute 1 + X2 for every expression of the form X*, the
paths that result from this substitution are sufficient to determine whether a given two-
character sequence exists or not.
 Two character string sequences are used to represent data flow anomaly. Then using
Huang’s theorem these anomalous can be detected if these loop is iterated twice.
Data Flow Testing Example:
 By assigning appropriate operators on each link the following flowgraph can be used to
detect different anomalies bugs.
r dr d
d 1 r u r ru
 Huang’s theorem states that the following expression is sufficient to detect any two
character sequence. d(r + 1)r[1 + (udr)2]ur(1 + d2)ru
 This makes the dd bug obvious. A kk bug cannot occur and also a dk bug cannot occur.
(drr + dr)(1 + udrudr)(urru + urd2ru)
 A better way to the above is subscript the operator with the link name.
rb dfrf
dh
da rd ue rg riui
1c
 The regular expression is da(rb + 1c)rd(uedfrf)*uergdh*riui
Page 34

www.Jntufastupdates.com 34
Software Testing Methodologies Unit III
 Applying Huang’s theorem:
da(rb + 1c)rd(1 + (uedfrf)2)uerg(1 + d2h)riui
(darbrd + dacrd)(uerg + uedfrfuedfrfuerg)(riuid2hriui)
(iii) Generalizations, Limitations and comments:
 Huang’s theorem can be easily generalized to cover sequences of greater length than two
characters. If A, B, and C are nonempty sets of strings of one or more characters, and if T
is a string of k characters, and if T is a substring of ABnC, where n is greater than or equal
to k, then T is a substring of ABkC.
 A sufficient test for strings of length k can be obtained by substituting Pk for every
appearance of P*
Pk = 1 + P + P2 + P3 + . . . + Pk
 In order to find the starting and ending sequence of strings in a path expression, the
mathematical approaches such as application of derivations to algebraic expression makes
it easier and time consuming than the path tracing process on a flowgraph.
 Static flow analysis methods can’t determine whether a path is achievable or is not
achievable.
 If unachievable paths exist, then the exactness and applicability of all flow analysis
methods reduces gradually. Hence achievable paths are preferred in order to overcome the
problems of unachievable paths.

Page 35

www.Jntufastupdates.com 35

You might also like