STM Unit-3
STM Unit-3
UNIT –III
DOMAIN TESTING
(1) Domains and paths:
(i) The Model:
Domain testing can be based on specifications and/or equivalent implementation
information.
If domain testing is based on specifications, it is a functional test technique; if based on
implementations, it is a structural technique.
Domain testing is applied to one input variable or to simple combinations of two variables,
based on specifications.
The schematic representation of Domain testing is given below.
DO CASE 2
DO CASE 3
DO CASE n
MIN MAX
D1 D2 D3
If the domain boundary point belongs to the same domain then the boundary is said to
close. If the domain boundary point belongs to some other domain then the boundary is
said to open.
In the above figure there are three domains D1, D2, D3.
In figure a D2’s boundaries are closed both at the minimum and maximum values. If D2 is
closed, then the adjacent domains D1 and D3 must be open.
In figure b D2 is closed on the minimum side and open on the maximum side, meaning
that D1 is open and D3 is closed. In figure c D2 is open on both sides, which mean that the
adjacent domains D1 and D3 must be closed.
(v) Domain Dimensionality:
Depending on the input variables, the domains can be classified as number line domains,
planer domains or solid domains.
That is for one input variable the value of the domain is on the number line, for two
variables the resultant is planer and for three variables the domain is solid.
One important thing here is to note that we need not worry about the domains
dimensionality with the number of predicates. Because there might be one or more
boundary predicates.
(vi) The Bug Assumptions:
The bug assumption for domain testing is that processing is okay but the domain definition
is wrong.
An incorrectly implemented domain means that boundaries are wrong, which mean that
control-flow predicates are wrong.
The following are some of the bugs that give to domain errors.
(a) Double-Zero Representation:
Boundary errors for negative zero occur frequently in computers or programming
languages where positive and negative zeros are treated differently.
Page 2
Software Testing Methodologies Unit III
(b) Floating-Point Zero Check:
A floating-point number can equal to zero only if the previous definition of that number is
set it to zero or if it is subtracted from itself, multiplied by zero.
Floating-point zero checks should always be done about a small interval.
(c) Contradictory Domains:
Here at least two assumed distinct domains overlap.
(d) Ambiguous Domains:
These are missing domain, incomplete domain.
(e) Over specified Domains:
The domain can be overloaded with so many conditions.
(f) Boundary Errors:
This error occurs when the boundary is shifted or when the boundary is tilted or missed.
(g) Closure Reversal
This bug occurs when we have selected the wrong predicate such as x>=0 is written as
x<=0.
(h) Faulty Logic:
This bug occurs when there are incorrect manipulations, calculations or simplifications
in a domain.
(vii) Restrictions:
(a) General
Domain testing has restrictions. i.e. we cannot use domain testing if they are violated.
In testing there is no invalid test, only unproductive test.
(b) Coincidental Correctness
Coincidental correctness is assumed not to occur.
Domain testing is not good for which outcome is correct for the wrong reason.
One important point to be noted here is that, domain testing does not support Boolean
outcomes (TRUE/FALSE).
If suppose the outputs are some discrete values, then there are some chances of
coincidental correctness.
(c) Representative Outcome
Domain testing is an example of partition testing.
Partition testing divide the program’s input space into domains.
If the selected input is shown to be correct by a test, then processing is correct, and
inputs within that domain are expected to be correct.
Most test techniques, functional or structural fall under partition testing and therefore
make this representative outcome assumption.
(d) Simple Domain Boundaries and Compound Predicates
Each boundary is defined by a simple predicate rather than by a compound predicate.
Compound predicates in which each part of the predicate specifies a different boundary
are not a problem: for example, x >= 0 .AND. x < 17, just specifies two domain
boundaries by one compound predicate.
(e) Functional Homogeneity of Bugs
Whatever the bug is, it will not change the functional form of the boundary predicate.
(f) Linear Vector Space
A linear predicate is defined by a linear inequality using only the simple relational
operators >, >=, =, <=, <>, and <.
Example x2 + y2 > a2.
(g) Loop-free Software
Loops (indefinite loops) are problematic for domain testing.
Page 3
Software Testing Methodologies Unit III
If a loop is an overall control loop on transactions, say, there’s no problem.
If the loop is definite, then domain testing may be useful for the processing within the
loop, and loop testing can be applied to the looping values.
(2) Nice Domains:
(i) Where Do Domains Come From?
Domains are often created by salesmen or politicians.
The first step in applying domain testing is to get consistent and complete domain
specifications.
(ii) Specified versus Implemented Domains:
Implemented domains can’t be incomplete or inconsistent but specified domains can be
incomplete or inconsistent.
Incomplete means that there are input vectors for which no path is specified and
inconsistent means that there are at least two contradictory specifications.
(iii) Nice Domains:
(1) General
The representation of Nice two-dimensional domains is as follows. .
U1 U2 U3 U4 U5
A
B B
C
C
D
E
The Boundaries A and E have gaps so they are incomplete & the boundaries B, C, D
are complete.
The main advantage of a complete boundary is that it requires only one set of tests to
verify the boundary
(4) Systematic Boundaries
Systematic boundaries refer to boundary inequalities with simple mathematical
functions such as a constant.
Consider the following relations,
f1(X) >= k1 or f1(X) >= g(1,c)
f2(X) >= k2 f2(X) >= g(2,c)
................ ................
fi(X) >= ki fi(X) >= g(i,c)
Where fi is an arbitrary linear function, X is the input vector, ki and c are constants,
and g(i,c) is a decent function that yields a constant, such as k + ic.
(5) Orthogonal Boundaries
The U and V boundary sets in Nice two-dimensional domains figure are orthogonal; that
is, the every boundary V is perpendicular to every other boundary U.
If two boundary sets are orthogonal, then they can be tested independently.
If we want to tilt the above orthogonal boundary we can do it by testing its intersection
points but this can change the linear growth, O(n) into the quadratic growth O(n 2).
If we tilt the boundaries to get the following figure then we must test the intersections.
y = k2 + bx
y = k3 + bx
x = A1 x = A2 x = A3 x = A4 x = A5
In the above figure, the shading lines show one boundary and thick lines show other
boundary.
It shows Non orthogonal domain boundaries, which mean that every inequality in
domain x is not perpendicular to every inequality in domain y.
(7) Convex
A figure is said to be convex when for any two boundaries, with two points placed on
them are combined by using a single line then all the points on that line are within the
range of the same figure.
Nice domains support convex property, where as dirty domains don’t.
(8) Simply Connected
Nice domains are usually simply connected because they are available at one place as
a whole but not dispersed in other domains..
Simple connectivity is a weaker requirement than convexity; if a domain is convex it is
simply connected, but not vice versa.
(iv) Ugly Domains:
(a) General
Some domains are born ugly. Some domains are bad specifications.
So every simplification of ugly domains by programmers can be either good or bad.
If the ugliness results from bad specifications and the programmer’s simplification is
harmless, then the programmer has made ugly good.
But if the domain’s complexity is essential such simplifications gives bugs.
(b) Nonlinear Boundaries
Non linear boundaries are rare in ordinary programming, because there is no
information on how programmers correct such boundaries.
So if a domain boundary is non linear, then programmers make it linear.
(c) Ambiguities and Contradictions:.
(a) Ambiguities
Hole B
(d) Contradiction:
Dual Closure (b) Ambiguity:
Missing Boundary
Page 6
Software Testing Methodologies Unit III
Domain ambiguity is missing or incomplete domain boundary.
In the above figure Domain ambiguities are holes in the A domain and missing
boundary in the B domain.
An ambiguity for one variable can be see easy.
An ambiguity for two variables can be difficult to spot.
An ambiguity for three or more variables impossible to spot. Hence tools are required.
Overlapping domains and overlapping domain closure is called contradiction.
There are two types of contradictions are possible here.
(1) Overlapped domain specifications
(2) Overlapped closure specifications.
In the above figure there is overlapped domain and there is dual closure contradiction.
This is actually a special kind of overlap.
(d) Simplifying the Topology
Connecting disconnected boundary segments and extending boundaries is called
simplifying the topology
There are three generic cases of simplifying the topology.
BOUNDARY POINT
INTERIOR POINT
EPSILON NEIGHBORHOOD
An interior point is a point in a domain. It can be defined as a point which specifies
certain distance covered by some other points in the same domain.
This distance is known as epsilon neighborhood.
A boundary point is on the boundary that is a point with in a specific epsilon
neighborhood.
An extreme point is a point that does not lie between any other two points.
ON POINTS
OFF POINTS
EXTRA BOUNDARY
SHIFTED BOUNDARIES
CORRECT
INCORRECT
OPEN / CLOSE ERROR
b) Closure bug
X
B A
X
B
e) Missing Boundary
X X
B A C
f) Extra Boundary
Page 9
Software Testing Methodologies Unit III
In the above figure a) we assume that the boundary was to open for A.
In figure b) one test point (marked X) on the boundary detects the bug.
In figure c) a boundary shifts to left.
In figure d) a boundary shifts to right.
In figure e) there is a missing boundary. In figure f) there is an extra boundary.
The following figure shows one dimensional domain bugs for closed boundaries.
B A
b) Closure bug
X
B A
X
B A
X
B
e) Missing Boundary
X X
B A C
f) Extra Boundary
In the above figure a) we assume that the boundary was to close for A.
In figure b) one test point (marked X) on the boundary detects the bug.
In figure c) a boundary shifts to left. In figure d) a boundary shifts to right.
In figure e) there is a missing boundary. In figure f) there is an extra boundary.
Only one difference from this diagram to previous diagram is here we have closed
boundaries.
(c) Testing Two-Dimensional Domains:
The following figure shows domain boundary bugs for two dimensional domains.
A and B are adjacent domains, and the boundary is closed with respect to A and the
boundary is opened with respect to B.
(i) Closure Bug:
The figure (a) shows a wrong closure, that is caused by using a wrong operator for
example, x>=k was used when x > k was intended.
The two on points detect this bug.
(ii) Shifted Boundary:
In figure (b) the bug is shifted up, which converts part of domain B into A’.
This is caused by incorrect constant in a predicate for example x + y >= 17 was used
when x + y > = 7 was intended. Similarly figure (c) shows a shift down.
Page 10
Software Testing Methodologies Unit III
B
X A X
(a) Closure Bug
X
A'
X A X
(b) Shifted Up
X
X B X
B'
A
(c) Shifted Down
A'
X
X A X
B'
A'
X
X A X
B'
(e) Extra Boundary
B
X
X A X
Page 11
Software Testing Methodologies Unit III
(iii) Tilted boundary:
A tilted boundary occurs, when coefficients in the boundary inequality are wrong.
For example we used 3x + 7y > 17 when 7x + 3y > 17 is needed.
Figure (d) shows a tilted boundary which creates domain segments A’ and B’.
(iv) Extra Boundary:
An extra boundary is created by an extra predicate.
Figure (e) shows an extra boundary. The extra boundary is caught by two on points.
(v) Missing Boundary:
A missing boundary is created by leaving out the predicate.
A missing boundary shown in figure (f) is caught by two on points.
The following figure summarizes domain testing for two dimensional domains.
There are two on points (closed circles) for each segment and one off point (open circle)
Note that the selected test points are shared with adjacent domains.
The on points for two adjacent boundary segments can also be shared.
The shared on points is given below.
A a
c c'
C
d
B
b
0
both closed
The following figure shows the twelve different ways the caller and the called can disagree
about closure. Not all of them are necessarily bugs.
17
Here the four cases in which a caller boundary is open and the called is closed are not
buggy.
(iv) Span Compatibility:
The following figure shows three possibly harmless of span incompatibilities.
In this figure Caller span is smaller than Called.
9 9 9 9
7 7
3 3
1 1 1 1
The range of a caller is a sub set of the called domain. That is not necessarily a bug.
The following figure shows Called is Smaller than Caller.
Page 14
Software Testing Methodologies Unit III
9 9 9 9
7 7
3 3
1 1 1 1
(v) Interface Range/ Domain Compatibility Testing:
The application of domain testing is also very important for interface testing because it tests
the range and domain compatibilities among caller and called routines.
It is the responsibility of the caller to provide the valid inputs to the called routine.
After getting the valid input, the test will be done on every input variable.
(vi) Finding the values:
Start with the called routine’s domains and generate test points.
A good component test should have included all the interesting domain-testing cases.
Those test cases are the values for which we must find the input values of the caller.
(5) Domains and Testability:
(i) General:
Domain testing gives orthogonal domain boundaries, consistent closure, independent
boundaries, linear boundaries, and other characteristics. We know that which makes
domain testing difficult. That is it consists of applying algebra to the problem.
(ii) Linearizing Transformations:
This is used to transfer non linear boundaries to equivalent linear boundaries.
The different methods used here are
(i)Polynomials:
A boundary is specified by a polynomial or multinomial in several variables.
For a polynomial each term can be replaced by a new variable.
i.e. x, x2, x3, …can be replaced by y1 = x, y2 = x2, y3 = x3 , …
For multinomials you add more new variables for terms such as xy, x 2y, xy2, …
So polynomial plays an important role in linear transformations.
(ii)Logarithmic Transforms:
Products such as xyz can be linearized by substituting u = log (x), v = log (y), log (z).
The original predicate xyz > 17 now becomes u + v + w > 2.83.
(iii)More general forms:
Apart from logarithmic transform & polynomials there are general linearizable forms
such as x / (a + b) and axb. We can also linearize by using Taylor series.
(iii) Coordinate Transformations:
The main purpose of coordinate transformation technique is to convert Parallel boundary
inequalities into non parallel boundary inequalities and Non-parallel boundary inequalities
into orthogonal boundary inequalities.
(iv) A Canonical Program Form:
Testing is clearly divided into testing the predicate and coordinate transformations.
i.e. testing the individual case selections, testing the control flow and then testing the case
processing..
(v) Great Insights:
Sometimes programmers have great insights into programming problems that result in
much simpler programs than one might have expected.
Page 15
Software Testing Methodologies Unit III
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
Page 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
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
Page 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
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
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
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
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
Page 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
Page 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
Page 24
Software Testing Methodologies Unit III
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
Software Testing Methodologies Unit III
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
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
.459 .306
.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
.1
1
10 2 C
Remove node 10 by applying series rule.
Page 28
Software Testing Methodologies Unit III
1 .05 .5 1 1
1 3 4 5 6 7
.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
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
.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
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
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
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
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
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
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
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