0% found this document useful (0 votes)
12 views91 pages

STM Unit 3

The document discusses software testing methodologies, focusing on path products, path expressions, and their applications in analyzing flow graphs. It covers concepts like regular expressions, logic-based testing, and reduction procedures for converting flow graphs into path expressions. Additionally, it addresses calculating the number of paths, probabilities, and mean processing times in routines.

Uploaded by

ARCHANA MANNE
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)
12 views91 pages

STM Unit 3

The document discusses software testing methodologies, focusing on path products, path expressions, and their applications in analyzing flow graphs. It covers concepts like regular expressions, logic-based testing, and reduction procedures for converting flow graphs into path expressions. Additionally, it addresses calculating the number of paths, probabilities, and mean processing times in routines.

Uploaded by

ARCHANA MANNE
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/ 91

SOFTWARE TESTING METHODOLOGY

UNIT-III
Topics:
Paths, Path products and Regular expressions: Path products &
path expression, reduction procedure, applications, regular
expressions & flow anomaly detection.
Logic based testing: overview ,decision tables,path
expressions,kv charts,specifications
Path Products & expressions

PURPOSE: APPLICATIONS
1.How many paths in a flow-graph?

Maximum, minimum etc.

2. The probability of getting to a point in a program ? (to a node in a flow

graph)

3. The mean processing time of a routine (a flow graph)

4. Effect of Routines involving complementary operations : (Push / Pop & Get /

Return)
Path Products & expressions

Path Expression:

An algebraic representation of sets of paths in a flow graph.

Regular Expression:

Path expressions converted by using arithmetic laws & weights into an


algebraic function.
Path Products & expressions – Path Product

• Annotate each link with a name.

• The path name as you traverse a path (segment) expressed as


concatenation of the link names is the path product.

1 2 3 4
a b d

• Examples of path products between 1 & 4 are:

abd abcbd abcbc


bd ….
Path Products & expressions – Path Expression

Path Expression
Simply: Derive using path products.

c
1 2 3 4
a b d

Example:

{ a b d , a b c b d, a b c b c b d , ….. } abd + abcbd

+ abcbcbd + ….
Path Products & expressions – Path Expression

Example:

g
h i
e f j

a b c d
Path Products & expressions – Path Expression
Example:

h i
e f j

a b c d

{ abcd , abfhebcd , abfigebcd ,


abfijd
}

abcd + abfhebcd + abfigebcd +


abfijd
Path Products & expressions – Path Segments & Products

•Loops:

a1 = a a2 = aa a3 = aaa an = aaaaa … n times

X = abc X1 = abc X2 = (abc)2 = abcabc

•Identity element

a0 = 1 X0 = 1 (path of length
0)
Path Products & expressions – Path Product

Path Product

• Associative

A ( BC ) = ( AB ) C = : Rule
ABC 1
Path Products & expressions – Path Product

Denotes a set of paths in parallel between two


nodes.

• Commutative
X +Y = : Rule
Y + X 2

• Associative
(X+Y)+Z = X+(Y+ : Rule
Z) =X+Y+Z 3
• Distributive

A ( B + C) = AB : Rule
+AC (A+B)C 4
= AC+BC
Path Products & expressions – Path Products
• Absorption: If X and Y denote the same set of paths, then the union of these sets is
unchanged

X +X =X : Rule 5
X + any subset of X = X

X = a + bc + X + a = X + bc + abcd =
abcd X

Example:
if X=a+ aa+ abc+abcd+def
X+a=X+aa=X+abc
Path Products & expressions – Path Products

• Loop:
b
An infinite set of parallel
paths. a c

b* = b0 + b + b + b + ……
1 2 3

X*
= X0 + X1 + X2 + X3 + ……

X+
= X1 + X2 + X3 + ……

• X X* = X* X  a = a* a
X+ a+
= =
a*
X = X0 + X + X
n 1 2

+ X3 + …… + Xn
Path Products & expressions – Path products
More Rules…

X m + Xn if n ≥ m : Rule 6
Xn
= if n < m
= Xm
m n = Xm+n : Rule 7
X X

Xn X* = X* Xn X* : Rule
= 8

Xn X+ = X+ Xn X+ : Rule
= 9
X* X+ = X+ X* X+ : Rule
= 10
Path Products & expressions – Path products
Identity Elements ..
1 : Path of Zero
Length
1+1 = 1 : Rule 11

1X = X1 = X : Rule 12

1
n = 1n = 1* = 1+ = 1 : Rule 13

1 +
+ = 1* = 1 : Rule 14
1
Path Products & expressions – Path products
Identity Elements ..

0 : empty set of
paths
X +0 = 0+X : Rule
=X 15

X = 0X = 0 : Rule
0 16

0* = 1 + 0 + 02 + 0 3 + . . . = 1 : Rule
17
Path Products & expressions – Reduction Procedure

 To convert a flow graph into a path


expression that denotes the set of all
entry/exit paths.

 Node by Node Reduction


Procedure
Path Products & expressions – Reduction Procedure
Initialization Steps:

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 - replace with

links of the form X*


Path Products & expressions – Reduction Procedure
Steps in the Algorithm’s loop
4. Select a non-initial & non-final node.: Replace it with a set of equivalent links,
whose path expressions correspond to all the ways you can form a product of the set of
in-links with the set of out-links of that node.

5. Combine any serial links by multiplying their path expressions.


( as in step 1)

6. Combine any parallel links by adding their path expressions.


( as in step 2)

7. Remove all the self-loops.


( as in step 3)

8. IF there’s just one node between entry & exit nodes, path expression for
the flow graph is the link’s path expression. ELSE, return to step 4.
Path Products & expressions – Reduction Procedure

Path Expression for a Flow Graph

• is not unique

• depends on the order of node removal.


Path Products & expressions – Reduction Procedure Example
Cross-Term Step (Step 4 of the algorithm)
• Fundamental step.

• Removes nodes one by one till there’s one entry & one
exit node.

• Replace the node by path products of all in-links with all


out-links
and interconnecting its immediate neighbors.
Path Products & expressions – Reduction Procedure Example
Processing of Loop Terms:

a c a b*c
1 2 1 2

d b*d
Path Products & expressions – Reduction Procedure Example

Processing of Loop Terms:

a b c
1 2 3 f4 5
d
e

bd
a bc f
1 2 4 5

a (bd)* bc f
1 2 4 5

e
Path Products & expressions – Reduction Procedure Example
Processing of Loop Terms:

a (bd)* bc f
1 2 4 5

a (bd)* bc f
1 4 5

e (bd)* bc

a (bd)* bc ( e (bd)* bc ) *
1 4 f 5

a (bd)* bc ( e (bd)* bc )* f
Two ways of loop removal:
Example of reduction procedure:

Fig 1: example flow graph Fig 2:removing node 10


Fig3 : removing node 9

Fig4 : removing node 7


Fig 5: removing node 8

Fig6 : after removing serial and parallel


linking
Fig 7 : removing node 4
Fig 8 : removing node 4 produces
Removing the loop and then node 6 result in the following expression:

a(bgjf)*b(c+gkh)d((ilhd)*imf(bjgf)*b(c+gkh)d)*(ilhd)*e
Path Products & expressions – Reduction Procedure Example

a(bgif)*b(c+gkh)d {(ilhd)*imf(bgif)*b(c+gkh)d}* (ilhd)*e


1 6 2

Flow Graph Path Expression :


a(bgif)*b(c+gkh)d {(ilhd)*imf(bgif)*b(c+gkh)d}* (ilhd)*e
Path Products & expressions – Before going into Applications

Before that, we learn:

Identities

Structured Flow Graphs

(code/routines) Unstructured Flow

graphs (routines)
Path Products & expressions – Identities / Rules
(A+B)* = ( A* + B* ) * : I1

= ( A* B* )* : I2

= ( A* B )* A* : I3

= ( B* A )* B* : I4

= ( A* B + A )* : I5

= ( B* A + B )* : I6

(A+B+C+...)* = ( A* + B* + C* + . . . )* : I7

= ( A* B* C* . . . )* : I8

Derived by removing nodes in different orders &


applying the series-parallel-loop rules.
Path Products & expressions – Structured Flow Graphs

Reducible to a single link by successive


application of the transformations shown below.

A B A, B
Proces
s

A B A B
IF THEN .. ELSE ..

A B
WHILE .. DO ..
Path Products & expressions – Structured Flow Graphs
Structured flow graph transformations

A B A, B
REPEAT .. UNTIL ..

Properties:
• No cross-term transformation.
• No GOTOs.
• No entry into or exit from the middle of
a loop.
Path Products & expressions – Structured Flow Graphs
Some
examples:

f
d
b
a b c d e
a c g i
e h

j
Path Products & expressions – UNstructured Flow Graphs
Some examples – unstructured flow
graphs/code:

X
Jumping into loops
X
Jumping out of loops

Branching into Decisions Branching out of Decisions


APPLICATIONS:
 Every application follows this common pattern:

Convert the program or graph into a path expression.


Identify a property of interest and derive an appropriate set of "arithmetic"
rules that characterizes the property.
Replace the link names by the link weights for the property of interest.
 The path expression has now been converted to an expression in some
algebra, such as ordinary algebra, regular expressions, or Boolean algebra.
Simplify or evaluate the resulting "algebraic" expression to answer the
question you asked.
How many paths in a Flow Graph?

•The question is not simple.


 What is the maximum number of different paths possible?
 What is the fewest number of paths possible?
 How many different paths are there really?
 What is the average number of paths?
MAXIMUM PATH COUNT ARITHMETIC:
• Label each link with a link weight that corresponds to the number of paths that link
represents. Also mark each loop with the maximum number of times that loop can be taken.
• If the answer is infinite, you might as well stop the analysis because it is clear that the
maximum number of paths will be infinite.
There are three cases of interest: parallel links, serial links, and loops.
EXAMPLE: The following is a reasonably well-structured program.
Each link represents a single link and consequently is given a weight of "1" to start.
Lets say the outer loop will be taken exactly four times and inner Loop Can be taken zero or
three times Its path expression, with a little work, is:
 Path expression: a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh

A: The flow graph should be annotated by replacing the link name with the maximum of
paths through that link (1) and also note the number of times for looping.
B: Combine the first pair of parallel loops outside the loop and also the pair in the outer
loop.
C: Multiply the things out and remove nodes to clear the clutter.
Alternatively, you could have substituted a "1" for each link in the path expression and
then simplified, as follows:

a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh
= 1(1 + 1)1(1(1 x 1)31 x 1 x 1(1 + 1)1)41(1 x 1)31 x 1 x 1
= 2(131 x (2))413
= 2(4 x 2)4 x 4
= 2 x 84 x 4 = 32,768
Calculating the Probability
 Weights, Notations and Arithmetic:

Probabilities can come into the act only at decisions (including decisions associated with loops).

 Annotate each out link with a weight equal to the probability of going in that direction.

 Evidently, the sum of the out link probabilities must equal 1

 For a simple loop, if the loop will be taken a mean of N times, the looping probability is N/(N + 1)

and the probability of not looping is 1/(N + 1).

 A link that is not part of a decision node has a probability of 1.


The arithmetic rules are those of ordinary arithmetic.

In this table, in case of a loop, PA is the probability of the link leaving the loop and PL is the probability of
looping.
The rules are those of ordinary probability theory.
 If you can do something either from column A with a probability of P A or from column B with a probability

PB, then the probability that you do either is PA + PB.

 For the series case, if you must do both things, and their probabilities are independent (as assumed),

then the probability that you do both is the product of their probabilities.
For example, a loop node has a looping probability of P L and a probability of not looping of PA, which is
obviously equal to I - PL.

because PL + PA + PB + PC = 1, 1 - PL = PA + PB + PC, and


CASE A
CASE B:
write down the path name and do the indicated arithmetic operation.
a path consisted of links a, b, c, d, e, and the associated probabilities were .2, .5, 1., .01,

and I respectively.
Path abcbcbcdeabddea would have a probability of 5 x 10-10.
Long paths are usually improbable.
MEAN PROCESSING TIME OF A ROUTINE:
Given the execution time of all statements or instructions for every link in a flowgraph and
the probability for each direction for all decisions are to find the mean processing time for
the routine as a whole.
The model has two weights associated with every link: the processing time for that link,
denoted by T, and the probability of that link P.
The arithmetic rules for calculating the mean time:
25x0.3+40x0.7 = 35.5
20x0.95+300x0.05 = 34

Fig 1

Fig 2
12+8=20
8+5=13
Fig 4

10+35.5+16=61.5
Fig 3
Fig 4

(20x0.6)/(1-0.4) +53 = 30
(0.4x5/1-0.6)+8=13

(0.3 x 63) / (1- 0.7) + 53 = 116

116x0.3/(1-0.3)=49.714
PUSH/POP, GET/RETURN:
This model can be used to answer several different questions that can turn up in debugging. It can also help decide which
test cases to design.
The question is:
“ Given a pair of complementary operations such as PUSH (the stack) and POP (the stack), considering the set of all possible
paths through the routine, what is the net effect of the routine? PUSH or POP? How many times? Under what conditions?”

Here are some other examples of complementary operations to which this model applies:
GET/RETURN a resource block.
OPEN/CLOSE a file.
START/STOP a device or process

Fig 1: Push /pop arithmetic


 The numeral 1 is used to indicate that nothing of interest (neither PUSH nor POP) occurs on a given link.
 “ H" denotes PUSH and "P" denotes POP. The operations are commutative, associative, and distributive.

Consider the following flow graph:


P(P + 1)1{P(HH)n1HP1(P + H)1}n2P(HH)n1HPH
Simplifying by using the arithmetic tables,
=(P2 + P){P(HH)n1(P + H)}n1(HH)n1
=(P2 + P){H2n1(P2 + 1)}n2H2n1
EXAMPLE 2 (GET / RETURN):
Exactly the same arithmetic tables used for previous example are used for GET / RETURN a buffer block or
resource, or, in fact, for any pair of complementary operations in which the total number of operations in
either direction is cumulative.
The arithmetic tables for GET/RETURN are:

"G" denotes GET and "R" denotes RETURN.


Consider the following flow graph:

G(G + R)G(GR)*GGR*R
= G(G + R)G3R*R
= (G + R)G3R*
= (G4 + G2)R*
This expression specifies the conditions under which the resources will be balanced on leaving the routine.
If the upper branch is taken at the first decision, the second loop must be taken four times.
If the lower branch is taken at the first decision, the second loop must be taken twice.
For any other values, the routine will not balance. Therefore, the first loop does not have to be
instrumented to verify this behavior because its impact should be nil.
Regular Expression & Flow anomaly Detection
The generic flow-anomaly detection problem (note: not just data-flow anomalies, but any flow anomaly) is
that of looking for a specific sequence of options considering all possible paths through a routine.
Let the operations be SET and RESET, denoted by s and r respectively, and we want to know if there is a SET
followed immediately a SET or a RESET followed immediately by a RESET (an ss or an rr sequence).
EXAMPLE: 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 (i.e., if T appears within) ABnC, then T
will appear in AB2C. (HUANG's Theorem)
As an example, let
A = pp
B = srr
C = rp
T = ss

The theorem states that ss will appear in pp(srr)nrp if it appears in pp(srr)2rp.


Topics:
Logic Based Testing: Overview, decision tables, path expressions,
kv charts, specifications.
Logic based testing: Overview
 Logic is used in a program by programmers.

 Boolean algebra is the way to work with logic – simplification & calculation.

 Hardware logic testing – hardware logic test design tools and methods use logic & Boolean
algebra.
 Hardware design language compilers/translators use logic & Boolean algebra.

 Impact of errors in specifications of a software is high as these are first in and last out.

 So, higher level language for specs is desired to reduce the number of errors.

 Higher order logic systems are used for formal specifications.


Logic based testing: Overview
Knowledge based systems:
 Knowledge based systems and artificial intelligence systems use high level logic
languages which are based on rule bases consisting of rules.
 Rules are predicate expressions containing domain knowledge related elements
combined with logical connectives.
 The answers to queries (problems) are derived based on Boolean algebraic operations
performed on the rule bases.

Such programs are called inference engines.


Modeling Logic with Decision Tables
• A matrix representation of the logic of a decision
• Specifies the possible conditions and the resulting actions
• Best used for complicated decision logic
Modeling Logic with Decision
Tables
• Consists of three parts
– Condition stubs
• Lists condition relevant to decision
– Action stubs
• Actions that result from a given set of conditions
– Rules
• Specify which actions are to be followed for a given set of conditions
Modeling Logic with Decision Tables

• Indifferent Condition
– Condition whose value does not affect which action is taken for two
or more rules
• Standard procedure for creating decision tables
– Name the condition and values each condition can assume
– Name all possible actions that can occur
– List all rules
– Define the actions for each rule
– Simplify the table
Complete decision table for payroll system example
Constructing a Decision Table
• PART 1. FRAME THE PROBLEM.

– Identify the conditions (decision criteria).These are the factors that will influence
the decision.
• E.g., We want to know the total cost of a student’s tuition. What factors are
important?

– Identify the range of values for each condition or criteria.


• E.g. What are they for each factor identified above?

– Identify all possible actions that can occur.


• E.g. What types of calculations would be necessary?
Constructing a Decision Table
• PART 2. CREATE THE TABLE.
– Create a table with 4 quadrants.
• Put the conditions in the upper left quadrant. One row per condition.
• Put the actions in the lower left quadrant. One row per action.
– List all possible rules.
• Alternate values for first condition.
• Repeat for all values of second condition. Keep repeating this process
for all conditions.
• Put the rules in the upper right quadrant.
– Enter actions for each rule
• In the lower right quadrant, determine what, if any, appropriate actions
should be taken for each rule. Reduce table as necessary.
Example
• Actions?
• Calculate the total cost of
– Consider CTI only (to make the
your tuition this quarter. problem smaller):
– What do you need to know? • U/G
• Level. (Undergrad or graduate) – Part Time (1 to 11 hrs.): $335.00/per
• School. (CTI, Law, etc.) hour
– Full Time (12 to 18 hrs.): $17,820.00
• Status. (Full or part time)
– * Credit hours over 18 are charged at the
• Number of hours part-time rate
• Graduate:
– Part time (1 to 7 hrs.): $520.00/per hour
– Full time (>= 8 hrs.): $520.00/per hour
A B AXB(AND)
T T T
T F F
F F F
F F F

A B A+B(OR)
T T T
T F T
F F T
F F F
Rules of a Boolean Algebra
The following ‘rules’ are satisfied for all elements x, y& z of B:
(1) x + y = y + x (commutative )
x× y = y × x
(2) x + (y + z) = (x + y) + z (associative )
x × (y × z) = (x × y) × z
(3) x × (y + z) = (x × y) + (x × z)
x + (y × z) = (x + y) × (x + z) (distributive)
(4) x + 0 = x (identity )
x×1=x
(5) x + x' = 1 (inverse)
x × x' = 0
Laws of Boolean Algebra
• In addition to the laws given by the rule of Boolean Algebra, we can show the
following laws

x'' = x (double complement)


x+x=x x× x = x (idempotent )
(x + y)' = (x × y)' = x' + y' (de Morgan’s laws)
x' × y' x + 1 = x×0=0
1 x× (x + y) = x
x + (x × (absorption) 1' = 0
y) = x (complement)
0' = 1
Exercise
Simplify the Boolean expression (x' × y) + (x × y)
Solution: (x' × y) + (x × y) (commutative)
= (y × x') + (y × x) (distributive)
= y × (x' + x) (commutative)
= y × (x + x') (inverse)
=y×1 (identity)
=y

Thus (x' × y) + (x × y) = y
Boolean Notation
• This means that in effect we’ll be employing Boolean Algebra
notation.
• The truth tables can be rewritten as
Notational Short-cuts
(1) In ‘multiplication’ we’ll omit the symbol ×, & write xy for x × y (just as in ordinary
algebra)
(2) The associative law says that
x + (y + z) = (x + y) + z
So we’ll write this as simply x + y + z, because the brackets aren’t necessary.
Similarly, write the product of 3 terms as xyz
(3) In ordinary algebra, the expression
x + y × z means x + (y × z), because of the convention that multiplication takes
precedence over addition.
e.g. x + yz means x + (y × z), and not (x + y) × z
Similarly, ab + cd means (a × b) + (c × d)
Reducing Boolean Expressions
• Is this the smallest possible implementation of this expression? No!

G = xyz + xyz’ + x’yz


• Use Boolean Algebra rules to reduce complexity while preserving
functionality.
• Step 1: Use idempotent law (a + a = a). So xyz + xyz’ + x’yz = xyz + xyz + xyz’
+ x’yz
• Step 2: Use distributive law a(b + c) = ab + ac. So xyz + xyz + xyz’ + x’yz = xy(z
+ z’) + yz(x + x’)
Reducing Boolean Expressions

• Step 3: Use Inverse law (a + a’ = 1).


So xy(z + z’) + yz(x + x’) = xy.1 + yz.1
• Step 4: Use Identity law (a . 1 = a).
So xy + yz = xy.1 + yz.1 = xyz + xyz’ + x’yz
Karnaugh Vietch chart
or
KV Chart
Karnaugh maps

• Alternate way of representing Boolean function


– All rows of truth table represented with a square
– Each square represents a minterm

x y F
y y
x 0 x 0 0 0
1 x’y
0 x’y’ 1 1
0 1 1
1 xy’ xy 0 1
1 0 0 1
1 0
0
1 1
0
Karnaugh maps
• Easy to convert between truth table, K-map, and SOP.

– Unoptimized form: number of 1’s in K-map equals number of


minterms (products) in SOP.

– Optimized form: reduced number of minterms

F(x,y) = x’y + x’y’ = x’


Karnaugh Maps
• A Karnaugh map is a graphical tool for assisting in the general
simplification procedure.
• Two variable maps.
B 0
A
100 1 B 0
F=AB A 0 1 F=AB +A B +AB
11 0 01
+ A ’B 11 1 
A B C F
• Three variable maps. 0 0 0 0
0 0 1 1
BC 0 1 0 1
00 01 11 0 1 1 0
A 10 1 0 0 1
00 1 0 1 1 0 1 1
11 1 1 1 1
1
1
1
0
1
1
1
+

F=AB’C’ + A B C +ABC + A BC  + A ’B’C +


A ’BC’
Rules for K-Maps
 We can reduce functions by circling 1’s in the K-map.

 Each circle represents minterm reduction.

 Following circling, we can deduce minimized

and-or form. x
y 0
1
1 1
0
0 0
1

F(x,y) = x’y + x’y’ = x’


Rules for K-Maps

Rules to consider

1. Every cell containing a 1 must be included at


least once.

2. The largest possible “power of 2 rectangle”


must be enclosed.
Karnaugh Maps
• A Karnaugh map is a graphical tool for assisting in the
general simplification procedure.
• Two variable maps.
B 0 B 0

00 1
1 00 1
1 F=AB +A B +AB
A11 0 F=AB A11 1 
+ A ’B
• Three variable maps. F=A+B

BC
00 01 11
A 10 1 0
00
11 1 1 F=A+B C +BC
1 
F=AB’C’ + A B C +ABC + A BC  + A’B’C +
More Karnaugh Map Examples
a a
Examples b 0 b 0
0 0 1 0 1 1
1 01 1 1 01 0
f=a g = b'
ab ab
c 00 01 11 10 c 00 01 11 10
0 0 0 1 0 0 0 0 1 1
1 0 1 1 1 1 0 0 1 1
cout = ab + bc + ac
f=a

1.Circle the largest groups possible.


2. Group dimensions must be a power of 2.
3. Remember what circling means
Specifications
Specification validation procedure / steps

1. Rewrite the specifications using consistent terminology.

2. Identify the predicates on which the cases are based. Name them with
suitable letters, such as A, B, C.

3.Rewrite the specification in English that uses only the logical connectives
AND, OR, and NOT, however stilted it may seem.

4. Convert the rewritten specifications into an equivalent set of Boolean


expressions.

5. Identify the default action and cases, if any are specified.

You might also like