Software Testing Methodologies
Software Testing Methodologies
SOFTWARE
TESTING
METHODOLOGIES
LECTURE notes
Syllabus
UNIT-I
Introduc琀椀on:-Purpose of tes琀椀ng,Dichotomies,model for tes琀椀ng,consequences of bugs,
taxonomy of bugs,Flow graphs and Path tes琀椀ng:- Basics concepts of path tes琀椀ng,
predicates, path predicates and achievable paths, path sensi琀椀zing, path
instrumenta琀椀on, applica琀椀on of path tes琀椀ng.
UNIT-II
Transac琀椀on Flow Tes琀椀ng:-transac琀椀on 昀氀ows, transac琀椀on 昀氀ow tes琀椀ng techniques.
Data昀氀ow tes琀椀ng:- Basics of data昀氀ow tes琀椀ng, strategies in data昀氀ow tes琀椀ng,applica琀椀on of
data昀氀ow tes琀椀ng.
UNIT-III
Domain Tes琀椀ng:-domains and paths, Nice & ugly domains, domain tes琀椀ng, domains
and interfaces tes琀椀ng, domain and interface tes琀椀ng, domains and testability.
UNIT-IV:
Paths,Path products and Regular expressions:- path products &pathexpression,
reduc琀椀on procedure, applica琀椀ons, regular expressions & 昀氀ow anomaly detec琀椀on.
Logic Based Tes琀椀ng:-overview,decision tables,path expressions,kv charts,
speci昀椀ca琀椀ons.
UNIT-V:
State, State Graphs and Transi琀椀on tes琀椀ng:- state graphs, good & bad state graphs,
state tes琀椀ng, Testability 琀椀ps.
Graph Matrices and Applica琀椀on:-Mo琀椀va琀椀onal overview, matrix of graph,
rela琀椀ons, power of a matrix, node reduc琀椀on algorithm, building tools
TEXT BOOKS
1. So昀琀ware Tes琀椀ng techniques – Boris Beizer, Dreamtech, second edi琀椀on.
2. So昀琀ware Tes琀椀ng Tools – Dr.K.V.K.K.Prasad, Dreamtech.
REFERENCES BOOKS:
1. The cra昀琀 of so昀琀ware tes琀椀ng – Brian Marick, Pearson Educa琀椀on.
2. So昀琀ware Tes琀椀ng Techniques – SPD(Oreille)
3. So昀琀ware Tes琀椀ng in the Real World – Edward Kit, Pearson.
4. E昀昀ec琀椀ve methods of So昀琀ware Tes琀椀ng, Perry, John Wiley.
5. Art of So昀琀ware Tes琀椀ng – Meyers, John Wiley.
OUTCOMES
INDEX
Introduc琀椀on 1-2
I
Dichotomies,consequences of Bugs, Taxonomy 3-14
of bugs
Flow graphs and Path tes琀椀ng 14-33
107-113
State, State Graphs and Transi琀椀on tes琀椀ng
V
UNIT- I
UNIT-I
What is tes琀椀ng?
Tes琀椀ng is the process of exercising or evalua琀椀ng a system or system components by manual or automated means to
verify that it sa琀椀s昀椀es speci昀椀ed requirements.
Tes琀椀ng consumes at least half of the 琀椀me and work required to produce a func琀椀onal program.
o MYTH: Good programmers write code without bugs. (It’s wrong!!!)
o History says that even well wri琀琀en programs s琀椀ll have 1-3 bugs per hundred statements.
o Tes琀椀ng and Test Design are parts of quality assurance should also focus on bug
preven琀椀on. A prevented bug is be琀琀er than a detected and corrected bug.
Phases in a tester's mental life:
Phases in a tester's mental life can be categorized into the following 5 phases:
1. Phase 0: (Un琀椀l 1956: Debugging Oriented) There is no di昀昀erence between tes琀椀ng and
debugging. Phase 0 thinking was the norm in early days of so昀琀ware development 琀椀ll
tes琀椀ng emerged as a discipline.
2. Phase 1: (1957-1978: Demonstra琀椀on Oriented) the purpose of tes琀椀ng here is to show that
so昀琀ware works. Highlighted during the late 1970s. This failed because the probability of
showing that so昀琀ware works 'decreases' as tes琀椀ng increases. I.e. the more you test, the
more likely you will 昀椀nd a bug.
3. Phase 2: (1979-1982: Destruc琀椀on Oriented) the purpose of tes琀椀ng is to show that
so昀琀ware doesn’t work. This also failed because the so昀琀ware will never get released as you
will 昀椀nd one bug or the other. Also, a bug corrected may also lead to another bug.
4. Phase 3: (1983-1987: Evalua琀椀on Oriented) the purpose of tes琀椀ng is not to prove anything
but to reduce the perceived risk of not working to an acceptable value (Sta琀椀s琀椀cal Quality
Control). No琀椀on is that tes琀椀ng does improve the product to the extent that tes琀椀ng catches
bugs and to the extent that those bugs are 昀椀xed. The product is released when the
con昀椀dence on that product is high enough. (Note: This is applied to large so昀琀ware
products with millions of code and years of use.)
5. Phase 4: (1988-2000: Preven琀椀on Oriented) Testability is the factor considered here. One
reason is to reduce the labor of tes琀椀ng. Other reason is to check the testable and non-
testable code. Testable code has fewer bugs than the code that's hard to test. Iden琀椀fying
the tes琀椀ng techniques to test the code is the main key here.
Test Design:
We know that the so昀琀ware code must be designed and tested, but many appear to be unaware that tests
themselves must be designed and tested. Tests should be properly designed and tested before applying it to the
actual code.
1. Inspec琀椀on Methods: Methods like walkthroughs, desk checking, formal inspec琀椀ons and
code reading appear to be as e昀昀ec琀椀ve as tes琀椀ng but the bugs caught don’t completely
overlap.
2. Design Style: While designing the so昀琀ware itself, adop琀椀ng stylis琀椀c objec琀椀ves such as
testability, openness and clarity can do much to prevent bugs.
3. Sta琀椀c Analysis Methods: Includes formal analysis of source code during compila琀椀on. In
earlier days, it is a rou琀椀ne job of the programmer to do that. Now, the compilers have
taken over that job.
4. Languages: The source language can help reduce certain kinds of bugs. Programmers
昀椀nd new bugs while using new languages.
5. Development Methodologies and Development Environment: The development
process and the environment in which that methodology is embedded can prevent
many kinds of bugs.
Dichotomies:
Tes琀椀ng Debugging
Tes琀椀ng starts with known condi琀椀ons, Debugging starts from possibly unknown
uses prede昀椀ned procedures and has ini琀椀al condi琀椀ons and the end cannot be
predictable outcomes. predicted except sta琀椀s琀椀cally.
Tes琀椀ng can and should be planned, Procedure and dura琀椀on of debugging cannot
designed and scheduled. be so constrained.
Tes琀椀ng is a demonstra琀椀on of error or
Debugging is a deduc琀椀ve process.
apparent correctness.
Debugging is the programmer's vindica琀椀on
Tes琀椀ng proves a programmer's failure.
(Jus琀椀昀椀ca琀椀on).
Tes琀椀ng, as executes, should strive to be
Debugging demands intui琀椀ve leaps,
predictable, dull, constrained, rigid and
experimenta琀椀on and freedom.
inhuman.
Much tes琀椀ng can be done without Debugging is impossible without detailed
design knowledge. design knowledge.
Tes琀椀ng can o昀琀en be done by an
Debugging must be done by an insider.
outsider.
Much of test execu琀椀on and design can
Automated debugging is s琀椀ll a dream.
be automated.
o Test designer is the person who designs the tests where as the tester is the one
actually tests the code. During func琀椀onal tes琀椀ng, the designer and tester are
probably di昀昀erent persons. During unit tes琀椀ng, the tester and the programmer
merge into one person.
o Tests designed and executed by the so昀琀ware designers are by nature biased
towards structural considera琀椀on and therefore su昀昀er the limita琀椀ons of
structural tes琀椀ng.
A module is a discrete, well-de昀椀ned, small component of a system. Smaller the modules, di昀케cult to
integrate; larger the modules, di昀케cult to understand. Both tests and systems can be modular. Tes琀椀ng can
and should likewise be organized into modular components. Small, independent test cases can be
designed to test independent modules.
Programming in large means construc琀椀ng programs that consists of many components wri琀琀en by many
di昀昀erent programmers. Programming in the small is what we do for ourselves in the privacy of our own
o昀케ces. Qualita琀椀ve and Quan琀椀ta琀椀ve changes occur with size and so must tes琀椀ng methods and quality
criteria.
Most so昀琀ware is wri琀琀en and used by the same organiza琀椀on. Unfortunately, this situa琀椀on is dishonest
because it clouds accountability. If there is no separa琀椀on between builder and buyer, there can be no
accountability.
The di昀昀erent roles / users in a system include:
1. Builder: Who designs the system and is accountable to the buyer.
2. Buyer: Who pays for the system in the hope of pro昀椀ts from providing services?
3. User: Ul琀椀mate bene昀椀ciary or vic琀椀m of the system. The user's interests are also
guarded by.
4. Tester: Who is dedicated to the builder's destruc琀椀on?
5. Operator: Who has to live with the builders' mistakes, the buyers' murky
(unclear) speci昀椀ca琀椀ons, testers' oversights and the users' complaints?
2. Bug Locality Hypothesis: The belief that a bug discovered with in a component a昀昀ects
only that component's behavior.
3. Control Bug Dominance: The belief those errors in the control structures (if, switch etc) of
programs dominate the bugs.
4. Code / Data Separa琀椀on: The belief that bugs respect the separa琀椀on of code and data.
5. Lingua Salvatore Est.: The belief that the language syntax and seman琀椀cs (e.g. Structured
Coding, Strong typing, etc) eliminates most bugs.
6. Correc琀椀ons Abide: The mistaken belief that a corrected bug remains corrected.
7. Silver Bullets: The mistaken belief that X (Language, Design method, representa琀椀on,
environment) grants immunity from bugs.
8. Sadism Su昀케ces: The common belief (especially by independent tester) that a sadis琀椀c
streak, low cunning, and intui琀椀on are su昀케cient to eliminate most bugs. Tough bugs need
methodology and techniques.
9. Angelic Testers: The belief that testers are be琀琀er at test design than programmers is at
code design.
Test
s:
o Tests are formal procedures, Inputs must be prepared, Outcomes should predict,
tests should be documented, commands need to be executed, and results are to
be observed. All these errors are subjected to error
o We do three distinct kinds of testing on a typical software system.
They are:
1. Unit / Component Tes琀椀ng: A Unit is the smallest testable piece of
so昀琀ware that can be compiled, assembled, linked, loaded etc. A unit is
usually the work of one programmer and consists of several hundred or
fewer lines of code. Unit Tes琀椀ng is the tes琀椀ng we do to show that the
unit does not sa琀椀sfy its func琀椀onal speci昀椀ca琀椀on or that its implementa琀椀on
structure does not match the intended design structure. A Component is
an integrated aggregate of one or more units. Component Tes琀椀ng is the
tes琀椀ng we do to show that the component does not sa琀椀sfy its func琀椀onal
speci昀椀ca琀椀on or that its implementa琀椀on structure does not match the
intended design structure.
2. Integra琀椀on Tes琀椀ng: Integra琀椀on is the process by which components are
aggregated to create larger components. Integra琀椀on Tes琀椀ng is tes琀椀ng
done to show that even though the components were individually
sa琀椀sfactory (a昀琀er passing component tes琀椀ng), checks the combina琀椀on of
components are incorrect or inconsistent.
Role of Models: The art of tes琀椀ng consists of crea琀椀ng, selec琀椀ng, exploring, and revising
models. Our ability to go through this process depends on the number of di昀昀erent
models we have at hand and their ability to express a program's behavior.
CONSEQUENCES OF BUGS:
TAXONOMY OF BUGS:
There is no universally correct way categorize bugs. The taxonomy is not rigid.
A given bug can be put into one or another category depending on its history and the
programmer's state of mind.
The major categories are: (1) Requirements, Features and Func琀椀onality Bugs (2)
Structural Bugs (3) Data Bugs (4) Coding Bugs (5) Interface, Integra琀椀on and System
Bugs (6) Test and Test Design Bugs.
and environment.
What hurts most about the bugs is that they are the earliest to invade the system
and the last to leave.
2. Feature Bugs:
Speci昀椀ca琀椀on problems usually create corresponding feature problems.
A feature can be wrong, missing, or super昀氀uous (serving no useful purpose). A missing
feature or case is easier to detect and correct. A wrong feature could have deep design
implica琀椀ons.
Removing the features might complicate the so昀琀ware, consume more resources, and
foster more bugs.
10
Another reason for control 昀氀ow bugs is that use of old code especially ALP & COBOL
code are dominated by control 昀氀ow bugs.
Control and sequence bugs at all levels are caught by tes琀椀ng, especially structural
tes琀椀ng, more speci昀椀cally path tes琀椀ng combined with a bo琀琀om line func琀椀onal test based
on a speci昀椀ca琀椀on.
2. Logic Bugs:
Bugs in logic, especially those related to misunderstanding how case statements and
logic operators behave singly and combina琀椀ons
Also includes evalua琀椀on of boolean expressions in deeply nested IF-THEN-ELSE
constructs.
If the bugs are parts of logical (i.e. boolean) processing not related to control 昀氀ow, they
are characterized as processing bugs.
If the bugs are parts of a logical expression (i.e. control-昀氀ow statement) which is used to
direct the control 昀氀ow, then they are categorized as control-昀氀ow bugs.
3. Processing Bugs:
Processing bugs include arithme琀椀c bugs, algebraic, mathema琀椀cal func琀椀on evalua琀椀on,
algorithm selec琀椀on and general processing.
Examples of Processing bugs include: Incorrect conversion from one data
representa琀椀on to other, ignoring over昀氀ow, improper use of greater-than-or-equal etc
Although these bugs are frequent (12%), they tend to be caught in good unit tes琀椀ng.
4. Initialization Bugs:
Ini琀椀aliza琀椀on bugs are common. Ini琀椀aliza琀椀on bugs can be improper and super昀氀uous.
Super昀氀uous bugs are generally less harmful but can a昀昀ect performance.
Typical ini琀椀aliza琀椀on bugs include: Forge琀�ng to ini琀椀alize the variables before 昀椀rst use,
assuming that they are ini琀椀alized elsewhere, ini琀椀alizing to the wrong format,
representa琀椀on or type etc
Explicit declara琀椀on of all variables, as in Pascal, can reduce some ini琀椀aliza琀椀on problems.
Data bugs:
Data bugs include all bugs that arise from the speci昀椀ca琀椀on of data objects, their
formats, the number of such objects, and their ini琀椀al values.
Data Bugs are at least as common as bugs in code, but they are o昀琀en treated as if they
did not exist at all.
Code migrates data: So昀琀ware is evolving towards programs in which more and more of
11
Dynamic data are transitory. Whatever their purpose their life琀椀me is rela琀椀vely short,
typically the processing 琀椀me of one transac琀椀on. A storage object may be used to hold
dynamic data of di昀昀erent types, with di昀昀erent formats, a琀琀ributes and residues.
Dynamic data bugs are due to le昀琀over garbage in a shared resource. This can be
handled in one of the three ways: (1) Clean up a昀琀er the use by the user (2) Common
Cleanup by the resource manager (3) No Clean up
Sta琀椀c Data are 昀椀xed in form and content. They appear in the source code or database
directly or indirectly, for example a number, a string of characters, or a bit pa琀琀ern.
Compile 琀椀me processing will solve the bugs caused by sta琀椀c data.
Coding bugs:
Coding errors of all kinds can create any of the other kind of bugs.
Syntax errors are generally not important in the scheme of things if the source language
translator has adequate syntax checking.
If a program has many syntax errors, then we should expect many logic and coding bugs.
The documenta琀椀on bugs are also considered as coding bugs which may mislead the
maintenance programmers.
1. External Interfaces:
12
The external interfaces are the means used to communicate with the world.
These include devices, actuators, sensors, input terminals, printers, and communica琀椀on
lines.
The primary design criterion for an interface with outside world should be robustness.
All external interfaces, human or machine should employ a protocol. The protocol may
be wrong or incorrectly implemented.
Other external interface bugs are: invalid 琀椀ming or sequence assump琀椀ons related to
external signals
Misunderstanding external input or output formats.
Insu昀케cient tolerance to bad input data.
2.Internal Interfaces:
Internal interfaces are in principle not di昀昀erent from external interfaces but they are
more controlled.
A best example for internal interfaces is communica琀椀ng rou琀椀nes.
The external environment is 昀椀xed and the system must adapt to it but the internal
environment, which consists of interfaces with other components, can be nego琀椀ated.
Internal interfaces have the same problem as external interfaces.
3. Hardware Architecture:
Bugs related to hardware architecture originate mostly from misunderstanding how the
hardware works.
Examples of hardware architecture bugs: address genera琀椀on error, i/o device opera琀椀on
/ instruc琀椀on error, wai琀椀ng too long for a response, incorrect interrupt handling etc.
The remedy for hardware architecture and interface problems is twofold: (1) Good
Programming and Tes琀椀ng (2) Centraliza琀椀on of hardware interface so昀琀ware in programs
wri琀琀en by hardware interface specialists.
5. Software Architecture:
So昀琀ware architecture bugs are the kind that called - interac琀椀ve.
Rou琀椀nes can pass unit and integra琀椀on tes琀椀ng without revealing such bugs.
Many of them depend on load, and their symptoms emerge only when the system is
stressed.
Sample for such bugs: Assump琀椀on that there will be no interrupts, Failure to block or un
block interrupts, Assump琀椀on that memory and registers were ini琀椀alized or not
13
ini琀椀alized etc
Careful integra琀椀on of modules and subjec琀椀ng the 昀椀nal system toa stress test are
e昀昀ec琀椀ve methods for these bugs.
6. Control and Sequence Bugs (Systems Level):
These bugs include: Ignored 琀椀ming, Assuming that events occur in a speci昀椀ed sequence, Working on data
before all the data have arrived from disc, Wai琀椀ng for an impossible combina琀椀on of prerequisites, Missing,
wrong, redundant or super昀氀uous process steps.
The remedy for these bugs is highly structured sequence control.
Specialize, internal, sequence control mechanisms are helpful.
8. Integration Bugs:
Integra琀椀on bugs are bugs having to do with the integra琀椀on of, and with the interfaces
between, working and tested components.
These bugs results from inconsistencies or incompa琀椀bili琀椀es between components.
The communica琀椀on methods include data structures, call sequences, registers,
semaphores, and communica琀椀on links and protocols results in integra琀椀on bugs.
The integra琀椀on bugs do not cons琀椀tute a big bug category (9%) they are expensive
category because they are usually caught late in the game and because they force
changes in several components and/or data structures.
9. System Bugs:
System bugs covering all kinds of bugs that cannot be ascribed to a component or to
their simple interac琀椀ons, but result from the totality of interac琀椀ons between many
components such as programs, data, hardware, and the opera琀椀ng systems.
There can be no meaningful system tes琀椀ng un琀椀l there has been thorough component
and integra琀椀on tes琀椀ng.
System bugs are infrequent (1.7%) but very important because they are o昀琀en found
only a昀琀er the system has been 昀椀elded.
14
Path Tes琀椀ng:
o Path Tes琀椀ng is the name given to a family of test techniques based
on judiciously selec琀椀ng a set of test paths through the program.
o If the set of paths are properly chosen then we have achieved some measure
of test thoroughness. For example, pick enough paths to assure that every
source statement has been executed at least once.
o Path tes琀椀ng techniques are the oldest of all structural test techniques.
o Path tes琀椀ng is most applicable to new so昀琀ware for unit tes琀椀ng. It is
a structural technique.
o It requires complete knowledge of the program's structure.
o It is most o昀琀en used by programmers to unit test their own code.
o The e昀昀ec琀椀veness of path tes琀椀ng rapidly deteriorates as the size of the
so昀琀ware aggregate under test increases.
o Flow Graph Elements: A 昀氀ow graph contains four di昀昀erent types of elements.
(1) Process Block (2) Decisions (3) Junc琀椀ons (4) Case Statements
1. Process Block:
A process block is a sequence of program
statements uninterrupted by either decisions or
junc琀椀ons.
It is a sequence of statements such that if any one of
statement of the block is executed, then all statement thereof
are executed.
Formally, a process block is a piece of straight line code of
one statement or hundreds of statements.
A process has one entry and one exit. It can consists of a single
statement or instruc琀椀on, a sequence of statements or
instruc琀椀ons, a
single entry/exit subrou琀椀ne, a macro or func琀椀on call, or a sequence of these.
2. Decisions:
A decision is a program point at which the control
昀氀ow can diverge.
Machine language condi琀椀onal branch and condi琀椀onal
skip instruc琀椀ons are examples of decisions.
Most of the decisions are two-way but some are
three way branches in control 昀氀ow.
3. Case Statements:
A case statement is a mul琀椀-way branch or decisions.
Examples of case statement are a jump table in
assembly language, and the PASCAL case statement.
From the point of view of test design, there are no
di昀昀erences between Decisions and Case Statements
4. Junctions:
A junc琀椀on is a point in the program where the control
昀氀ow can merge.
Examples of junc琀椀ons are: the target of a jump or
16
17
Notational Evolution:
The control 昀氀ow graph is simpli昀椀ed representa琀椀on of the program's structure.The nota琀椀on changes made in
crea琀椀on of control 昀氀ow graphs:
o The process boxes weren't really needed. There is an implied process on every line
joining junc琀椀ons and decisions.
o We don't need to know the speci昀椀cs of the decisions, just the fact that there is a branch.
o The speci昀椀c target label names aren't important-just the fact that they exist. So we can
replace them by simple numbers.
o To understand this, we will go through an example (Figure 2.2) wri琀琀en in a FORTRAN
like programming language called Programming Design Language (PDL). The program's
corresponding 昀氀owchart (Figure 2.3) and 昀氀owgraph (Figure 2.4) were also provided
below for be琀琀er understanding.
o The 昀椀rst step in transla琀椀ng the program to a 昀氀owchart is shown in Figure 2.3, where we
have the typical one-for-one classical 昀氀owchart. Note that complexity has increased,
18
clarity has decreased, and that we had to add auxiliary labels (LOOP, XX, and YY), which
have no actual program counterpart. In Figure 2.4 we merged the process steps and
replaced them with the single process box.
o We now have a control 昀氀ow graph. But this representa琀椀on is s琀椀ll too busy. We simplify
the nota琀椀on further to achieve Figure 2.5, where for the 昀椀rst 琀椀me we can really see
what the control 昀氀ow looks like.
Although graphical representa琀椀ons of 昀氀ow graphs are revealing, the details of the control 昀氀ow inside a program
20
in the 昀氀ow graph. Only the informa琀椀on per琀椀nent to the control 昀氀ow is shown.
Linked List representation of Flow Graph:
21
Flowcharts can be
1. Handwri琀琀en by the programmer.
2. Automa琀椀cally produced by a 昀氀owchar琀椀ng program based on a mechanical analysis
of the source code.
3. Semi automa琀椀cally produced by a 昀氀ow char琀椀ng program based in part on
structural analysis of the source code and in part on direc琀椀ons given by
the programmer.
There are rela琀椀vely few control 昀氀ow graph generators.
Path: A path through a program is a sequence of instruc琀椀ons or statements that starts at an entry,
junc琀椀on, or decision and ends at another, or possibly the same junc琀椀on, decision, or exit.
o A path may go through several junc琀椀ons, processes, or decisions, one
or more 琀椀mes.
o Paths consist of segments.
o The segment is a link - a single process that lies between two nodes.
o A path segment is succession of consecu琀椀ve links that belongs to some path.
o The length of path measured by the number of links in it and not by the
number of the instruc琀椀ons or statements executed along that path.
o The name of a path is the name of the nodes along the path.
There are many paths between the entry and exit of a typical rou琀椀ne.
Every decision doubles the number of poten琀椀al paths. And every loop mul琀椀plies the number of poten琀椀al paths by the
number of di昀昀erent itera琀椀on values possible for the loop.
De昀椀ning complete tes琀椀ng:
1. Exercise every path from entry to exit.
2. Exercise every statement or instruc琀椀on at least once.
3. Exercise every branch and case statement, in each direc琀椀on at least once.
If prescrip琀椀on 1 is followed then 2 and 3 are automa琀椀cally followed. But it is imprac琀椀cal for most rou琀椀nes. It
can be done for the rou琀椀nes that have no loops, in which it is equivalent to 2 and 3 prescrip琀椀ons.
22
For X nega琀椀ve, the output is X + A, while for X greater than or equal to zero, the output is X + 2A. Following
prescrip琀椀on 2 and execu琀椀ng every statement, but not every branch, would not reveal the bug in the following
incorrect version:
A nega琀椀ve value produces the correct answer. Every statement can be executed, but if the test cases do not force
each branch to be taken, the bug can remain hidden. The next example uses a test based on execu琀椀ng each branch
but does not force the execu琀椀on of all statements:
The hidden loop around label 100 is not revealed by tests based on prescrip琀椀on 3 alone because no test forces the
execu琀椀on of statement 100 and the following GOTO statement. Furthermore, label 100 is not 昀氀agged by the
compiler as an unreferenced label and the subsequent GOTO does not refer to an unde昀椀ned label.
A Sta琀椀c Analysis (that is, an analysis based on examining the source code or structure) cannot determine whether
a piece of code is or is not reachable. There could be subrou琀椀ne calls with parameters that are subrou琀椀ne labels,
or in the above example there could be a GOTO that targeted label 100 but could never achieve a value that would
send the program to that label.
Only a Dynamic Analysis (that is, an analysis based on the code's behavior while running - which is to say, to all
intents and purposes, tes琀椀ng) can determine whether code is reachable or not and therefore dis琀椀nguish between
the ideal structure we think we have and the actual, buggy structure.
Any tes琀椀ng strategy based on paths must at least both exercise every instruc琀椀on and take branches in all
direc琀椀ons.
A set of tests that does this is not complete in an absolute sense, but it is complete in the sense that anything less
23
24
7. A昀琀er you have traced a covering path set on the master sheet and 昀椀lled in the
table for every path, check the following:
1. Does every decision have a YES and a NO in its column? (C2)
2. Has every case of all case statements been marked? (C2)
3. Is every three - way branch (less, equal, greater) covered? (C2)
25
LOOPS:
Cases for a single loop: A Single loop can be covered with two cases: Looping and Not looping. But, experience
shows that many loop-related bugs are not discovered by C1+C2. Bugs hide themselves in corners and congregate at
boundaries - in the cases of loops, at or around the minimum or maximum number of 琀椀mes the loop can be
iterated. The minimum number of itera琀椀ons is o昀琀en zero, but it need not be.
26
27
Kinds of Loops: There are only three kinds of loops with respect to path tes琀椀ng:
Nested Loops:
The number of tests to be performed on nested loops will be the exponent of the tests performed on single
loops.As we cannot always a昀昀ord to test all combina琀椀ons of nested loops' itera琀椀ons values. Here's a tac琀椀c
used to discard some of these values:
1. Start at the inner most loop. Set all the outer loops to their minimum values.
2. Test the minimum, minimum+1, typical, maximum-1 , and maximum for the
innermost loop, while holding the outer loops at their minimum itera琀椀on parameter
values. Expand the tests as required for out of range and excluded values.
3. If you've done the outmost loop, GOTO step 5, else move out one loop and set it up as
in step 2 with all other loops set to typical values.
4. Con琀椀nue outward in this manner un琀椀l all loops have been covered.
5. Do all the cases for all loops in the nest simultaneously.
Concatenated Loops:
Concatenated loops fall between single and nested loops with respect to test cases. Two loops are
concatenated if it's possible to reach one a昀琀er exi琀椀ng the other while s琀椀ll on a path from entrance to exit.
If the loops cannot be on the same path, then they are not concatenated and can be treated as individual
loops.
Horrible Loops:
A horrible loop is a combina琀椀on of nested loops, the use of code that jumps into and out of loops,
intersec琀椀ng loops, hidden loops, and cross connected loops.
Makes itera琀椀on value selec琀椀on for test cases an awesome and ugly task, which is another reason such
structures should be avoided.
28
29
Put in limits or checks that prevent the combined extreme cases. Then you have to test
the so昀琀ware that implements such safety measures.
PREDICATE: The logical func琀椀on evaluated at a decision is called Predicate. The direc琀椀on taken at a decision
depends on the value of decision variable. Some examples are: A>0, x+y>=90.......
PATH PREDICATE: A predicate associated with a path is called a Path Predicate. For example, "x is greater than
zero", "x+y>=90", "w is either nega琀椀ve or equal to 10 is true" is a sequence of predicates whose truth values will
cause the rou琀椀ne to take a speci昀椀c path.
MULTIWAY BRANCHES:
The path taken through a mul琀椀way branch such as a computed GOTO's, case statement, or
jump tables cannot be directly expressed in TRUE/FALSE terms.
Although, it is possible to describe such alterna琀椀ves by using mul琀椀 valued logic, an
expedient (prac琀椀cal approach) is to express mul琀椀way branches as an equivalent set of
if..then..else statements.
For example a three way case statement can be wri琀琀en as: If case=1 DO A1 ELSE (IF Case=2
DO A2 ELSE DO A3 ENDIF)ENDIF.
INPUTS:
In tes琀椀ng, the word input is not restricted to direct inputs, such as variables in a subrou琀椀ne
call, but includes all data objects referenced by the rou琀椀ne whose values are 昀椀xed prior to
entering it.
For example, inputs in a calling sequence, objects in a data structure, values le昀琀 in
registers, or any combina琀椀on of object types.
The input for a par琀椀cular test is mapped as a one dimensional array called as an Input
Vector.
PREDICATE INTERPRETATION:
The simplest predicate depends only on input variables.
For example if x1,x2 are inputs, the predicate might be x1+x2>=7, given the values of x1
and x2 the direc琀椀on taken through the decision is based on the predicate is determined at
input 琀椀me and does not depend on processing.
Another example, assume a predicate x1+y>=0 that along a path prior to reaching this
predicate we had the assignment statement y=x2+7. although our predicate depends on
processing, we can subs琀椀tute the symbolic expression for y to obtain an equivalent
predicate x1+x2+7>=0.
The act of symbolic subs琀椀tu琀椀on of opera琀椀ons along the path in order to express the
predicate solely in terms of the input vector is called predicate interpreta琀椀on.
Some琀椀mes the interpreta琀椀on may depend on the path; for
30
example, INPUT X
ON X GOTO A, B, C, ...
A: Z := 7 @ GOTO HEM B: Z := -
7 @ GOTO HEM C: Z := 0 @
GOTO HEM
.........
HEM: DO SOMETHING
.........
HEN: IF Y + Z > 0 GOTO ELL ELSE GOTO EMM
The predicate interpreta琀椀on at HEN depends on the path we took through the 昀椀rst mul琀椀way branch. It yields for
the three cases respec琀椀vely, if Y+7>0, Y-7>0, Y>0.
The path predicates are the speci昀椀c form of the predicates of the decisions along the
selected path a昀琀er interpreta琀椀on.
31
Any set of input values that sa琀椀sfy all of the condi琀椀ons of the path predicate expression
will force the rou琀椀ne to the path.
Some琀椀mes a predicate can have an OR in it.
Example:
A: X5 > 0 E: X6 < 0
B: X1 + 3X2 + 17 B: X1 + 3X2 + 17
>= 0 >= 0
C: X3 = 17 C: X3 = 17
D: X4 - X1 >= D: X4 - X1 >=
14X2 14X2
Boolean algebra nota琀椀on to denote the boolean expression:
ABCD+EBCD=(A+E)BCD
PREDICATE COVERAGE:
Compound Predicate: Predicates of the form A OR B, A AND B and more complicated
Boolean expressions are called as compound predicates.
Some琀椀mes even a simple predicate becomes compound a昀琀er interpreta琀椀on. Example: the
predicate if (x=17) whose opposite branch is if x.NE.17 which is equivalent to x>17. Or.
X<17.
Predicate coverage is being the achieving of all possible combina琀椀ons of truth values
corresponding to the selected path have been explored under some test.
As achieving the desired direc琀椀on at a given decision could s琀椀ll hide bugs in the associated
predicates
TESTING BLINDNESS:
Tes琀椀ng Blindness is a pathological (harmful) situa琀椀on in which the desired path is achieved
for the wrong reason.
There are three types of Tes琀椀ng Blindness:
Assignment Blindness:
o Assignment blindness occurs when the buggy predicate appears to work correctly
because the speci昀椀c value chosen for an assignment statement works with both the
correct and incorrect predicate.
o For Example:
Correct Buggy
X = 7 X = 7
........ ........
if Y > 0 if X+Y > 0
then ... then ...
o If the test case sets Y=1 the desired path is taken in either case, but there is s琀椀ll a bug.
Equality Blindness:
o Equality blindness occurs when the path selected by a prior predicate results in a value
32
Self Blindness:
o Self blindness occurs when the buggy predicate is a mul琀椀ple of the correct predicate and
as a result is indis琀椀nguishable along that path.
o For Example:
Correct Buggy
X=A X=A
........ ........
if X-1 > 0 if X+A-2 > 0
then ... then ...
1. The assignment (x=a) makes the predicates mul琀椀ples of each other, so the direc琀椀on taken is the same for the
correct and buggy version.
PATH SENSITIZING:
SENSITIZATION.
34
1. This is a workable approach, instead of selec琀椀ng the paths without considering how to
sensi琀椀ze, a琀琀empt to choose a covering path set that is easy to sensi琀椀ze and pick hard to
sensi琀椀ze paths only as you must to achieve coverage.
2. Iden琀椀fy all variables that a昀昀ect the decision.
3. Classify the predicates as dependent or independent.
4. Start the path selec琀椀on with un correlated, independent predicates.
5. If coverage has not been achieved using independent uncorrelated predicates, extend the
path set using correlated predicates.
6. If coverage has not been achieved extend the cases to those that involve dependent
predicates.
7. Last, use correlated, dependent predicates.
PATH INSTRUMENTATION:
1. Path instrumenta琀椀on is what we have to do to con昀椀rm that the outcome was achieved
by the intended path.
2. Co-incidental Correctness: The coincidental correctness stands for achieving the desired
outcome for wrong reason.
35
o Why Single Link Markers aren't enough: Unfortunately, a single link marker may not
do the trick because links can be chewed by open bugs.
36
We intended to traverse the ikm path, but because of a rampaging GOTO in the middle of the m link, we go
to process B. If coincidental correctness is against us, the outcomes will be the same and we won't know
about the bug.
Link Counter: A less disrup琀椀ve (and less informa琀椀ve) instrumenta琀椀on method is based
on counters. Instead of a unique link name to be pushed into a string when the link is
traversed, we simply increment a link counter. We now con昀椀rm that the path length is as
expected. The same problem that led us to double link markers also leads us to double
link counters.
37
UNIT II
TRANSACTION FLOW TESTING AND DATA FLOW TESTING
Transac琀椀on Flow Tes琀椀ng:-transac琀椀on 昀氀ows, transac琀椀on 昀氀ow tes琀椀ng
techniques. Data昀氀ow tes琀椀ng:- Basics of data昀氀ow tes琀椀ng, strategies in
data昀氀ow tes琀椀ng, applica琀椀on of data昀氀ow tes琀椀ng.
INTRODUCTION
38
USAGE:
o Transac琀椀on 昀氀ows are indispensable for specifying requirements of complicated
systems, especially online systems.
o A big system such as an air tra昀케c control or airline reserva琀椀on system, has not
hundreds, but thousands of di昀昀erent transac琀椀on 昀氀ows.
o The 昀氀ows are represented by rela琀椀vely simple 昀氀owgraphs, many of which have a
single straight-through path.
o Loops are infrequent compared to control 昀氀owgraphs.
o The most common loop is used to request a retry a昀琀er user input errors. An ATM
system, for example, allows the user to try, say three 琀椀mes, and will take the
card away the fourth 琀椀me.
COMPLICATIONS:
o In simple cases, the transac琀椀ons have a unique iden琀椀ty from the 琀椀me they're
created to the 琀椀me they're completed.
o In many systems the transac琀椀ons can give birth to others, and transac琀椀ons can
also merge.
o Births: There are three di昀昀erent possible interpreta琀椀ons of the decision symbol,
or nodes with two or more out links. It can be a Decision, Biosis or a Mitosis.
1. Decision: Here the transac琀椀on will take one alterna琀椀ve or the other
alterna琀椀ve but not both. (See Figure 3.2 (a))
2. Biosis: Here the incoming transac琀椀on gives birth to a new transac琀椀on,
and both transac琀椀on con琀椀nue on their separate paths, and the parent
retains it iden琀椀ty. (See Figure 3.2 (b))
3. Mitosis: Here the parent transac琀椀on is destroyed and two new
transac琀椀ons are created.(See Figure 3.2 (c))
39
40
PATH SENSITIZATION:
o Most of the normal paths are very easy to sensi琀椀ze-80% - 95% transac琀椀on 昀氀ow
coverage (c1+c2) is usually easy to achieve.
o The remaining small percentage is o昀琀en very di昀케cult.
o Sensi琀椀za琀椀on is the act of de昀椀ning the transac琀椀on. If there are sensi琀椀za琀椀on
problems on the easy paths, then bet on either a bug in transac琀椀on 昀氀ows or a
design bug.
PATH INSTRUMENTATION:
o Instrumenta琀椀on plays a bigger role in transac琀椀on 昀氀ow tes琀椀ng than in unit path
tes琀椀ng.
o The informa琀椀on of the path taken for a given transac琀椀on must be kept with that
transac琀椀on and can be recorded by a central transac琀椀on dispatcher or by the
individual processing modules.
o In some systems, such traces are provided by the opera琀椀ng systems or a running
log.
ini琀椀alized prior to use or that all de昀椀ned objects have been used for something.
o Mo琀椀va琀椀on: It is our belief that, just as one would not feel con昀椀dent about a
program without execu琀椀ng every statement in it as part of some test, one should
not feel con昀椀dent about a program without having seen the e昀昀ect of using the value produced by each and every
computa琀椀on.
BUG ASSUMPTION:
The bug assump琀椀on for data-昀氀ow tes琀椀ng strategies is that control 昀氀ow is generally correct and that
something has gone wrong with the so昀琀ware so that data objects are not available when they should be,
or silly things are being done to data objects.
o Also, if there is a control-昀氀ow problem, we expect it to have symptoms that
can be detected by data-昀氀ow analysis.
o Although we'll be doing data-昀氀ow tes琀椀ng, we won't be using data 昀氀ow graphs as
such. Rather, we'll use an ordinary control 昀氀ow graph annotated to show what
happens to the data objects of interest at the moment.
DATA FLOW GRAPHS:
o The data 昀氀ow graph is a graph consis琀椀ng of nodes and directed links.
o We will use a control graph to show what happens to data objects of interest at
that moment.
o Our objec琀椀ve is to expose devia琀椀ons between the data 昀氀ows we have and
the data 昀氀ows we want.
42
43
1 dd :- probably harmless but suspicious. Why de昀椀ne the object twice without an intervening
usage?
2 dk :- probably a bug. Why de昀椀ne the object without using it?
3 du :- the normal case. The object is de昀椀ned and then used.
4 kd :- normal situa琀椀on. An object is killed and then rede昀椀ned.
5 kk :- harmless but probably buggy. Did you want to be sure it was really killed?
6 ku :- a bug. the object doesnot exist.
7 ud :- usually not a bug because the language permits reassignment at almost any 琀椀me.
8 uk :- normal situa琀椀on.
9 uu :- normal situa琀椀on.
In addi琀椀on to the two le琀琀er situa琀椀ons, there are six single le琀琀er situa琀椀ons.We will use a leading dash to mean that
nothing of interest (d,k,u) occurs prior to the ac琀椀on noted along the entry-exit path of interest.
A trailing dash to mean that nothing happens a昀琀er the point of interest to the exit.
They possible anomalies are:
1 -k :- possibly anomalous because from the entrance to this point on the path, the
variable had not been de昀椀ned. We are killing a variable that does not exist.
2 -d :- okay. This is just the 昀椀rst de昀椀ni琀椀on along this path.
3 -u :- possibly anomalous. Not anomalous if the variable is global and has
been previously de昀椀ned.
44
4 k- :- not anomalous. The last thing done on this path was to kill the variable.
5 d- :- possibly anomalous. The variable was de昀椀ned and not used on this path. But
this could be a global de昀椀ni琀椀on.
6 u- :- not anomalous. The variable was used but not killed on this path. Although
this sequence is not anomalous, it signals a frequent kind of bug. If d and k mean
dynamic storage alloca琀椀on and return respec琀椀vely, this could be an instance in
which a dynamically allocated object was not returned to the pool a昀琀er use.
Data 昀氀ow anomaly model prescribes that an object can be in one of four dis琀椀nct states:
0. K :- unde昀椀ned, previously killed, doesnot exist
1. D :- de昀椀ned but not yet used for anything
2. U :- has been used for computa琀椀on or in predicate
3. A :- anomalous
These capital le琀琀ers (K, D, U, A) denote the state of the variable and should not be confused with the program
ac琀椀on, denoted by lower case le琀琀ers.
Unforgiving Data - Flow Anomaly Flow Graph: Unforgiving model, in which once a variable becomes
anomalous it can never return to a state of grace.
Assume that the variable starts in the K state - that is, it has not been de昀椀ned or does not exist. If an a琀琀empt is
made to use it or to kill it (e.g., say that we're talking about opening, closing, and using 昀椀les and that 'killing' means
closing), the object's state becomes anomalous (state A) and, once it is anomalous, no ac琀椀on can return the
variable to a working state.
If it is de昀椀ned (d), it goes into the D, or de昀椀ned but not yet used, state. If it has been de昀椀ned (D) and rede昀椀ned (d)
or killed without use (k), it becomes anomalous, while usage (u) brings it to the U state. If in U, rede昀椀ni琀椀on (d)
brings it to D, u keeps it in U, and k kills it.
Forgiving Data - Flow Anomaly Flow Graph: Forgiving model is an alternate model where
redemp琀椀on (recover) from the anomalous state is possible
45
The point of showing you this alterna琀椀ve anomaly state graph is to demonstrate that the speci昀椀cs of an anomaly
depends on such things as language, applica琀椀on, context, or even your frame of mind. In principle, you must
create a new de昀椀ni琀椀on of data 昀氀ow anomaly (e.g., a new state graph) in each situa琀椀on. You must at least verify
that the anomaly de昀椀ni琀椀on behind the theory or imbedded in a data 昀氀ow anomaly test tool is appropriate to your
situa琀椀on.
Sta琀椀c analysis is analysis done on source code without actually execu琀椀ng it. For example: source code syntax error
detec琀椀on is the sta琀椀c analysis result.
Dynamic analysis is done on the 昀氀y as the program is being executed and is based on intermediate values that
result from the program's execu琀椀on. For example: a division by zero warning is the dynamic result.
If a problem, such as a data 昀氀ow anomaly, can be detected by sta琀椀c analysis methods, then it doesn’t belongs in
tes琀椀ng - it belongs in the language processor.
There is actually a lot more sta琀椀c analysis for data 昀氀ow analysis for data 昀氀ow anomalies going on in current
language processors.
For example, language processors which force variable declara琀椀ons can detect (-u) and (ku) anomalies.But s琀椀ll
there are many things for which current no琀椀ons of sta琀椀c analysis are INADEQUATE.
Why Sta琀椀c Analysis isn't enough? There are many things for which current no琀椀ons of sta琀椀c
analysis are inadequate. They are:
46
Dead Variables: Although it is o昀琀en possible to prove that a variable is dead or alive at a
given point in the program, the general problem is unsolvable.
Arrays: Arrays are problema琀椀c in that the array is de昀椀ned or killed as a single object, but
reference is to speci昀椀c loca琀椀ons within the array. Array pointers are usually dynamically
calculated, so there's no way to do a sta琀椀c analysis to validate the pointer value. In many
languages, dynamically allocated arrays contain garbage unless explicitly ini琀椀alized and
therefore, -u anomalies are possible.
Records and Pointers: The array problem and the di昀케culty with pointers is a special case of
mul琀椀part data structures. We have the same problem with records and the pointers to
them. Also, in many applica琀椀ons we create 昀椀les and their names dynamically and there's no
way to determine, without execu琀椀on, whether such objects are in the proper state on a
given path or, for that ma琀琀er, whether they exist at all.
False Anomalies: Anomalies are speci昀椀c to paths. Even a "clear bug" such as ku may not be
a bug if the path along which the anomaly exist is unachievable. Such "anomalies" are false
anomalies. Unfortunately, the problem of determining whether a path is or is not
achievable is unsolvable.
Recoverable Anomalies and Alternate State Graphs: What cons琀椀tutes an anomaly depends
on context, applica琀椀on, and seman琀椀cs. How does the compiler know which model I have in
mind? It can't because the de昀椀ni琀椀on of "anomaly" is not fundamental. The language
processor must have a built-in anomaly de昀椀ni琀椀on with which you may or may not (with
good reason) agree.
Concurrency, Interrupts, System Issues: As soon as we get away from the simple single-
task uniprocessor environment and start thinking in terms of systems, most anomaly issues
become vastly more complicated.
How o昀琀en do we de昀椀ne or create data objects at an interrupt level so that they can be processed by a lower-
priority rou琀椀ne? Interrupts can make the "correct" anomalous and the "anomalous" correct. True concurrency
(as in an MIMD machine) and pseudo concurrency (as in mul琀椀processing) systems can do the same to us.
Much of integra琀椀on and system tes琀椀ng is aimed at detec琀椀ng data-昀氀ow anomalies that cannot be detected in
the context of a single rou琀椀ne.
Although sta琀椀c analysis methods have limits, they are worth using and a con琀椀nuing trend in language
processor design has been be琀琀er sta琀椀c analysis methods, especially for data 昀氀ow anomaly detec琀椀on. That's
good because it means there's less for us to do as testers and we have far too much to do as it is.
47
The data 昀氀ow model is based on the program's control 昀氀ow graph - Don't confuse that with the program's data
昀氀ow graph.
Here we annotate each link with symbols (for example, d, k, u, c, and p) or sequences of symbols (for example, dd,
du, ddd) that denote the sequence of data opera琀椀ons on that link with respect to the variable of interest. Such
annota琀椀ons are called link weights.
The control 昀氀ow graph structure is same for every variable: it is the weights that change.
Figure 3.8: Unannotated 昀氀ow graph for example program in Figure 3.7
Figure 3.9: Control 昀氀ow graph annotated for X and Y data 昀氀ows.
49
INTRODUCTION:
TERMINOLOGY:
1. De昀椀ni琀椀on-Clear Path Segment, with respect to variable X, is a connected
sequence of links such that X is (possibly) de昀椀ned on the 昀椀rst link and not
rede昀椀ned or killed on any subsequent link of that path segment. ll paths in
Figure
3.9 are de昀椀ni琀椀on clear because variables X and Y are de昀椀ned only on the 昀椀rst link (1,3) and not therea昀琀er. In Figure
3.10, we have a more complicated situa琀椀on. The following path segments are de昀椀ni琀椀on-clear: (1,3,4), (1,3,5),
(5,6,7,4), (7,8,9,6,7), (7,8,9,10), (7,8,10), (7,8,10,11). Subpath (1,3,4,5) is not de昀椀ni琀椀on-clear because the variable is
de昀椀ned on (1,3) and again on (4,5). For prac琀椀ce, try 昀椀nding all the de昀椀ni琀椀on-clear subpaths for this rou琀椀ne (i.e., for all
variables).
2. Loop-Free Path Segment is a path segment for which every node in it is visited
atmost once. For Example, path (4,5,6,7,8,10) in Figure 3.10 is loop free, but path
(10,11,4,5,6,7,8,10,11,12) is not because nodes 10 and 11 are each visited twice.
3. Simple path segment is a path segment in which at most one node is visited
twice. For example, in Figure 3.10, (7,4,5,6,7) is a simple path segment. A simple
path segment is either loop-free or if there is a loop, only one node is involved.
4. A du path from node i to k is a path segment such that if the last link has a
computa琀椀onal use of X, then the path is simple and de昀椀ni琀椀on-clear; if the
penul琀椀mate (last but one) node is j - that is, the path is (i,p,q,...,r,s,t,j,k) and link
(j,k) has a predicate use - then the path from i to j is both loop-free and
de昀椀ni琀椀on- clear.
STRATEGIES: The structural test strategies discussed below are based on the program's control 昀氀ow graph. They
di昀昀er in the extent to which predicate uses and/or computa琀椀onal uses of variables are included in the test set.
Various types of data 昀氀ow tes琀椀ng strategies in decreasing order of their e昀昀ec琀椀veness are:
All - du Paths (ADUP): The all-du-paths (ADUP) strategy is the strongest data-昀氀ow tes琀椀ng strategy discussed here.
It requires that every du path from every de昀椀ni琀椀on of every variable to every some test.
50
For variable X and Y:In Figure 3.9, because variables X and Y are used only on link (1,3), any test that starts at
the entry sa琀椀s昀椀es this criterion (for variables X and Y, but not for all variables as required by the strategy).
For variable Z: The situa琀椀on for variable Z (Figure 3.10) is more complicated because the variable is rede昀椀ned in
many places. For the de昀椀ni琀椀on on link (1,3) we must exercise paths that include subpaths (1,3,4) and (1,3,5). The
de昀椀ni琀椀on on link (4,5) is covered by any path that includes (5,6), such as subpath (1,3,4,5,6, ...). The (5,6)
de昀椀ni琀椀on requires paths that include subpaths (5,6,7,4) and (5,6,7,8).
For variable V: Variable V (Figure 3.11) is de昀椀ned only once on link (1,3). Because V has a predicate use at node 12
and the subsequent path to the end must be forced for both direc琀椀ons at node 12, the all-du-paths strategy for
this variable requires that we exercise all loop-free entry/exit paths and at least one path that includes the loop
caused by (11,4).
Note that we must test paths that include both subpaths (3,4,5) and (3,5) even though neither of these has V
de昀椀ni琀椀ons. They must be included because they provide alternate du paths to the V use on link (5,6). Although
(7,4) is not used in the test set for variable V, it will be included in the test set that covers the predicate uses of
array variable V() and U.
The all-du-paths strategy is a strong criterion, but it does not take as many tests as it might seem at 昀椀rst because
any one test simultaneously sa琀椀s昀椀es the criterion for several de昀椀ni琀椀ons and uses of several di昀昀erent variables.
All Uses Startegy (AU):The all uses strategy is that at least one de昀椀ni琀椀on clear path from every de昀椀ni琀椀on of every
variable to every use of that de昀椀ni琀椀on be exercised under some test.
Just as we reduced our ambi琀椀ons by stepping down from all paths (P) to branch coverage (C2), say, we can reduce
the number of test cases by asking that the test set should include at least one path segment from every
de昀椀ni琀椀on to every use that can be reached by that de昀椀ni琀椀on.
For variable V: In Figure 3.11, ADUP requires that we include subpaths (3,4,5) and (3,5) in some test because
subsequent uses of V, such as on link (5,6), can be reached by either alterna琀椀ve. In AU either (3,4,5) or (3,5) can be
used to start paths, but we don't have to use both. Similarly, we can skip the (8,10) link if we've included the
(8,9,10) subpath.
Note the hole. We must include (8,9,10) in some test cases because that's the only way to reach the c use at link
(9,10) - but suppose our bug for variable V is on link (8,10) a昀琀er all? Find a covering set of paths under AU for
Figure 3.11.
All p-uses/some c-uses strategy (APU+C) : For every variable and every de昀椀ni琀椀on of that variable, include at least
one de昀椀ni琀椀on free path from the de昀椀ni琀椀on to every predicate use; if there are de昀椀ni琀椀ons of the variables that are
not covered by the above prescrip琀椀on, then add computa琀椀onal use test cases as required to cover every
de昀椀ni琀椀on.
51
For variable Z:In Figure 3.10, for APU+C we can select paths that all take the upper link (12,13) and therefore we do
not cover the c-use of Z: but that's okay according to the strategy's de昀椀ni琀椀on because every de昀椀ni琀椀on is covered.
Links (1,3), (4,5), (5,6), and (7,8) must be included because they contain de昀椀ni琀椀ons for variable
Z. Links (3,4), (3,5), (8,9), (8,10), (9,6), and (9,10) must be included because they contain
predicate uses of Z. Find a covering set of test cases under APU+C for all variables inthis
example - it only takes two tests.
For variable V:In Figure 3.11, APU+C is achieved for V by (1,3,5,6,7,8,10,11,4,5,6,7,8,10,11,12[upper], 13,2) and
(1,3,5,6,7,8,10,11,12[lower], 13,2). Note
that the c-use at (9,10) need not be included under the APU+C criterion.
All c-uses/some p-uses strategy (ACU+P) : The all c-uses/some p-uses strategy (ACU+P) is to 昀椀rst ensure coverage
by computa琀椀onal use cases and if any de昀椀ni琀椀on is not covered by the previously selected paths, add such
predicate use cases as are needed to assure that every de昀椀ni琀椀on is included in some test.
For variable Z: In Figure 3.10, ACU+P coverage is achieved for Z by path (1,3,4,5,6,7,8,10, 11,12,13[lower], 2), but
the predicate uses of several de昀椀ni琀椀ons are not covered. Speci昀椀cally, the (1,3) de昀椀ni琀椀on is not covered for the
(3,5) p-use, the (7,8) de昀椀ni琀椀on is not covered for the (8,9), (9,6) and (9, 10) p-uses.
The above examples imply that APU+C is stronger than branch coverage but ACU+P may be weaker than, or
incomparable to, branch coverage.
All De昀椀ni琀椀ons Strategy (AD) : The all de昀椀ni琀椀ons strategy asks only every de昀椀ni琀椀on of every variable be covered by
atleast one use of that variable, be that use a computa琀椀onal use or a predicate use.
For variable Z: Path (1,3,4,5,6,7,8, . . .) sa琀椀s昀椀es this criterion for variable Z, whereas any entry/exit path
sa琀椀s昀椀es it for variable V.
From the de昀椀ni琀椀on of this strategy we would expect it to be weaker than both ACU+P and APU+C.
1. All Predicate Uses (APU), All Computa琀椀onal Uses (ACU) Strategies : The all predicate uses
strategy is derived from APU+C strategy by dropping the requirement that we include a c- use
for the variable if there are no p-uses for the variable. The all computa琀椀onal uses strategy is
derived from ACU+P strategy by dropping the requirement that we include a p-use for the
variable if there are no c-uses for the variable.
It is intui琀椀vely obvious that ACU should be weaker than ACU+P and that APU should be weaker than APU+C.
52
Figure 3.12compares path-昀氀ow and data-昀氀ow tes琀椀ng strategies. The arrows denote that the strategy at the
arrow's tail is stronger than the strategy at the arrow's head
53
o The debugger 昀椀rst limits her scope to those prior statements that could have
caused the faulty value at statement i (the slice) and then eliminates from
further considera琀椀on those statements that tes琀椀ng has shown to be correct.
o Debugging can be modeled as an itera琀椀ve procedure in which slices are further
re昀椀ned by dicing, where the dicing informa琀椀on is obtained from ad hoc tests
aimed primarily at elimina琀椀ng possibili琀椀es. Debugging ends when the dice has
been reduced to the one faulty statement.
54
UNIT III
DOMAIN TESTING
Domain Tes琀椀ng:-domains and paths, Nice & ugly domains, domain tes琀椀ng, domains and
interfaces tes琀椀ng, domain and interface tes琀椀ng, domains and testability.
INTRODUCTION:
o Domain: In mathema琀椀cs, domain is a set of possible values of
an independent variable or the variables of a func琀椀on.
o Programs as input data classi昀椀ers: domain tes琀椀ng a琀琀empts to determine
whether the classi昀椀ca琀椀on is or is not correct.
o Domain tes琀椀ng can be based on speci昀椀ca琀椀ons or
equivalent implementa琀椀on informa琀椀on.
o If domain tes琀椀ng is based on speci昀椀ca琀椀ons, it is a func琀椀onal test technique.
o If domain tes琀椀ng is based implementa琀椀on details, it is a structural test technique.
o For example, you're doing domain tes琀椀ng when you check extreme values
of an input variable.
All inputs to a program can be considered as if they are numbers. For example, a character string can be
treated as a number by concatena琀椀ng bits and looking at them as if they were a binary integer. This is the
view in domain tes琀椀ng, which is why this strategy has a mathema琀椀cal 昀氀avor.
o Before doing whatever it does, a rou琀椀ne must classify the input and set
it moving on the right path.
o An invalid input (e.g., value too big) is just a special processing case
called 'reject'.
o The input then passes to a hypothe琀椀cal subrou琀椀ne rather than on calcula琀椀ons.
o In domain tes琀椀ng, we focus on the classi昀椀ca琀椀on aspect of the rou琀椀ne rather
than on the calcula琀椀ons.
55
A DOMAIN CLOSURE:
o A domain boundary is closed with respect to a domain if the points on the
boundary belong to the domain.
o If the boundary points belong to some other domain, the boundary is said to be
open.
o Figure 4.2 shows three situa琀椀ons for a one-dimensional domain - i.e., a domain
de昀椀ned over one input variable; call it x
56
The importance of domain closure is that incorrect closure bugs are frequent domain bugs. For example, x >= 0 when x >
0 was intended
Domain Errors:
Double Zero Representa琀椀on: In computers or Languages that have a
dis琀椀nct posi琀椀ve and nega琀椀ve zero, boundary errors for nega琀椀ve zero are
common.
Floa琀椀ng point zero check: A 昀氀oa琀椀ng point number can equal zero only if
the previous de昀椀ni琀椀on of that number set it to zero or if it is subtracted
from itself or mul琀椀plied by zero. So the 昀氀oa琀椀ng point zero check to be
done against an epsilon value.
57
o Co-incidental Correctness: Domain tes琀椀ng isn't good at 昀椀nding bugs for which
the outcome is correct for the wrong reasons. If we're plagued by coincidental
correctness we may misjudge an incorrect boundary. Note that this implies
weakness for domain tes琀椀ng when dealing with rou琀椀nes that have binary
outcomes (i.e., TRUE/FALSE)
58
o Func琀椀onal Homogeneity of Bugs: Whatever the bug is, it will not change the
func琀椀onal form of the boundary predicate. For example, if the predicate is ax >=
b, the bug will be in the value of a or b but it will not change the predicate to
ax
>= b,
say.
o Linear Vector Space: Most papers on domain tes琀椀ng, assume linear boundaries -
not a bad assump琀椀on because in prac琀椀ce most boundary predicates are linear.
o Loop Free So昀琀ware: Loops are problema琀椀c for domain tes琀椀ng. The trouble with
loops is that each itera琀椀on can result in a di昀昀erent predicate expression (a昀琀er
interpreta琀椀on), which means a possible domain boundary change.
NICE DOMAINS:
o Where do these domains come from?
Domains are and will be de昀椀ned by an imperfect itera琀椀ve process aimed at achieving (user, buyer, voter) sa琀椀sfac琀椀on.
o Implemented domains can't be incomplete or inconsistent. Every input will be
processed (rejec琀椀on is a process), possibly forever. Inconsistent domains will be
made consistent.
o Conversely, speci昀椀ed domains can be incomplete and/or inconsistent.
Incomplete in this context means that there are input vectors for which no path
is speci昀椀ed, and inconsistent means that there are at least two contradictory
speci昀椀ca琀椀ons over the same segment of the input space.
o Some important proper琀椀es of nice domains are: Linear, Complete, Systema琀椀c,
And Orthogonal, Consistently closed, Convex and simply connected.
o To the extent that domains have these proper琀椀es domain tes琀椀ng is easy as
tes琀椀ng gets.
o The bug frequency is lesser for nice domain than for ugly domains.
59
COMPLETE BOUNDARIES:
o Nice domain boundaries are complete in that they span the number space from
plus to minus in昀椀nity in all dimensions.
o Figure 4.4 shows some incomplete boundaries. Boundaries A and E have gaps.
o Such boundaries can come about because the path that hypothe琀椀cally
corresponds to them is unachievable, because inputs are constrained in such a
way that such values can't exist, because of compound predicates that de昀椀ne a
single boundary, or because redundant predicates convert such boundary values
into a null set.
o The advantage of complete boundaries is that one set of tests is needed to
con昀椀rm the boundary no ma琀琀er how many domains it bounds.
o If the boundary is chopped up and has holes in it, then every segment of that
boundary must be tested for every domain it bounds.
SYSTEMATIC BOUNDARIES:
o Systema琀椀c boundary means that boundary inequali琀椀es related by a simple
func琀椀on such as a constant.
In Figure 4.3 for example, the domain boundaries for u and v di昀昀er only by a
constant.
60
ORTHOGONAL BOUNDARIES:
o Two boundary sets U and V (See Figure 4.3) are said to be orthogonal if every
inequality in V is perpendicular to every inequality in U.
o If two boundary sets are orthogonal, then they can be tested independently
o In Figure 4.3 we have six boundaries in U and four in V. We can con昀椀rm the
boundary proper琀椀es in a number of tests propor琀椀onal to 6 + 4 = 10 (O(n)). If we
琀椀lt the boundaries to get Figure 4.5,
o we must now test the intersec琀椀ons. We've gone from a linear number of cases
to a quadra琀椀c: from O(n) to O(n2).
61
CLOSURE CONSISTENCY:
o Figure 4.6 shows another desirable domain property: boundary closures are
consistent and systema琀椀c.
o The shaded areas on the boundary denote that the boundary belongs to the
domain in which the shading lies - e.g., the boundary lines belong to the domains
on the right.
o Consistent closure means that there is a simple pa琀琀ern to the closures - for
example, using the same rela琀椀onal operator for all boundaries of a set of parallel
boundaries.
CONVEX:
o A geometric 昀椀gure (in any number of dimensions) is convex if you can take two
arbitrary points on any two di昀昀erent boundaries, join them by a line and all
points on that line lie within the 昀椀gure.
o Nice domains are convex; dirty domains aren't.
o You can smell a suspected concavity when you see phrases such as: ". . . except if
. . .," "However . . .," ". . . but not......" In programming, it's o昀琀en the buts in the speci昀椀ca琀椀on that kill you.
SIMPLY CONNECTED:
o Nice domains are simply connected; that is, they are in one piece rather than
pieces all over the place interspersed with other domains.
o Simple connec琀椀vity is a weaker requirement than convexity; if a domain is
convex it is simply connected, but not vice versa.
o Consider domain boundaries de昀椀ned by a compound predicate of the (Boolean)
form ABC. Say that the input space is divided into two domains, one de昀椀ned by
62
UGLY DOMAINS:
o Some domains are born ugly and some are ugli昀椀ed by bad speci昀椀ca琀椀ons.
o Every simpli昀椀ca琀椀on of ugly domains by programmers can be either good or bad.
o Programmers in search of nice solu琀椀ons will "simplify" essen琀椀al complexity out
of existence. Testers in search of brilliant insights will be blind to essen琀椀al
complexity and therefore miss important cases.
o If the ugliness results from bad speci昀椀ca琀椀ons and the programmer's
simpli昀椀ca琀椀on is harmless, then the programmer has made ugly good.
o But if the domain's complexity is essen琀椀al (e.g., the income tax code),
such "simpli昀椀ca琀椀ons" cons琀椀tute bugs.
o Nonlinear boundaries are so rare in ordinary programming that there's no
informa琀椀on on how programmers might "correct" such boundaries if they're
essen琀椀al.
63
DOMAIN TESTING:
64
The closure can be wrong (i.e., assigned to the wrong domain) or the boundary (a point in this case) can be shi昀琀ed
one way or the other, we can be missing a boundary, or we can have an extra boundary.
1. Figure 4.13 shows possible domain bugs for a one-dimensional open domain
boundary.
2. In Figure 4.13a we assumed that the boundary was to be open for A. The bug
we're looking for is a closure error, which converts > to >= or < to <= (Figure
4.13b). One test (marked x) on the boundary point detects this bug because
processing for that point will go to domain A rather than B.
3. In Figure 4.13c we've su昀昀ered a boundary shi昀琀 to the le昀琀. The test point we used
for closure detects this bug because the bug forces the point from the B domain,
where it should be, to A processing. Note that we can't dis琀椀nguish between a
shi昀琀 and a closure error, but we do know that we have a bug.
66
67
1. Figure 4.15 shows possible domain boundary bugs for a two-dimensional domain.
2. A and B are adjacent domains and the boundary is closed with respect to A,
which means that it is open with respect to B.
68
1. Shi昀琀ed Boundary: In Figure 4.15b the bug is a shi昀琀 up, which converts
part of domain B into A processing, denoted by A'. This result is caused by
an incorrect constant in a predicate, such as x + y >= 17 when x + y >= 7
was intended. The o昀昀 point (closed o昀昀 outside) catches this bug. Figure
4.15c shows a shi昀琀 down that is caught by the two on points.
2. Tilted Boundary: A 琀椀lted boundary occurs when coe昀케cients in the
boundary inequality are wrong. For example, 3x + 7y > 17 when 7x + 3y >
17 was intended. Figure 4.15d has a 琀椀lted boundary, which creates erroneous domain
segments A' and B'. In this example the bug is caught by the le昀琀 on point.
INTRODUCTION:
o Recall that we de昀椀ned integra琀椀on tes琀椀ng as tes琀椀ng the correctness of the
interface between two otherwise correct components.
69
CLOSURE COMPATIBILITY:
o Assume that the caller's range and the called domain spans the same numbers -
for example, 0 to 17.
o Figure 4.16 shows the four ways in which the caller's range closure and the
called's domain closure can agree.
o The thick line means closed and the thin line means open. Figure 4.16 shows the
four cases consis琀椀ng of domains that are closed both on top (17) and bo琀琀om (0),
open top and closed bo琀琀om, closed top and open bo琀琀om, and open top and
bo琀琀om.
disagree about closure. Not all of them are necessarily bugs. The four cases
in which a
caller boundary is open and the called is closed (marked with a "?") are probably not buggy. It means that the caller
will not supply such values but the called can accept them.
SPAN COMPATIBILITY:
o Figure 4.18 shows three possibly harmless span incompa琀椀bili琀椀es.
71
72
UNIT IV
PATHS, PATH PRODUCTS AND REGULAR EXPRESSIONS
MOTIVATION:
o Flow graphs are being an abstract representa琀椀on of programs.
o Any ques琀椀on about a program can be cast into an equivalent ques琀椀on about
an appropriate 昀氀owgraph.
o Most so昀琀ware development, tes琀椀ng and debugging tools use 昀氀ow graphs
analysis techniques.
PATH PRODUCTS:
o Normally 昀氀ow graphs used to denote only control 昀氀ow connec琀椀vity.
o The simplest weight we can give to a link is a name.
o Using link names as weights, we then convert the graphical 昀氀ow graph into an
equivalent algebraic like expressions which denotes the set of all possible paths
from entry to exit for the 昀氀ow graph.
o Every link of a graph can be given a name.
o The link name will be denoted by lower case italic le琀琀ers In tracing a path or
path segment through a 昀氀ow graph, you traverse a succession of link
names.
o The name of the path or path segment that corresponds to those links is
expressed naturally by concatena琀椀ng those link names.
o For example, if you traverse links a,b,c and d along some path, the name for that
path segment is abcd. This path name is also called a path product. Figure 5.1
shows some examples:
73
PATH PRODUCTS:
o The name of a path that consists of two successive path segments is
conveniently expressed by the concatena琀椀on or Path Product of the segment
names.
o For example, if X and Y are de昀椀ned as X=abcde,Y=fghij,then the
path corresponding to X followed by Y is denoted by
XY=abcdefghij
o Similarly,
YX=fghijabcde
aX=aabcde
Xa=abcdea
XaX=abcdeaabcde
o If X and Y represent sets of paths or path expressions, their product represents
the set of paths that can be obtained by following every element of X by any
element of Y in all possible ways. For example,
o X = abc + def + ghi
74
o Y = uvw + z
Then,
XY = abcuvw + defuvw + ghiuvw + abcz + defz + ghiz
o If a link or segment name is repeated, that fact is denoted by an
exponent. The exponent's value denotes the number of repe琀椀琀椀ons:
o a1 = a; a2 = aa; a3 = aaa; an = aaaa . . . n 琀椀mes.
Similarly, if X = abcde then
X1 = abcde
X2 = abcdeabcde = (abcde)2
X3 = abcdeabcdeabcde = (abcde)2abcde
= abcde(abcde)2 = (abcde)3
o The path product is not commuta琀椀ve (that is XY!=YX).
o The path product is Associa琀椀ve.
RULE 1: A(BC)=(AB)C=ABC
where A,B,C are path names, set of path names or path expressions.
o The zeroth power of a link name, path product, or path expression is also
needed for completeness. It is denoted by the numeral "1" and denotes the
"path" whose length is zero - that is, the path that doesn't have any links.
o a0 = 1
o X0 = 1
PATH SUMS:
o The "+" sign was used to denote the fact that path names were part of the same
set of paths.
o The "PATH SUM" denotes paths in parallel between nodes.
o Links a and b in Figure 5.1a are parallel paths and are denoted by a + b. Similarly,
links c and d are parallel paths between the next two nodes and are denoted by
c + d.
o The set of all paths between nodes 1 and 2 can be thought of as a set of
parallel paths and denoted by eacf+eadf+ebcf+ebdf.
o If X and Y are sets of paths that lie between the same pair of nodes, then
X+Y denotes the UNION of those set of paths. For example, in Figure 5.2:
DISTRIBUTIVE LAWS:
o The product and sum opera琀椀ons are distribu琀椀ve, and the ordinary rules of
mul琀椀plica琀椀on apply; that is
RULE 4: A(B+C)=AB+AC and (B+C)D=BD+CD
o Applying these rules to the below Figure 5.1a yields
o e(a+b)(c+d)f=e(ac+ad+bc+bd)f = eacf+eadf+ebcf+ebdf
ABSORPTION RULE:
o If X and Y denote the same set of paths, then the union of these sets is
unchanged; consequently,
RULE 5: X+X=X (Absorp琀椀on Rule)
o If a set consists of paths names and a member of that set is added to it, the
"new" name, which is already in that set of names, contributes nothing and can
be ignored.
o For example,
o if X=a+aa+abc+abcd+def then
X+a = X+aa = X+abc = X+abcd = X+def = X
It follows that any arbitrary sum of iden琀椀cal path expressions reduces to the same path expression.
LOOPS:
Loops can be understood as an in昀椀nite set of parallel paths. Say that the loop consists of a single link b.
then the set of all paths through that loop point is b0+b1+b2+b3+b4+b5+..............
RULES 6 - 16:
o The following rules can be derived from the previous rules:
76
o RULE 6: Xn + Xm = Xn if n>m
RULE 6: Xn + Xm = Xm if m>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+ RULE 11: 1 + 1 = 1
RULE 12: 1X = X1 = X
Following or preceding a set of paths by a path of zero length does not change the set.
RULE 13: 1n = 1n = 1* = 1+ = 1
No ma琀琀er how o昀琀en you traverse a path of zero length,It is a path of zero length. RULE 14: 1++1 = 1*=1
The null set of paths is denoted by the numeral 0. it obeys the following
rules:
RULE 15: X+0=0+X=X
RULE 16: 0X=X0=0
If you block the paths of a graph for or a昀琀 by a graph that has no paths , there won’t be any paths.
REDUCTION PROCEDURE:
o The cross - term step is the fundamental step of the reduc琀椀on algorithm.
78
o In the 昀椀rst way, we remove the self-loop and then mul琀椀ply all outgoing links
by Z*.
o In the second way, we split the node into two equivalent nodes, call them A and
A' and put in a link between them whose path expression is Z*. Then we remove
node A' using steps 4 and 5 to yield outgoing links whose path expressions are
Z*X and Z*Y.
79
Removing node 4 leads to a loop term. The graph has now been replaced with the following
equivalent simpler graph:
o You can prac琀椀ce by applying the algorithm on the following 昀氀owgraphs and
generate their respec琀椀ve path expressions:
81
Each link represents a single link and consequently is given a weight of "1" to start. Let’s
say the outer loop will be taken exactly four 琀椀mes and inner Loop Can be taken zero or
three 琀椀mes Its path expression, with a li琀琀le work, is:
Path expression: a(b+c)d{e(昀椀)*fgj(m+l)k}*e(昀椀)*fgh
A: The 昀氀ow graph should be annotated by replacing the link name
with the maximum of paths through that link (1) and also note the
number of 琀椀mes for looping.
B: Combine the 昀椀rst pair of parallel loops outside the loop and
also the pair in the outer loop.
C: Mul琀椀ply the things out and remove nodes to clear the clu琀琀er.
83
13 = 10 + 11 + 12 + 13 = 1 + 1 + 1 + 1 = 4
2. E: Mul琀椀ply the link weights inside the loop: 1 X 4 = 4
3. F: Evaluate the loop by mul琀椀plying the link wieghts: 2 X 4 = 8.
4. G: Simpifying the loop further results in the total maximum number
of paths in the 昀氀owgraph:
2 X 84 X 2 = 32,768.
84
Alterna琀椀vely, you could have subs琀椀tuted a "1" for each link in the path expression and then simpli昀椀ed, 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
This is the same result we got graphically.Actually, the outer loop should be taken exactly four 琀椀mes. That doesn't
mean it will be taken zero or four 琀椀mes. Consequently, there is a super昀氀uous "4" on the outlink in the last step.
Therefore the maximum number of di昀昀erent paths is 8192 rather than 32,768.
STRUCTURED FLOWGRAPH:
Structured code can be de昀椀ned in several di昀昀erent ways that do not involve ad-hoc rules such as not using
GOTOs.
A structured 昀氀owgraph is one that can be reduced to a single link by successive applica琀椀on of the
transforma琀椀ons of Figure 5.7.
The node-by-node reduc琀椀on procedure can also be used as a test for structured code.Flow graphs that DO NOT
contain one or more of the graphs shown below (Figure 5.8) as subgraphs are structured.
1. Jumping into loops
2. Jumping out of loops
3. Branching into decisions
4. Branching out of decisions
85
The values of the weights are the number of members in a set of paths.
EXAMPLE:
Applying the arithme琀椀c to the earlier example gives us the iden琀椀cal
steps unitl step 3 (C) as below:
86
If you observe the original graph, it takes at least two paths to cover
and that it can be done in two paths.
If you have fewer paths in your test plan than this minimum
you probably haven't covered. It's another check.
This ques琀椀on can be answered under suitable assump琀椀ons primarily that all probabili琀椀es involved are
independent, which is to say that all decisions are independent and uncorrelated. We use the same algorithm as
before: node-by-node removal of uninteres琀椀ng nodes.
Weights, Notations and Arithmetic:
Probabili琀椀es can come into the act only at decisions (including decisions
associated with loops).
Annotate each outlink with a weight equal to the probability of going in
that direc琀椀on.
Evidently, the sum of the outlink probabili琀椀es must equal 1
For a simple loop, if the loop will be taken a mean of N 琀椀mes, 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 arithme琀椀c rules are those of ordinary arithme琀椀c.
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.
1. If you can do something either from column A with a probability
of PA or from column B with a probability P B, then the probability
that you do either is PA + PB.
2. For the series case, if you must do both things, and their
probabili琀椀es are independent (as assumed), then the probability
that you do both is the product of their probabili琀椀es.
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.
88
Following the above rule, all we've done is replace the outgoing
probability with 1 - so why the complicated rule? A昀琀er a few steps in
which you've removed nodes, combined parallel terms, removed loops
and the like, you might 昀椀nd something like this:
89
which is what we've postulated for any decision. In other words, division by 1 - P L
renormalizes the outlink probabili琀椀es so that their sum equals unity a昀琀er the loop is
removed.
EXAMPLE:
Here is a complicated bit of logic. We want to know the
probability associated with cases A, B, and C.
Let us do this in three parts, star琀椀ng with case A. Note that the sum of
the probabili琀椀es at each decision node is equal to 1. Start by throwing
away anything that isn't on the way to case A, and then apply the
reduc琀椀on procedure. To avoid clu琀琀er, we usually leave out probabili琀椀es
equal to 1.
CASE A:
90
Case B is simpler:
These checks. It's a good idea when doing this sort of thing to calculate all
the probabili琀椀es and to verify that the sum of the rou琀椀ne's exit
probabili琀椀es does equal 1.
If it doesn't, then you've made calcula琀椀on error or, more likely, you've
le昀琀 out some bra How about path probabili琀椀es? That's easy. Just trace
the path of interest and mul琀椀ply the probabili琀椀es as you go.
Alterna琀椀vely, write down the path name and do the indicated arithme琀椀c
opera琀椀on.
91
EXAMPLE:
1. Start with the original 昀氀ow graph annotated with probabili琀椀es and processing 琀椀me.
2.Combine the parallel links of the outer loop. The result is just the mean of the
processing 琀椀mes for the links because there aren't any other links leaving the 昀椀rst
node. Also combine the pair of links at the beginning of the 昀氀ow graph.
92
4. Use the cross-term step to eliminate a node and to create the inner self -
loop. 5.Finally, you can get the mean processing 琀椀me, by using the arithme琀椀c
rules as follows:
PUSH/POP, GET/RETURN:
This model can be used to answer several di昀昀erent ques琀椀ons that can turn up in debugging. It can also help
decide which test cases to design.
The ques琀椀on 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 opera琀椀ons to which this model applies: GET/RETURN a
resource block.
OPEN/CLOSE a 昀椀le.
START/STOP a device or process.
93
94
95
G(G + R)G(GR)*GGR*R
= G(G + R)G3R*R
= (G + R)G3R*
= (G4 + G2)R*
This expression speci昀椀es the condi琀椀ons under which the resources will be
balanced on leaving the rou琀椀ne.
If the upper branch is taken at the 昀椀rst decision, the second loop must
be taken four 琀椀mes.
If the lower branch is taken at the 昀椀rst decision, the second loop must
be taken twice.
For any other values, the rou琀椀ne will not balance. Therefore, the 昀椀rst
loop does not have to be instrumented to verify this behavior because its
impact should be nil.
96
THE PROBLEM:
o The generic 昀氀ow-anomaly detec琀椀on problem (note: not just data-昀氀ow
anomalies, but any 昀氀ow anomaly) is that of looking for a speci昀椀c sequence
of op琀椀ons considering all possible paths through a rou琀椀ne.
o Let the opera琀椀ons be SET and RESET, denoted by s and r respec琀椀vely, 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).
o Some more applica琀椀on examples:
1. A 昀椀le can be opened (o), closed (c), read (r), or wri琀琀en (w). If the 昀椀le is
read or wri琀琀en to a昀琀er it's been closed, the sequence is nonsensical.
Therefore, cr and cw are anomalous. Similarly, if the 昀椀le is read before
it's been wri琀琀en, just a昀琀er opening, we may have a bug. Therefore, or
is also anomalous. Furthermore, oo and cc, though not actual bugs, are
a waste of 琀椀me and therefore should also be examined.
2. A tape transport can do a rewind (d), fast-forward (f), read (r), write (w),
stop (p), and skip (k). There are rules concerning the use of the transport;
for example, you cannot go from rewind to fast-forward without an
intervening stop or from rewind or fast-forward to read or write without
an intervening stop. The following sequences are anomalous: df, dr, dw,
fd, and fr. Does the 昀氀owgraph lead to anomalous sequences on any path?
If so, what sequences and under what circumstances?
3. The data-昀氀ow anomalies discussed in Unit 4 requires us to detect
the dd, dk, kk, and ku sequences. Are there paths with anomalous
data 昀氀ows?
THE METHOD:
o Annotate each link in the graph with the appropriate operator or the
null operator 1.
o Simplify things to the extent possible, using the fact that a + a = a and 12 = 1.
o You now have a regular expression that denotes all the possible sequences
of operators in that graph. You can now examine that regular expression
for the sequences of interest.
o 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) AB nC, then T will appear in
AB2C. (HUANG's Theorem)
As an example, let
o A = pp
B = srr
C = rp
T = ss
97
A = p + pp + ps
B = psr + ps(r + ps)
C = rp
T = P4
Is it obvious that there is a p4 sequence in ABnC? The theorem states that we have only to look at
LIMITATIONS:
o Huang's theorem can be easily generalized to cover sequences of greater length
than two characters. Beyond three characters, though, things get complex and
this method has probably reached its u琀椀litarian limit for manual applica琀椀on.
o There are some nice theorems for 昀椀nding sequences that occur at the beginnings
and ends of strings but no nice algorithms for 昀椀nding strings buried in an
expression.
o Sta琀椀c 昀氀ow analysis methods can't determine whether a path is or is not
achievable. Unless the 昀氀ow analysis includes symbolic execu琀椀on or similar
techniques, the impact of unachievable paths will not be included in the analysis.
The 昀氀ow-anomaly applica琀椀on, for example, doesn't tell us that there will be a 昀氀ow anomaly - it tells us
that if the path is achievable, then there will be a 昀氀ow anomaly. Such analy琀椀cal problems go away, of
course, if you take the trouble to design rou琀椀nes for which all paths are achievable.
98
UNIT IV(Part-II)
LOGIC BASED TESTING
INTRODUCTION:
o The func琀椀onal requirements of many programs can be speci昀椀ed by decision
tables, which provide a useful basis for program and test design.
o Consistency and completeness can be analyzed by using boolean algebra, which
can also be used as a basis for test design. Boolean algebra is trivialized by using
Karnaugh-Veitch charts.
o "Logic" is one of the most o昀琀en used words in programmers' vocabularies but
one of their least used techniques.
o Boolean algebra is to logic as arithme琀椀c is to mathema琀椀cs. Without it, the tester
or programmer is cut o昀昀 from many test and design techniques and tools that
incorporate those techniques.
o Logic has been, for several decades, the primary tool of hardware logic designers.
o Many test methods developed for hardware logic can be adapted to so昀琀ware
logic tes琀椀ng. Because hardware tes琀椀ng automa琀椀on is 10 to 15 years ahead of
so昀琀ware tes琀椀ng automa琀椀on, hardware tes琀椀ng methods and its associated
theory is a fer琀椀le ground for so昀琀ware tes琀椀ng methods.
o As programming and test techniques have improved, the bugs have shi昀琀ed
closer to the process front end, to requirements and their speci昀椀ca琀椀ons. These
bugs range from 8% to 30% of the total and because they're 昀椀rst-in and last-out,
they're the costliest of all.
o The trouble with speci昀椀ca琀椀ons is that they're hard to express.
o Boolean algebra (also known as the senten琀椀al calculus) is the most basic of all
logic systems.
o Higher-order logic systems are needed and used for formal speci昀椀ca琀椀ons.
o Much of logical analysis can be and is embedded in tools. But these tools
incorporate methods to simplify, transform, and check speci昀椀ca琀椀ons, and the
methods are to a large extent based on boolean algebra.
99
DECISION TABLES:
Figure 6.1 is a limited - entry decision table. It consists of four areas called the condi琀椀on
stub, the condi琀椀on entry, the ac琀椀on stub, and the ac琀椀on entry.
Each column of the table is a rule that speci昀椀es the condi琀椀ons under which the ac琀椀ons
named in the ac琀椀on stub will take place.
The condi琀椀on stub is a list of names of condi琀椀ons.
100
Ac琀椀on 1 will take place if condi琀椀ons 1 and 2 are met and if condi琀椀ons 3 and 4 are not met (rule
1) or if condi琀椀ons 1, 3, and 4 are met (rule 2).
"Condi琀椀on" is another word for predicate.
Decision-table uses "condi琀椀on" and "sa琀椀s昀椀ed" or "met". Let us use "predicate" and
TRUE / FALSE.
Now the above transla琀椀ons become:
1. Ac琀椀on 1 will be taken if predicates 1 and 2 are true and if predicates 3 and 4
are false (rule 1), or if predicates 1, 3, and 4 are true (rule 2).
2. Ac琀椀on 2 will be taken if the predicates are all false, (rule 3).
3. Ac琀椀on 3 will take place if predicate 1 is false and predicate 4 is true (rule 4).
In addi琀椀on to the stated rules, we also need a Default Rule that speci昀椀es the default
ac琀椀on to be taken when all other rules fail. The default rules for Table in Figure 6.1 is
shown in Figure 6.3
DECISION-TABLE PROCESSORS:
o Decision tables can be automa琀椀cally translated into code and, as such, are a
higher-order language
o If the rule is sa琀椀s昀椀ed, the corresponding ac琀椀on takes place
o Otherwise, rule 2 is tried. This process con琀椀nues un琀椀l either a sa琀椀s昀椀ed rule
results in an ac琀椀on or no rule is sa琀椀s昀椀ed and the default ac琀椀on is taken
o Decision tables have become a useful tool in the programmers kit, in
business data processing.
101
1. The speci昀椀ca琀椀on is given as a decision table or can be easily converted into one.
2. The order in which the predicates are evaluated does not a昀昀ect interpreta琀椀on of
the rules or the resul琀椀ng ac琀椀on - i.e., an arbitrary permuta琀椀on of the predicate
order will not, or should not, a昀昀ect which ac琀椀on takes place.
3. The order in which the rules are evaluated does not a昀昀ect the resul琀椀ng ac琀椀on -
i.e., an arbitrary permuta琀椀on of rules will not, or should not, a昀昀ect which ac琀椀on
takes place.
4. Once a rule is sa琀椀s昀椀ed and an ac琀椀on selected, no other rule need be examined.
5. If several ac琀椀ons can result from sa琀椀sfying a rule, the order in which the ac琀椀ons
are executed doesn't ma琀琀er.
102
CONDITION A
CONDITION B
CONDITION C YES YES YES NO I NO I NO I
CONDITION D YES I NO I YES I YES I NO NO
YES I NO YES NO
PATH EXPRESSIONS:
GENERAL:
o Logic-based tes琀椀ng is structural tes琀椀ng when it's applied to structure (e.g.,
control 昀氀ow graph of an implementa琀椀on); it's func琀椀onal tes琀椀ng when it's applied
to a speci昀椀ca琀椀on.
104
BOOLEAN ALGEBRA:
o STEPS:
1. Label each decision with an uppercase le琀琀er that represents the truth
value of the predicate. The YES or TRUE branch is labeled with a le琀琀er
(say A) and the NO or FALSE branch with the same le琀琀er overscored (say
).
2. The truth value of a path is the product of the individual labels.
Concatena琀椀on or products mean "AND". For example, the straight-
through path of Figure 6.5, which goes via nodes 3, 6, 7, 8, 10, 11, 12, and
2, has a truth value of ABC. The path via nodes 3, 6, 7, 9 and 2 has a value
of .
3. If two or more paths merge at a node, the fact is expressed by use of a
plus sign (+) which means "OR".
105
o There are only two numbers in boolean algebra: zero (0) and one (1). One means
"always true" and zero means "always false".
o RULES OF BOOLEAN ALGEBRA:
Boolean algebra has three operators: X (AND), + (OR) and (NOT)
X : meaning AND. Also called mul琀椀plica琀椀on. A statement such as AB (A X
B) means "A and B are both true". This symbol is usually le昀琀 out as in
ordinary algebra.
+ : meaning OR. "A + B" means "either A is true or B is true or both".
meaning NOT. Also nega琀椀on or complementa琀椀on. This is read as either "not A" or
"A bar". The en琀椀re expression under the bar is negated.
The following are the laws of boolean algebra:
In all of the above, a le琀琀er can represent a single sentence or an en琀椀re boolean algebra expression.
Individual le琀琀ers in a boolean algebra expression are called Literals (e.g. A,B) The product of
several literals is called a product term (e.g., ABC, DE).
An arbitrary boolean expression that has been mul琀椀plied out so that it consists of the sum of products (e.g., ABC +
DEF + GH) is said to be in sum-of-products form.
The result of simpli昀椀ca琀椀ons (using the rules above) is again in the sum of product form and each product term in such a
simpli昀椀ed version is called a prime implicant. For example, ABC + AB
+ DEF reduce by rule 20 to AB + DEF; that is, AB and DEF are prime implicants. The path
expressions of Figure 6.5 can now be simpli昀椀ed by applying the rules.
The following are the laws of boolean algebra:
106
Similarly,
The devia琀椀on from the speci昀椀ca琀椀on is now clear. The func琀椀ons should have been:
Loops complicate things because we may have to solve a boolean equa琀椀on to determine what predicate value
combina琀椀ons lead to where.
KV CHARTS:
INTRODUCTION:
o If you had to deal with expressions in four, 昀椀ve, or six variables, you could get
bogged down in the algebra and make as many errors in designing test cases as
there are bugs in the rou琀椀ne you're tes琀椀ng.
o Karnaugh-Veitch chart reduces boolean algebraic manipula琀椀ons to graphical
trivia.
o Beyond six variables these diagrams get cumbersome and may not be e昀昀ec琀椀ve.
SINGLE VARIABLE:
o Figure 6.6 shows all the boolean func琀椀ons of a single variable and their
equivalent representa琀椀on as a KV chart.
107
108
109
on.
111
o Given two charts over the same variables, arranged the same way, their product
is the term by term product, their sum is the term by term sum, and the
nega琀椀on of a chart is go琀琀en by reversing all the 0 and 1 entries in the chart.
OR
THREE VARIABLES:
o KV charts for three variables are shown below.
o As before, each box represents an elementary term of three variables with a bar
appearing or not appearing according to whether the row-column heading for
that box is 0 or 1.
o A three-variable chart can have groupings of 1, 2, 4, and 8 boxes.
o A few examples will illustrate the principles:
112
113
UNIT-V
STATES, STATE GRAPHS, AND TRANSITION TESTING
State, State Graphs and Transi琀椀on tes琀椀ng:- state graphs, good & bad state graphs, state
tes琀椀ng, Testability 琀椀ps.
Graph Matrices and Applica琀椀on:-Mo琀椀va琀椀onal overview, matrix of graph, rela琀椀ons, power of
a matrix, node reduc琀椀on algorithm, building tools. ( Student should be given an exposure to a tool
like JMeter or Win-runner).
Introduction
The 昀椀nite state machine is as fundamental to so昀琀ware engineering as boolean algebra
to logic.
State tes琀椀ng strategies are based on the use of 昀椀nite state machine models for so昀琀ware
structure, so昀琀ware behavior, or speci昀椀ca琀椀ons of so昀琀ware behavior.
Finite state machines can also be implemented as table-driven so昀琀ware, in which case
they are a powerful design op琀椀on.
State Graphs
A state is de昀椀ned as: “A combina琀椀on of circumstances or a琀琀ributes belonging for the
琀椀me being to a person or thing.”
For example, a moving automobile whose engine is running can have the following
states with respect to its transmission.
Reverse gear
Neutral gear
First gear
Second gear
Third gear
Fourth gear
State graph -
Example
For example, a program that detects the character sequence “ZCZC” can be in
the following states.
Neither ZCZC nor any part of it has been detected.
Z has been detected.
ZC has been detected.
ZCZ has been detected.
ZCZC has been detected.
States are represented by Nodes. State are numbered or may iden琀椀昀椀ed by words or whatever else is convenient.
114
The input that causes the transi琀椀on are marked on the link; that is, the inputs are
link weights.
There is one out link from every state for every input.
If several inputs in a state cause a transi琀椀on to the same subsequent state, instead of
drawing a bunch of parallel links we can abbreviate the nota琀椀on by lis琀椀ng the several
inputs as in: “input1, input2, input3………”.
115
116
Important graphs
117
Equivalent States
Two states are Equivalent if every sequence of inputs star琀椀ng from one state produces
exactly the same sequence of outputs when started from the other state. This no琀椀on
can also be extended to set of states.
118
TransitionBugs-
unspeci昀椀ed and contradictory Transi琀椀ons
Every input-state combina琀椀on must have a speci昀椀ed transi琀椀on.
If the transi琀椀on is impossible, then there must be a mechanism that prevents the input
from occurring in that state.
Exactly one transi琀椀on must be speci昀椀ed for every combina琀椀on of input and state.
A program can’t have contradic琀椀ons or ambigui琀椀es.
Ambigui琀椀es are impossible because the program will do something for every input. Even
the state does not change, by de昀椀ni琀椀on this is a transi琀椀on to the same state.
Unreachable States
An unreachable state is like unreachable code.
A state that no input sequence can reach.
An unreachable state is not impossible, just as unreachable code is not impossible
There may be transi琀椀ons from unreachable state to other states; there usually
because the state became unreachable as a result of incorrect transi琀椀on.
There are two possibili琀椀es for unreachable states:
o There is a bug; that is some transi琀椀ons are missing.
o The transi琀椀ons are there, but you don’t know about it.
Dead States
A dead state is a state that once entered cannot be le昀琀.
This is not necessarily a bug but it is suspicious.
The states, transi琀椀ons, and the inputs could be correct, there could be no dead or
unreachable states, but the output for the transi琀椀on could be incorrect.
Output ac琀椀ons must be veri昀椀ed independently of states and
transi琀椀ons. State Tes琀椀ng
Impact of Bugs
If a rou琀椀ne is speci昀椀ed as a state graph that has been veri昀椀ed as correct in all details.
Program code or table or a combina琀椀on of both must s琀椀ll be implemented.
A bug can manifest itself as one of the following symptoms:
Wrong number of states.
Wrong transi琀椀ons for a given state-input combina琀椀on.
Wrong output for a given transi琀椀on.
119
Device drivers such as for tapes and discs that have complicated retry and recovery
procedures if the ac琀椀on depends on the state.
Whenever a feature is directly and explicitly implemented as one or more state transi琀椀on tables.
Tool Building
If you build test tools or want to know how they work, sooner or later you will be implemen琀椀ng
or inves琀椀ga琀椀ng analysis rou琀椀nes based on these methods.
It is hard to build algorithms over visual graphs so the proper琀椀es or graph matrices are
fundamental to tool building.
121
A simple weight
A simplest weight we can use is to note that there is or isn’t a connec琀椀on. Let “1” mean
that there is a connec琀椀on and “0” mean that there isn’t.
The arithme琀椀c rules are:
1+1=1 1*1=1
1+0=1 1*0=0
0+0=0 0*0=0
A matrix de昀椀ned like this is called connec琀椀on matrix.
Connection matrix
The connec琀椀on matrix is obtained by replacing each entry with 1 if there is a link and 0 if there
isn’t.
As usual we don’t write down 0 entries to reduce the clu琀琀er.
122
Connection Matrix-continued
Each row of a matrix denotes the out links of the node corresponding to that row.
Each column denotes the in links corresponding to that node.
A branch is a node with more than one nonzero entry in its row.
A junc琀椀on is node with more than one nonzero entry in its column.
A self loop is an entry along the diagonal.
Cyclomatic Complexity
The cycloma琀椀c complexity obtained by subtrac琀椀ng 1 from the total number of entries in each
row and ignoring rows with no entries, we obtain the equivalent number of decisions for each
row. Adding these values and then adding 1 to the sum yields the graph’s cycloma琀椀ccomplexity.
123
Relations
A rela琀椀on is a property that exists between two objects of interest.
For example,
“Node a is connected to node b” or aRb where “R” means “is connected to”.
“a>=b” or aRb where “R” means greater than or equal”.
A graph consists of set of abstract objects called nodes and a rela琀椀on R between the nodes.
If aRb, which is to say that a has the rela琀椀on R to b, it is denoted by a link from a to b.
For some rela琀椀ons we can associate proper琀椀es called as link weights.
Transitive Relations
A rela琀椀on is transi琀椀ve if aRb and bRc implies aRc.
Most rela琀椀ons used in tes琀椀ng are transi琀椀ve.
Examples of transi琀椀ve rela琀椀ons include: is connected to, is greater than or equal to, is less than
or equal to, is a rela琀椀ve of, is faster than, is slower than, takes more 琀椀me than, is a subset of,
includes, shadows, is the boss of.
Examples of intransi琀椀ve rela琀椀ons include: is acquainted with, is a friend of, is a neighbor of,
is lied to, has a du chain between.
Reflexive Relations
A rela琀椀on R is re昀氀exive if, for every a, aRa.
A re昀氀exive rela琀椀on is equivalent to a self loop at every node.
Examples of re昀氀exive rela琀椀ons include: equals, is acquainted with, is a rela琀椀ve of.
Examples of irre昀氀exive rela琀椀ons include: not equals, is a friend of, is on top of, is under.
Symmetric Relations
A rela琀椀on R is symmetric if for every a and b, aRb implies bRa.
A symmetric rela琀椀on mean that if there is a link from a to b then there is also a link from b to a.
124
Antisymmetric Relations
A rela琀椀on R is an琀椀symmetric if for every a and b, if aRb and bRa, then a=b, or they are the same
elements.
Examples of an琀椀symmetric rela琀椀ons: is greater than or equal to, is a subset of, 琀椀me.
Examples of nonan琀椀symmetric rela琀椀ons: is connected to, can be reached from, is greater than,
is a rela琀椀ve of, is a friend of
quivalence Relations
An equivalence rela琀椀on is a rela琀椀on that sa琀椀s昀椀es the re昀氀exive, transi琀椀ve, and symmetric
proper琀椀es.
Equality is the most familiar example of an equivalence rela琀椀on.
If a set of objects sa琀椀sfy an equivalence rela琀椀on, we say that they form an equivalence class
over that rela琀椀on.
The importance of equivalence classes and rela琀椀ons is that any member of the equivalence class
is, with respect to the rela琀椀on, equivalent to any other member of that class.
The idea behind par琀椀琀椀on tes琀椀ng strategies such as domain tes琀椀ng and path tes琀椀ng, is that we
can par琀椀琀椀on the input space into equivalence classes.
Tes琀椀ng any member of the equivalence class is as e昀昀ec琀椀ve as tes琀椀ng them all.
125
entry with
126
n
aij=Σ aik akj
k=1
more generally, given two matrices A and B with entries aik and bkj, respec琀椀vely, their
product is a new matrix C, whose entries are cij, where:
n
Cij=Σ aik bkj
k=1
Partitioning Algorithm
Consider any graph over a transi琀椀ve rela琀椀on. The graph may have loops.
We would like to par琀椀琀椀on the graph by grouping nodes in such a way that every loop is
contained within one group or another.
Such a graph is par琀椀ally ordered.
There are many used for an algorithm that does that:
We might want to embed the loops within a subrou琀椀ne so as to have a resul琀椀ng graph which
is loop free at the top level.
Many graphs with loops are easy to analyze if you know where to break theloops.
While you and I can recognize loops, it’s much harder to program a tool to do it unless
you have a solid algorithm on which to base the tool.
127