0% found this document useful (0 votes)
19 views190 pages

Software Testing Notes

software testing notes for computer science

Uploaded by

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

Software Testing Notes

software testing notes for computer science

Uploaded by

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

Mangayarkarasi College of Arts and Science for Women

Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

STUDY MATERIAL
SOFTWARE TESTING
(II CS)

DEPARTMENT OF COMPUTER APPLICATIONS


IV SEMESTER 2025-2026
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

SOFTWARETESTING
UNIT I
Introduction: Purpose–Productivity and Quality in Software– Testing Vs. Debugging–Model for
Testing–Bugs–Types of Bugs – Testing and Design Style.
UNIT II
Flow / Graphs and Path Testing – Achievable paths – Path instrumentation Application Transaction
Flow Testing Techniques.
UNIT III
Data Flow Testing Strategies - Domain Testing: Domains and Paths – Domains and Interface
Testing.
UNIT IV
Linguistic –Metrics – Structural Metric – Path Products and Path Expressions. Syntax Testing–
Formats–Test Cases
UNIT IV
Logic Based Testing–Decision Tables–Transition Testing–States, State Graph, State Testing.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

SOFTWARE TESTING

LECTURE NOTES

Unit I
(Introduction) : Purpose of Testing - productivity and Quality in software - Testing vs Debugging -
Model for Testing - Bugs - Types of Bugs - Testing and Design Style.

Definition of Software:

Software is a set of instructions, programs, or data that directs a computer on how to perform
specific tasks. It acts as the intermediary between the user and the hardware, enabling the execution
of operations and the functionality of devices.

Types of Software:

 System Software:
Manages and controls the computer hardware so other software can function.
Ex: Windows, macOS, Linux, antivirus

 Application Software:
Performs specific tasks for end-users, designed to solve problems or fulfill particular
needs.
Ex : Microsoft Office, Google Docs, games, media players
 Programming Software:
Provides tools for developers to write, test, and debug other software.
Ex: Python Interpreter

Definition of Testing:
Testing is the process of exercising or evaluating a system or system components by manual or
automated means to verify that it satisfies specified requirements.
The Purpose of Testing:

Testing consumes at least half of the time and work required to produce a functional program.
o MYTH: Good programmers write code without bugs. (It’s wrong!!!)
o History says that even well written programs still have 1-3 bugs per hundred
statements.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Productivity in Software Development

Productivity in software development refers to the efficiency and speed at which software is
developed while maintaining desired quality. It measures how effectively developers can convert
requirements into functional software within a given timeframe.

Factors Influencing Productivity:

1. Development Tools: Modern IDEs, frameworks, and libraries can significantly speed up
development.
2. Team Skills and Experience: Skilled and experienced developers produce high-quality
work faster.
3. Processes and Methodologies: Agile, DevOps, or other methodologies can streamline
workflows.
4. Code Reusability: Reusing code modules or libraries reduces development time.
5. Collaboration and Communication: Efficient teamwork and clear communication improve
productivity.
6. Automation: Automating repetitive tasks like testing and deployment increases efficiency.

Quality in Software

Software quality refers to the degree to which a software product meets customer requirements and
expectations, as well as how well it performs under specified conditions.

Dimensions of Software Quality:

1. Functionality: The software performs the tasks it is designed for correctly.


2. Reliability: The software operates consistently without failures.
3. Usability: The software is user-friendly and easy to navigate.
4. Performance: The software runs efficiently under expected workloads.
5. Maintainability: The software can be easily updated or fixed.
6. Security: The software protects data and resists unauthorized access.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Testing vs Debugging:

Testing: To identify errors or verify that a system meets its requirements. The goal is to ensure the
software behaves as expected under various conditions.

Debugging: To identify, analyze, and fix defects found during testing or operation. The goal is to
locate the root cause of a failure and resolve it.

Testing vs Debugging:

S.NO TESTING DEBUGGING

It is the implementation of the software The process of fixing and resolving the
1.
with the intent of identifying the defects defects is known as debugging.
Testing can be performed either manually
The debugging process cannot be
2. or with the help of some automation
automated.
tools.
A group of test engineers executes
Debugging is done by the developer or
3. testing, and sometimes it can be
the programmer.
performed by the developers.
The test engineers perform manual and
automated test cases on the application,
The developers will find, evaluates, and
4. and if they detect any bug or error, they
removes the software errors.
can report back to the development team
for fixing.
Without having an understanding of the
Programming knowledge is not required
5. programming language, we cannot
to perform the testing process.
proceed with the debugging process.
Once the coding phase is done, we After the implementation of the test case,
6.
proceed with the testing process. we can start the Debugging process.
Software Testing includes two or more Debugging tries to match indication with
7. activities such as validation and cause, hence leading to the error
verification of the software. correction.
It is built on different testing levels such It is built on different kinds of bugs
8. as Unit Testing, Integration Testing, because there is no such level of
System Testing, etc. debugging is possible.
Software testing is the presentation of
9. It is a logical procedure.
defects.
Software testing is the vital phase of
It is not a part of SDLC because it occurs
10. SDLC (Software Development Life
as a subset of testing.
Cycle).
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

MODEL FOR TESTING:

The testing model includes three models:


 A model of the environment
 A model of the program
 A model of the expected bugs

1. Environment:
(i) A Program's environment is the hardware and software required to make it run.
For online systems, the environment may include communication lines, other
systems, terminals and operators.
(ii) The environment also includes all programs that interact with and are used to
create the program under test - such as OS, linkage editor, loader, compiler,
utility routines.
Because the hardware and firmware are stable, it is not smart to blame the
environment for bugs.
2. Program:
(i) Most programs are too complicated to understand in detail.
(ii) The concept of the program is to be simplified in order to test it.
(iii) If simple model of the program doesn’t explain the unexpected behavior, we
may have to modify that model to include more facts and details. And if that
fails, we may have to modify the program.
3. Bugs:
(i) Bugs are more insidious (deceiving but harmful) than ever we expect them to be.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(ii) An unexpected test result may lead us to change our notion of what a bug is and
our model of bugs.
(iii) Some optimistic notions that many programmers or testers have about bugs are
usually unable to test effectively and unable to justify the dirty tests most
programs need.
Definition of Bug:
A bug is an error in a computer program's code that causes the software to behave unexpectedly or
fail.

There are many types of bugs.

Types of Bugs:

 Functional Bugs: These bugs are issues in software that cause a problem with how it's
supposed to work. They might cause wrong calculations, make it act strangely, crash, or stop
features from working.

 Unit Level Bugs: are errors found in the smallest parts of a software system. Developers divide
their code into these units to manage and test it more effectively. This method helps catch and
fix issues early.

 Performance Bugs: are an issue that negatively impacts software stability, how fast it runs, or
how quickly it responds to user inputs. They slow down the system or make it unresponsive.

 Usability Bugs: are errors that occur during the design of the user interface, making it
ineffective. This means the interface prevents users from performing their tasks easily or
efficiently. As a result, they may find it difficult or time-consuming to accomplish what need to
do.

 Security bugs: are ongoing and serious problems in the tech world. These bugs can be exploited
to gain unauthorized access or privileges on a computer system. Attackers can steal sensitive
data or cause other damaging effects.

 Logical bugs: disrupt software's intended workflow and cause it to behave incorrectly. These
bugs can lead to unexpected software behavior and even sudden crashes. They primarily occur
due to poorly written code or misinterpretation of business logic.

 Compatibility Bugs: occur when software is incompatible with the hardware or cannot be
processed by the operating system. Such bugs arise when the software fails to run correctly on
different devices, operating systems, or environments.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Syntax Errors: are very common and typically happen when there are missing or incorrect
characters in the code. These occur in the source code of a program.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Testing and Design Style:

In software testing, testing style and designing style refer to different approaches or
methodologies used to create and execute test cases. They guide how testers identify test scenarios,
write test cases, and assess the system under test.

1. Testing Style

The testing style refers to the strategies or approaches testers adopt to execute tests and evaluate the
quality of the software. These styles vary depending on the goals, tools, and processes involved.

Types of Testing Styles

Exploratory Testing:

1. A hands-on, unscripted approach.


2. Testers explore the application, designing and executing tests on the fly.
3. Focuses on discovering defects through intuition and experience.
4. Example: Testing a new feature without predefined test cases to see how it behaves
under various inputs.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Scripted Testing:

1. Relies on pre-written test cases or scripts.


2. Testers strictly follow step-by-step instructions.
3. Ensures coverage of specific requirements.
4. Example: Running a pre-defined test suite to validate a login function.

Automated Testing:

1. Uses automation tools to execute tests.


2. Efficient for repetitive tasks like regression testing.
3. Requires designing scripts or frameworks for automation.
4. Example: Using Selenium to test web applications' UI across browsers.

Context-Driven Testing:

1. Adapts the testing process based on the project context, such as team skills,
application type, or deadlines.
2. Focused on flexibility and relevance.
3. Example: Prioritizing security testing for a banking application.

Risk-Based Testing:

1. Prioritizes testing of high-risk components or features.


2. Focuses resources on areas that are more likely to fail or have higher impact.
3. Example: Stress testing the payment gateway in an e-commerce platform.

2. Designing Style

The designing style in software testing refers to how test cases or scenarios are planned and created.
This is a key step in ensuring thorough and effective testing.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Types of Designing Styles:

Black-Box(Specification-Based) Testing Design:

1. Focuses on inputs and outputs without knowledge of the internal code.


2. Tests the system's functionality based on requirements.
3. Techniques include:

1. Equivalence Partitioning: Grouping inputs that should produce similar


results.
2. Boundary Value Analysis: Testing edges of input ranges.
3. Decision Table Testing: Using logic-based tables for test case design.

4. Example: Checking if entering a valid username/password logs the user in


successfully.

White-Box(Structred-Based) Testing Design:

1. Involves detailed knowledge of the internal structure or code.


2. Focuses on code logic, control flow, and data flow.
3. Techniques include:

1. Statement Coverage: Ensuring all statements are executed.


2. Branch Coverage: Testing all code branches.
3. Path Testing: Verifying all possible execution paths.

4. Example: Testing a sorting algorithm's loops and decision structures.

Gray-Box Testing Design:

1. Combines aspects of black-box and white-box testing.


2. Testers have partial knowledge of the internal system.
3. Useful for integration and system testing.
4. Example: Verifying the behavior of APIs with knowledge of underlying business
logic.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Model-Based Testing (MBT):

1. Uses formal models of the system (e.g., state machines) to generate test cases.
2. Ensures systematic and comprehensive coverage.
3. Example: Designing test cases from a UML diagram.

Experience-Based Design:

1. Relies on testers' domain knowledge, experience, and intuition.


2. Often used when formal requirements are incomplete.
3. Example: Testing edge cases and error handling based on previous defects.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

UNIT - II

Unit II (Flow Graphs and Path Testing): Achievable paths - Path instrumentation - Application
of data flow testing - Transaction flow testing techniques.

Introduction to Flow Graphs and Path Testing:


Flow Path and Path Testing are techniques used in software testing to ensure that all
possible execution paths in a program are tested. This technique helps to detect issues such as
untested conditions, unreachable code, and logic errors. By thoroughly testing all paths, path testing
aims to improve software quality and reliability.
Flow Graph:
(i) A flow path refers to a specific route that the program takes during execution,
determined by the sequence of decisions and branches. The control flow graph is a graphical
representation of a program's control structure. It uses the elements named process blocks, decisions,
and junctions.

(ii) The flow graph is similar to the earlier flowchart, with which it is not to be confused .

(iii) Flow Graph Elements:A flow graph contains four different types of elements. (1)
Process Block (2) Decisions (3) Junctions (4) Case Statements. They are following,

1. Process Block:
 A process block is a sequence of program statements uninterrupted by either
decisions or junctions.
 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
instruction, a sequence of statements or instructions, a single entry/exit
subroutine, a macro or function call, or a sequence of these.
2. Decisions:
 A decision is a program point at which the control flow can diverge.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Machine language conditional branch and conditional skip instructions are


examples of decisions.
 Most of the decisions are two-way but some are three way branches in control
flow.
3. Case Statements:
 A case statement is a multi-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 differences between
Decisions and Case Statements
4. Junctions:
 A junction is a point in the program where the control flow can merge.
 Examples of junctions are: the target of a jump or skip instruction in ALP, a
label that is a target of GOTO.

Steps Involved in Flow Graph Testing

Step1: Create a Flow Graph

1. A flow graph is a graphical representation of the control flow in a program. It


includes nodes (representing statements or conditions) and edges (representing the
flow of execution).

Flow Graph:

1. Node 1: Start
2. Node 2: x > 0
3. Node 3: print("Positive")
4. Node 4: print("Negative")
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

5. Node 5: End

Edges:

1. 1 → 2 → 3 → 5 (if x > 0 is True)


2. 1 → 2 → 4 → 5 (if x > 0 is False)

Step 2: Identify Independent Paths

1.

1. Independent paths are the unique paths that traverse through the flow graph. These
include all possible branches, loops, and conditions.

Example: From the above flow graph:

1. Path 1: 1 → 2 → 3 → 5
2. Path 2: 1 → 2 → 4 → 5

Step 3: Write Test Cases for Each Path

1. Create test cases to cover all independent paths.

Example: Test cases for the program:

1. Test Case 1: Input x = 5 (to follow Path 1)


2. Test Case 2: Input x = -3 (to follow Path 2)

Step 4: Execute Test Cases

1. Run the test cases and verify the output against expected results.

Example:

1. For x = 5: The program outputs Positive.


2. For x = -3: The program outputs Negative.

Step 5: Analyze Results

1. Ensure all paths are tested and all branches behave as expected. Modify code or tests
if issues are identified.

Example: If a path produces incorrect output, inspect the logic in the corresponding part of
the flow graph and adjust the code.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Path Testing:

Path Testing is a white-box testing technique used to ensure that all possible execution
paths in a program or module are exercised at least once. It focuses on verifying the flow of logic
through the code, aiming to uncover errors in the control flow. It involves identifying and testing all
potential paths through the code, ensuring comprehensive coverage of the program’s logic.

Key Concepts of Path Testing

(i) Path:

Path is a sequence of executable statements or instructions in the code from the start to an
endpoint (or from one decision point to another).

(ii) Control Flow Graph (CFG):

A control flow graph (or simply, flow graph) is a directed graph which represents the
control structure of a program or module. control flow graph (V, E) has V number of
nodes/vertices and E number of edges in it. A control graph can also have :

 Junction Node – a node with more than one


arrow entering it.
 Decision Node – a node with more than one
arrow leaving it.
 Region – area bounded by edges and nodes

Objective:

1. To design test cases that cover all the independent paths in the control flow graph.
2. Ensure maximum coverage of branches, loops, and decision points.

(iii) Independent Path:

1. An independent path introduces at least one new edge or node that has not been
traversed before in any other path.
2. The number of independent paths is determined by the Cyclomatic Complexity of
the program.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Steps in Path Testing:

Step 1: Create the Control Flow Graph (CFG):

Represent the code as a graph to visualize all possible


paths.

Step 2: Calculate Cyclomatic Complexity: The


cyclomatic complexity V(G) is said to be a measure of the
logical complexity of a program. It can be calculated
using three different formulae :

(i) Formula based on edges and nodes :

Cyclomatic Complexity (M) = E - N + 2P


Where:

 E = Number of edges in the graph


 N = Number of nodes in the graph
 P = Number of connected components (usually 1 for a single
function/module)

Eg:

where, e = 4, n = 4 and p = 1 So, Cyclomatic complexity V(G)


=4-4+2*1=2
(ii) Formula based on Decision Nodes : V(G) = d + P
d = number of decision nodes,
P = number of connected nodes.
Eg:
where, d = 1 and p = 1 So, Cyclomatic Complexity V(G)
=1+1=2
(iii) Formula based on Regions : V(G) = number of regions in the graph

Cyclomatic complexity V(G) = 1 (for Region 1) + 1 (for Region 2) = 2

Cyclomatic complexity gives the minimum number of test cases needed to cover all
paths.

Step 3: Identify All Independent Paths:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Analyze the graph to determine paths that cover new edges or nodes.

Eg: A -> B, C -> D

Step 4: Design Test Cases: Finally, after obtaining the independent paths, test cases can
be designed where each test case represents one or more independent paths.

Step 5: Execute Test Cases: Run the program with the designed inputs and verify the
outputs.

ACHIEVABLE PATHS

 In software testing, an achievable path is a path that has a solution. A path that doesn't have a
solution is considered unachievable. The process of finding a set of solutions to a path predicate
expression is called path sensitization.
 We want to select and test enough paths to achieve a satisfactory notion of test completeness
such as C1+C2.Extract the programs control flowgraph and select a set of tentative covering
paths.
 For any path in that set, interpret the predicates along the path as needed to express them in
terms of the input vector. In general individual predicates are compound or may become
compound as a result of interpretation.
 Trace the path through, multiplying the individual compound predicates to achieve a boolean
expression such as

(A+BC) (D+E) (FGH) (IJ) (K) (l) (L).

Multiply out the expression to achieve a sum of products form:

ADFGHIJKL+AEFGHIJKL+BCDFGHIJKL+BCEFGHIJKL

Each product term denotes a set of inequalities that if solved will yield an input vector that will drive
the routine along the designated path.Solve any one of the inequality sets for the chosen path and
you have found a set of input values for the path.If you can find a solution, then the path is
achievable.If you cant find a solution to any of the sets of inequalities, the path is un achievable.

PATH INSTRUMENTATION

Path instrumentation in path testing refers to the process of inserting additional code or
mechanisms (called instrumentation) into a program to collect information about the paths taken
during its execution. This helps determine whether specific paths in the control flow graph are
executed and assists in verifying test coverage.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Co-incidental Correctness: The coincidental correctness stands for achieving the desired
outcome for wrong reason.

The above figure is an example of a routine that, for the (unfortunately) chosen input value (X = 16),
yields the same outcome (Y = 2) no matter which case we select. Therefore, the tests chosen this
way will not tell us whether we have achieved coverage. For example, the five cases could be totally
jumbled and still the outcome would be the same. Path Instrumentation is what we have to do to
confirm that the outcome was achieved by the intended path.

The types of instrumentation methods:

(i) Interpretive Trace Program:

 An interpretive trace program is one that executes every statement in order and records the
intermediate values of all calculations, the statement labels traversed etc.
 If we run the tested routine under a trace, then we have all the information we need to confirm
the outcome and, furthermore, to confirm that it was achieved by the intended path.
 The trouble with traces is that they give us far more information than we need. In fact, the
typical trace program provides so much information that confirming the path from its massive
output dump is more work than simulating the computer by hand to confirm the path.

(ii) Traversal Marker or Link Marker:

 A simple and effective form of instrumentation is called a traversal marker or link marker.
 Name every link by a lower case letter.
 Instrument the links so that the link's name is recorded when the link is executed.
 The succession of letters produced in going from the routine's entry to its exit should, if there are
no bugs, exactly correspond to the path name.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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.

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.

(iii) Two Link Marker Method:

 The solution to the problem of single link marker method is to implement two markers per link:
one at the beginning of each link and on at the end.
 The two link markers now specify the path name and confirm both the beginning and end of the
link.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(iv) Link Counter: A less disruptive (and less informative) instrumentation 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 confirm that the path length is as expected. The same
problem that led us to double link markers also leads us to double link counters.

APPLICATIONS OF PATH TESTING

(i) Integration, Coverage and Paths in called Components


 Path testing methods are mainly used in unit testing, especially for new software.
 The new component is first tested as an independent unit with all called components and co-
requisite components replaced by stubs. A simulator of low-level components that is more
reliable than the actual component.
 Path testing clarifies the integration issues.
 C1 coverage at the system level ranges from 50% to 85%.
 We gave no statistics for C2 coverage in system testing because it is impossible to monitor
C2 coverage without disrupting the system's operation.

(ii) New Code:


 New code should always be subjected to enough path testing to achieve C2.
 Stubs are used where it is clear that the bug potential for the stub is significantly lower than
that of the called components.
 Old, trusted components will not be replaced by stubs.
 Some consideration is given to paths within called components.
 Typically, we will try to use the shortest entry/exit path that will do the task.
(iii) Maintenance:
 There is a great difference between maintenance testing and new code testing.
 Maintenance testing is a completely different situation.
 It involves modifications which are accommodated in the system, as required.
 Path testing is used firstly on the modified component.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(iv) Rehosting:
 Path testing with C1+C2 coverage is a powerful tool for rehosting old software.
 We get a very powerful, effective, rehosting process when C 1+C2 coverage is used in
conjunction with automatic or semiautomatic structural test generators.
 Software is rehosted because it is no longer cost effective to support the environment in
which it runs.
 The objective of rehosting is to change the operating environment and not the rehosted
software.
 Rehosting from one COBOL environment to another is easy by comparison.
 Rehosted software can be modified to improve efficiency and/or to implement new
functionality, which had been difficult in the old environments.
 The test suites(collection) and all outcomes of the old environment become the specification
for the rehosted software.

TRANSACTION FLOW TESTING TECHNIQUES

(i) Get the Transaction Flows:


 Complicated systems that process a lot of different, complicated transactions, should
have explicit representations of the transactions flows or the equivalent..
 Transaction flows are like control flow graphs, and consequently, we should expect to
have them in increasing levels of details.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 The systems design documentation should contain an overview section, that details the
main transaction flows.
 Detailed transaction flows are a mandatory prerequisite to the rational design of a
systems functional test.

(ii) Inspections, Reviews and Walkthroughs:


 Transaction flows are natural agenda for system reviews or inspections.
 In conducting the walkthrough, you should:
o Discuss enough transaction types to account for 98%-99% of the transaction, the
system is expected to process.
o Discuss paths through flows in functional rather than technical terms.

 Ask the designers to relate every flow to the specification and to show how that
transaction, directly or indirectly, follows from the requirements.
 Make transaction flow testing the corner stone of system functional testing, just as path
testing is the corner stone of unit testing.
 Select additional flow paths for loops, extreme values, and domain boundaries.
 Design more test cases to validate all births and deaths.
 Publish and distribute the selected test paths through the transaction flows as early as
possible, so that they will exert the maximum beneficial effect on the project.

(iii) Path Selection


 Select a set of covering paths (C1 + C2) using the analogous criteria you used for structural
path testing.
 Select a covering set of paths based on functionally sensible transactions as you would for
control flow graphs.
 Try to find most tortuous, longest, strongest path from the entry to the exit of the transaction
flow.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(iv) Path Sensitization


 Most of the normal paths are very easy to sensitize. 80% - 95% transaction flow
coverage (C1 + C2) is usually easy to achieve.
 The remaining small percentage is often very difficult.
 Sensitization is the act of defining the transaction, if there are sensitization problems on
the easy paths, then bet on either bug in transaction flows or a design bug.

(v) Path Instrumentation


 Instrumentation plays a bigger role in transaction flow testing than in unit path testing.
 The information of the path taken for a given transaction must be kept with that
transaction and can be recorded by a central transaction dispatcher or by the individual
processing modules.
 In some systems, such traces are provided by the operating systems or a running log.

(vi) Design and Maintain Test Database


 Design and maintenance of the test databases constitute about 30% to 40% of the effort in
transaction flow test design.
 People are often unaware that a test database needs to designed.
 Test databases must be centrally administrated and configuration controlled with a
comprehensive design plan.
 Creating a comprehensive test databases is itself a big project on its own.
 It requires talented, matured, and diplomatic designers who are experienced in both
system design and test design.

(vii) Test Execution:


 Commit to automation of test execution if you want to do transaction flow testing for a
system of any size.
 If the numbers of test cases are limited, you need not worry about test execution
automation.
 If the number of test cases run into several hundred, performing transaction flow testing
to achieve (C1 + C2) needs execution automation without which you cannot get it right.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Unit III
Data Flow Testing Strategies - Domain Testing: Domains and Paths – Domains and Interface
Testing.

3.1 DATA FLOW TESTING:

 Data flow testing is the name given to a family of test strategies based on selecting paths
through the program's control flow in order to explore sequences of events related to the
status of data objects.
 For example, pick enough paths to assure that every data object has been initialized prior to
use or that all defined objects have been used for something.

 The source code consists of data declaration statements-that is statements that define data
structures, individual objects, initial or default rules and attributes

Data Flow Machines:


There are two types of data flow machines with different architectures. (1) Von Neumann machines
(2) Multi-instruction, multi-data machines (MIMD).

Von Neumann Machine Architecture:


 Most computers today are Von-Neumann machines.
 This architecture features interchangeable storage of instructions and data in the same
memory units.
 The Von Neumann machine Architecture executes one instruction at a time in the
following, micro instruction sequence:
1. Fetch instruction from memory
2. Interpret instruction
3. Fetch operands
4. Process or Execute
5. Store result
6. Increment program counter
7. GOTO 1
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Multi-instruction, Multi-data machines (MIMD) Architecture:


 These machines can fetch several instructions and objects in parallel.
 They can also do arithmetic and logical operations simultaneously on different data objects.
 The decision of how to sequence them depends on the compiler.
Bug Assumption:
 The bug assumption for data-flow testing strategies is that control flow is generally correct and
that something has gone wrong with the software so that data objects are not available when
they should be, or silly things are being done to data objects.
 Also, if there is a control-flow problem, we expect it to have symptoms that can be detected by
data-flow analysis.
 Although we'll be doing data-flow testing, we won't be using data flow graphs as such. Rather,
we'll use an ordinary control flow graph annotated to show what happens to the data objects of
interest at the moment.
Data Flow Graphs:
 The data flow graph is a graph consisting of nodes and directed links.

 We will use a control graph to show what happens to data objects of interest at that moment.
 Our objective is to expose deviations between the data flows we have and the data flows we
want.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Data Object State and Usage:

 Data Objects can be created, killed and used.


 They can be used in two distinct ways: (1) In a Calculation (2) As a part of a Control Flow
Predicate.
 The following symbols denote these possibilities:
 Defined: d - defined, created, initialized etc
 Killed or undefined: k - killed, undefined, released etc
Usage: u - used for something (c - used in Calculations, p - used in a predicate)

Defined (d):

 An object is defined explicitly when it appears in a data declaration.


 Or implicitly when it appears on the left hand side of the assignment.
 It is also to be used to mean that a file has been opened.
 A dynamically allocated object has been allocated.
 Something is pushed on to the stack.
 A record written.

Killed or Undefined (k):

 An object is killed on undefined when it is released or otherwise made unavailable.


 When its contents are no longer known with certitude (with absolute certainty / perfectness).
 Release of dynamically allocated objects back to the availability pool.
 Return of records.
 The old top of the stack after it is popped.
 An assignment statement can kill and redefine immediately. For example, if A had been
previously defined and we do a new assignment such as A : = 17, we have killed A's previous
value and redefined A

Usage (u):

 A variable is used for computation (c) when it appears on the right hand side of an
assignment statement.
 A file record is read or written.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 It is used in a Predicate (p) when it appears directly in a predicate.

Data Flow Anomalies:

 An anomaly is denoted by a two-character sequence of actions.


 For example, ku means that the object is killed and then used, where as dd means that the
object is defined twice without an intervening usage.
 What is an anomaly is depend on the application.
 There are nine possible two-letter combinations for d, k and u. some are bugs, some are
suspicious, and some are okay.
1. dd :- probably harmless but suspicious. Why define the object twice without an
intervening usage?
2. dk :- probably a bug. Why define the object without using it?
3. du :- the normal case. The object is defined and then used.
4. kd :- normal situation. An object is killed and then redefined.
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 time.
8. uk :- normal situation.
9. uu :- normal situation.

 In addition to the two letter situations, there are six single letter situations.
 We will use a leading dash to mean that nothing of interest (d,k,u) occurs prior to the action
noted along the entry-exit path of interest.
 A trailing dash to mean that nothing happens after 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 defined. We are killing a variable that does not exist.
2. -d :- okay. This is just the first definition along this path.
3. -u :- possibly anomalous. Not anomalous if the variable is global and has been
previously defined.
4. k- :- not anomalous. The last thing done on this path was to kill the variable.
5. d- :- possibly anomalous. The variable was defined and not used on this path. But this could
be a global definition.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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 allocation and return respectively, this could be an instance in which a dynamically
allocated object was not returned to the pool after use.

Data Flow Anomaly State Graph:

 Data flow anomaly model prescribes that an object can be in one of four distinct states:
o K :- undefined, previously killed, does not exist
o D :- defined but not yet used for anything
o U :- has been used for computation or in predicate
o A :- anomalous
 These capital letters (K, D, U, A) denote the state of the variable and should not be confused
with the program action, denoted by lower case letters.
 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 defined or does not
exist. If an attempt is made to use it or to kill it (e.g., say that we're talking about opening, closing,
and using files and that 'killing' means closing), the object's state becomes anomalous (state A) and,
once it is anomalous, no action can return the variable to a working state.
If it is defined (d), it goes into the D, or defined but not yet used, state. If it has been defined
(D) and redefined (d) or killed without use (k), it becomes anomalous, while usage (u) brings it to
the U state. If in U, redefinition (d) brings it to D, u keeps it in U, and k kills it.

Forgiving Data - Flow Anomaly Flow Graph


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Forgiving model is an alternate model where redemption (recover) from the anomalous state
is possible.

This graph has three normal and three anomalous states and he considers the kk
sequence not to be anomalous. The difference between this state graph and Figure 3.5 is that
redemption is possible. A proper action from any of the three anomalous states returns the
variable to a useful working state.
The point of showing you this alternative anomaly state graph is to demonstrate that the specifics of
an anomaly depends on such things as language, application, context, or even your frame of mind.
In principle, you must create a new definition of data flow anomaly (e.g., a new state graph) in
each situation. You must at least verify that the anomaly definition behind the theory or
imbedded in a data flow anomaly test tool is appropriate to your situation.

Static Vs Dynamic Anomaly Detection:


 Static analysis is analysis done on source code without actually executing it. For example:
source code syntax error detection is the static analysis result.
 Dynamic analysis is done on the fly as the program is being executed and is based on
intermediate values that result from the program's execution. For example: a division by zero
warning is the dynamic result.
 If a problem, such as a data flow anomaly, can be detected by static analysis methods, then it
doesn’t belong in testing - it belongs in the language processor.
 There is actually a lot more static analysis for data flow analysis for data flow anomalies going
on in current language processors.
 For example, language processors which force variable declarations can detect (-u) and (ku)
anomalies.
 But still there are many things for which current notions of static analysis are Inadequate they
are
1. Dead variables: Although it is often possible proved that a variable is dead or alive at
the given point in the program.
2. Arrays: Arrays are problematic in that array is defined or killed as a single object.
Arrays are dynamically calculated so there is no way to do static analysis to validate
the pointer value.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Records and pointers : In many applications we create the files and their names
dynamically and there is no way to determine without execution
4. Dynamic subroutine or function names in a call : A subroutine or function name is a
dynamic variable in a call
5. False Anomalies
6. Concurrency, Interrupts and system issues
Data Flow Model:
 The data flow model is based on the program's control flow graph
 Here we annotate each link with symbols (for example, d, k, u, c, p) or sequences of symbols
(for example, dd, du, ddd) that denote the sequence of data operations on that link with respect
to the variable of interest. Such annotations are called link weights.
 The control flow graph structure is same for every variable: it is the weights that change.

Components of the model:


The modeling rules are
1. To every statement there is a node and whose name or number is unique.
Every node has one outlink and atleast one inlink except exit nodes, which do
not have outlinks, and entry nodes,which do not have inlinks
2. Exit nodes are placed at the outgoing arrowheads of exit statements(Ex:
END, RETURN) to complete the graph and Entry nodes are placed at the
entry statements (Ex: BEGIN)
3. The outlink of simple statements are weighted by proper sequence of data
flow actions of that statement
4. Predicate nodes (Ex: IF-THEN-ELSE, DO WHILE,CASE) are weighted with
p-use
5. Every sequence of simple statements can be replaced by pair of nodes that has
weights on the link between them
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Putting it Together: Example:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 3.8 shows that the control flow graph for the program and the node labels and
marked the decision nodes with the variables.
Figure 3.9 shows that this control flowgraph annotated for variables X and Y and there
there is a dcc on the first link (1,3)
Figure 3.10 shows all the predicate uses for the Z variable and Figure 3.11shows the
control flow graph for V data flow .
Data flow testing is a family of test strategies based on selecting paths through the program's
control flow in order to explore sequences of events related to the status of variables or data objects.
Dataflow Testing focuses on the points at which variables receive values and the points at which
these values are used.

3.2 DATA FLOW TESTING STRATEGIES


 Data Flow Testing Strategies are structural strategies.
 In contrast to the path-testing strategies, data-flow strategies take into account what happens
to data objects on the links in addition to the raw connectivity of the graph.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 In other words, data flow strategies require data-flow link weights (d,k,u,c,p).
 Data Flow Testing Strategies are based on selecting test path segments (also called
sub paths) that satisfy some characteristic of data flows for all data objects.

 For example, all subpaths that contain a d (or u, k, du, dk).


 A strategy X is stronger than another strategy Y if all test cases produced under Y are
included in those produced under X - conversely for weaker.

Terminology:

Definition-Clear Path Segment, with respect to variable X, is a connected sequence of


links such that X is (possibly) defined on the first link and not redefined or killed on any
subsequent link of that path segment. ll paths in Figure 3.9 are definition clear because variables X
and Y are defined only on the first link (1,3) and not thereafter. In Figure 3.10, we have a more
complicated situation. The following path segments are definition-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 definition-clear because the
variable is defined on (1,3) and again on (4,5). For practice, try finding all the definition-clear
subpaths for this routine (i.e., for all variables).

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.

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.

A du path from node i to k is a path segment such that if the last link has a computational
use of X, then the path is simple and definition-clear; if the penultimate (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 definition-clear.

The Strategies
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

The structural test strategies discussed below are based on the program's control flowgraph. They
differ in the extent to which predicate uses and/or computational uses of variables are included in
the test set. Various types of data flow testing strategies in decreasing order of their effectiveness
are:

All - du Paths (ADUP): The all-du-paths (ADUP) strategy is the strongest data- flow testing
strategy discussed here. It requires that every du path from every definition of every variable to
every use of that definition be exercised under some test.

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 satisfies this criterion (for variables X and Y, but not for all
variables as required by the strategy).

For variable Z: The situation for variable Z (Figure 3.10) is more complicated
because the variable is redefined in many places. For the definition on link (1,3) we must exercise
paths that include subpaths (1,3,4) and (1,3,5). The definition on link (4,5) is covered by any path
that includes (5,6), such as subpath (1,3,4,5,6, ...). The (5,6) definition requires paths that
include subpaths (5,6,7,4) and (5,6,7,8).

For variable V: Variable V (Figure 3.11) is defined 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 directions 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 definitions. 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
first because any one test simultaneously satisfies the criterion for several definitions and uses of
several different variables.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

All Uses Startegy (AU):The all uses strategy is that at least one definition clear path from every
definition of every variable to every use of that definition be exercised under some test. Just as we
reduced our ambitions 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 definition to every use that can be reached by that
definition.

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 alternative.
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) after 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 definition of that
variable, include at least one definition free path from the definition to every predicate use; if there
are definitions of the variables that are not covered by the above prescription, then add
computational use test cases as required to cover every definition.

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 definition
because every definition is covered. Links (1,3), (4,5), (5,6), and (7,8) must be included because
they contain definitions 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 in this 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
first ensure coverage by computational use cases and if any definition is not covered by the
previously selected paths, add such predicate use cases as are needed to assure that every
definition 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 definitions are not covered. Specifically, the
(1,3) definition is not covered for the (3,5) p-use, the (7,8) definition is not covered for the (8,9),
(9,6) and (9, 10) p-uses.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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 Definitions Strategy (AD) : The all definitions strategy asks only every definition of
every variable be covered by atleast one use of that variable, be that use a computational use or
a predicate use.

For variable Z: Path (1,3,4,5,6,7,8, . . .) satisfies this criterion for variable Z, whereas any entry/exit
path satisfies it for variable V. From the definition of this strategy we would expect it to be weaker
than both ACU+P and APU+C.

All Predicate Uses (APU), All Computational 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 computational 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 intuitively obvious that ACU should be weaker than ACU+P and
that APU should be weaker than APU+C.

Ordering The Strategies:


Figure 3.12 compares path-flow and data-flow testing strategies. The arrows denote that the
strategy at the arrow's tail is stronger than the strategy at the arrow's head.

Figure 3.12 Relative Strength Of Structural Test Strategies


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Slicing And Dicing:

 A (static) program slice is a part of a program (e.g., a selected set of statements) defined
with respect to a given variable X (where X is a simple variable or a data vector) and a
statement i: it is the set of all statements that could (potentially, under static analysis) affect
the value of X at statement i - where the influence of a faulty statement could result from an
improper computational use or predicate use of some other variables at prior statements.
 If X is incorrect at statement i, it follows that the bug must be in the program slice for X
with respect to i
 A program dice is a part of a slice in which all statements which are known to be correct
have been removed.
 In other words, a dice is obtained from a slice by incorporating information obtained
through testing or experiment (e.g., debugging).
 The debugger first limits her scope to those prior statements that could have caused the
faulty value at statement i (the slice) and then eliminates from further consideration those
statements that testing has shown to be correct.
 Debugging can be modeled as an iterative procedure in which slices are further refined by
dicing, where the dicing information is obtained from ad hoc tests aimed primarily at
eliminating possibilities. Debugging ends when the dice has been reduced to the one faulty
statement.
 Dynamic slicing is a refinement of static slicing in which only statements on achievable
paths to the statement in question are included.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3.3 APPLICATIONS,TOOLS AND EFFECTIVENESS


Comparison Random Testing, P2, AU - by Ntafos

• AU detects more bugs than


• P2 with more test cases
• RT with less # of test cases Comparison of P2,
AU - by Sneed
 AU detects more bugs with 90% Data Coverage Requirement.

Comparison of number of test cases for ACU, APU, AU & ADUP by Weyuker using
ASSET testing system

 Test Cases Normalized. t = a + b * d d = # binary


decisions
 At most d+1 Test Cases for P2 loop-free
 No of Test Cases / Decision ADUP > AU> APU > ACU >
revised-APU

Comparison of # test cases for ACU, APU, AU & ADUP by Shimeall & Levenson

Test Cases Normalized. t=a+b*d (d = # binary decisions)


At most d+1 Test Cases for P2 loop-free
# Test Cases / Decision ADUP ~ ½ APU* AP ~ AC
 The data flow testing strategies have found it expedient and cost effective to
create supporting tools

Commercial tools :

 Can possibly do Better than Commercial Tools


 Easier Integration into a Compiler
 Efficient Testing
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3.4 DOMAINS AND PATHS


 Domain: In mathematics, domain is a set of possible values of an independant variable
or the variables of a function.
 Programs as input data classifiers: domain testing attempts to determine whether the
classification is or is not correct.
 Domain testing can be based on specifications or equivalent implementation
information.
 If domain testing is based on specifications, it is a functional test technique.
 If domain testing is based implementation details, it is a structural test technique.

The Model:

The following figure is a schematic representation of domain testing.

Figure 4.1: Schematic Representation of Domain Testing.

 Before doing whatever it does, a routine must classify the input and set it moving
on the right path
 An invalid input (e.g., value too big) is just a special processing case called
'reject'.
 The input then passses to a hypothetical subroutine rather than on
calculations.
 In domain testing, we focus on the classification aspect of the routine rather than
on the calculations.
 Structural knowledge is not needed for this model - only a consistent, complete
specification of input values for each case.
 We can infer that for each case there must be atleast one path to process
that case.

A Domain Is A Set:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 An input domain is a set.


 If the source language supports set definitions (E.g. PASCAL set types and C
enumerated types) less testing is needed because the compiler does much of it for
us.
 Domain testing does not work well with arbitrary discrete sets of data objects.
 Domain for a loop-free program corresponds to a set of numbers defined over the
input vector.

Domains, Paths And Predicates:


 In domain testing, predicates are assumed to be interpreted in terms of input vector
variables.
 If domain testing is applied to structure, then predicate interpretation must be based
on actual paths through the routine - that is, based on the implementation control
flowgraph.
 Conversely, if domain testing is applied to specifications, interpretation is based on a
specified data flowgraph for the routine; but usually, as is the nature of
specifications, no interpretation is needed because the domains are specified directly.
 For every domain, there is at least one path through the routine.
 There may be more than one path if the domain consists of disconnected parts or if
the domain is defined by the union of two or more domains.
 Domains are defined their boundaries. Domain boundaries are also where most
domain bugs occur.
 For every boundary there is at least one predicate that specifies what numbers
belong to the domain and what numbers don't.

 For example, in the statement IF x>0 THEN ALPHA ELSE BETA we know
that numbers greater than zero belong to ALPHA processing domain(s) while
zero and smaller numbers belong to BETA domain(s).

 A domain may have one or more boundaries - no matter how many variables define
it.

For example, if the predicate is x2 + y2 < 16, the domain is the inside of a circle of
radius 4 about the origin. Similarly, we could define a spherical domain with one
boundary but in three variables.

 Domains are usually defined by many boundary segments and therefore by many
predicates. i.e. the set of interpreted predicates traversed on that path (i.e., the path's
predicate expression) defines the domain's boundaries.

1. A Domain Closure:

 A domain boundary is closed with respect to a domain if the points on the boundary
belong to the domain.
 If the boundary points belong to some other domain, the boundary is said to be open.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Figure 4.2 shows three situations for a one-dimensional domain - i.e., a domain
defined over one input variable; call it x
 The importance of domain closure is that incorrect closure bugs are frequent
domain bugs. For example, x >= 0 when x > 0 was intended.

 Figure 4.2: Open and Closed Domains.

2. Domain Dimensionality:

 Every input variable adds one dimension to the domain.


 One variable defines domains on a number line.
 Two variables define planar domains.
 Three variables define solid domains.
 Every new predicate slices through previously defined domains and cuts them in
half.
 Every boundary slices through the input vector space with a
dimensionality which is less than the dimensionality of the space.
 Thus, planes are cut by lines and points, volumes by planes, lines and points
and n-spaces by hyperplanes.

3. Bug Assumption:

 The bug assumption for the domain testing is that processing is okay but the domain
definition is wrong.
 An incorrectly implemented domain means that boundaries are wrong, which
may in turn mean that control flow predicates are wrong.
 Many different bugs can result in domain errors. Some of them are:
1. Double Zero Representation :In computers or Languages that have a
distinct positive and negative zero, boundary errors for negative zero are
common.
2. Floating point zero check:A floating point number can equal zero only if
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

the previous definition of that number set it to zero or if it is subtracted from


it self or multiplied by zero. So the floating point zero check to be done
against a epsilon value.
3. Contradictory domains:An implemented domain can never be ambiguous
or contradictory, but a specified domain can. A contradictory domain
specification means that at least two supposedly distinct domains overlap.
4. Ambiguous domains:Ambiguous domains means that union of the domains
is incomplete. That is there are missing domains or holes in the specified
domains. Not specifying what happens to points on the domain boundary is a
common ambiguity.
5. Overspecified Domains:he domain can be overloaded with so many
conditions that the result is a null domain. Another way to put it is to say that
the domain's path is unachievable.
6. Boundary Errors:Errors caused in and around the boundary of a domain.
Example, boundary closure bug, shifted, tilted, missing, extra boundary.
7. Closure Reversal:A common bug. The predicate is defined in terms of >=.
The programmer chooses to implement the logical complement and
incorrectly uses <= for the new predicate; i.e., x >= 0 is incorrectly negated
as x <= 0, thereby shifting boundary values to adjacent domains.
8. Faulty Logic:Compound predicates (especially) are subject to faulty logic
transformations and improper simplification. If the predicates define domain
boundaries, all kinds of domain bugs can result from faulty logic
manipulations.

4. Restrictions To Domain Testing:


Domain testing has restrictions, as do other testing techniques. Some of them include:

5. Co-incidental Correctness:
Domain testing isn't good at finding 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 testing when dealing with routines
that have binary outcomes (i.e., TRUE/FALSE)
6. Representative Outcome:
Domain testing is an example of partition testing. Partition-testing strategies divide
the program's input space into domains such that all inputs within a domain are equivalent
(not equal, but equivalent) in the sense that any input represents all inputs in that domain.
If the selected input is shown to be correct by a test, then processing is presumed
correct, and therefore all inputs within that domain are expected (perhaps unjustifiably) to
be correct. Most test techniques, functional or structural, fall under partition testing and
therefore make this representative outcome assumption. For example, x 2 and 2x are equal for
x = 2, but the functions are different. The functional differences between adjacent domains
are usually simple, such as x + 7 versus x + 9, rather than x2 versus 2x.

7. Simple Domain Boundaries and Compound Predicates:

Compound predicates in which each part of the predicate specifies a different


boundary are not a problem: for example, x >= 0 AND x < 17, just specifies two domain
boundaries by one compound predicate. As an example of a compound predicate that
specifies one boundary, consider: x = 0 AND y >= 7 AND y <= 14.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

This predicate specifies one boundary equation (x = 0) but alternates closure, putting
it in one or the other domain depending on whether y < 7 or y >
14. Treat compound predicates with respect because they’re more complicated than they
seem.

8. Functional Homogeneity of Bugs:

Whatever the bug is, it will not change the functional 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.

9. Linear Vector Space:

Most papers on domain testing, assume linear boundaries - not a bad assumption
because in practice most boundary predicates are linear.

10. Loop Free Software:


Loops are problematic for domain testing. The trouble with loops is that each
iteration can result in a different predicate expression (after interpretation), which means a
possible domain boundary change.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

11. NICE AND UGLY DOMAINS:

NICE DOMAINS:

Where do these domains come from?


Domains are and will be defined by an imperfect iterative process aimed at achieving (user,
buyer, voter) satisfaction.

 Implemented domains can't be incomplete or inconsistent. Every input will be processed


(rejection is a process), possibly forever. Inconsistent domains will be made consistent.

 Conversely, specified domains can be incomplete and/or inconsistent. Incomplete in this


context means that there are input vectors for which no path is specified, and inconsistent
means that there are at least two contradictory specifications over the same segment of the
input space.

 Some important properties of nice domains are: Linear, Complete, Systematic, And
Orthogonal, Consistently closed, Convex and simply connected.

 To the extent that domains have these properties domain testing is easy as testing gets.

 The bug frequency is lesser for nice domain than for ugly domains.

Figure 4.3: Nice Two-Dimensional Domains.

Linear And Non Linear Boundaries:

 Nice domain boundaries are defined by linear inequalities or equations.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 The impact on testing stems from the fact that it takes only two points to determine a
straight line and three points to determine a plane and in general n+ 1 point to determine an
n-dimensional hyper plane.

 In practice more than 99.99% of all boundary predicates are either linear or can be
linearized by simple variable transformations.

Complete Boundaries:
 Nice domain boundaries are complete in that they span the number space from plus to minus
infinity in all dimensions.

 Figure 4.4 shows some incomplete boundaries. Boundaries A and E have gaps.

 Such boundaries can come about because the path that hypothetically corresponds to them is
unachievable, because inputs are constrained in such a way that such values can't exist,
because of compound predicates that define a single boundary, or because redundant
predicates convert such boundary values into a null set.

 The advantage of complete boundaries is that one set of tests is needed to confirm the
boundary no matter how many domains it bounds.

 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.

Figure 4.4: Incomplete Domain Boundaries.

Systematic Boundaries:
 Systematic boundary means that boundary inequalities related by a simple function such as
a constant.

In Figure 4.3 for example, the domain boundaries for u and v differ only by a constant.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

where fi is an arbitrary linear function, X is the input vector, ki and c are constants, and g(i,c) is a
decent function over i and c that yields a constant, such as k + ic.

 The first example is a set of parallel lines, and the second example is a set of systematically
(e.g., equally) spaced parallel lines (such as the spokes of a wheel, if equally spaced in
angles, systematic).

 If the boundaries are systematic and if you have one tied down and generate tests for it, the
tests for the rest of the boundaries in that set can be automatically generated.

Orthogonal Boundaries:

 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.

 If two boundary sets are orthogonal, then they can be tested independently

 In Figure 4.3 we have six boundaries in U and four in V. We can confirm the boundary
properties in a number of tests proportional to 6 + 4 = 10 (O(n)). If we tilt the boundaries to
get Figure 4.5,

 we must now test the intersections. We've gone from a linear number of cases to a quadratic:
from O(n) to O(n2).
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 4.5: Tilted Boundaries.

Figure 4.6: Linear, Non-orthogonal Domain Boundaries.

Actually, there are two different but related orthogonality conditions. Sets of boundaries can be
orthogonal to one another but not orthogonal to the coordinate axes (condition 1), or boundaries can
be orthogonal to the coordinate axes (condition 2).

Closure Consistency:

 Figure 4.6 shows another desirable domain property: boundary closures are consistent and
systematic.

 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.

 Consistent closure means that there is a simple pattern to the closures - for example,
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

using the same relational operator for all boundaries of a set of parallel boundaries.

CONVEX:
 A geometric figure (in any number of dimensions) is convex if you can take two arbitrary
points on any two different boundaries, join them by a line and all points on that line lie
within the figure.

 Nice domains are convex; dirty domains aren't.


 You can smell a suspected concavity when you see phrases such as: ". . . except if . . .,"
"However . . .," ". . . but not......." In programming, it's often the buts in the specification
that kill you.

Simply Connected:

 Nice domains are simply connected; that is, they are in one piece rather than pieces all over
the place interspersed with other domains.

 Simple connectivity is a weaker requirement than convexity; if a domain is convex it is


simply connected, but not vice versa.

 Consider domain boundaries defined by a compound predicate of the (Boolean) form ABC.
Say that the input space is divided into two domains, one defined by ABC and, therefore,
the other defined by its negation.

 For example, suppose we define valid numbers as those lying between 10 and 17 inclusive.
The invalid numbers are the disconnected domain consisting of numbers less than 10 and
greater than 17.

 Simple connectivity, especially for default cases, may be impossible.

UGLY DOMAINS:
 Some domains are born ugly and some are uglified by bad specifications.

 Every simplification of ugly domains by programmers can be either good or bad.

 Programmers in search of nice solutions will "simplify" essential complexity out of


existence. Testers in search of brilliant insights will be blind to essential complexity and
therefore miss important cases.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 If the ugliness results from bad specifications and the programmer's simplification is
harmless, then the programmer has made ugly good.
 But if the domain's complexity is essential (e.g., the income tax code), such
"simplifications" constitute bugs.

 Nonlinear boundaries are so rare in ordinary programming that there's no information on


how programmers might "correct" such boundaries if they're essential.

Ambiguities And Contradictions:


 Domain ambiguities are holes in the input space.
 The holes may lie within the domains or in cracks between domains.

 Two kinds of contradictions are possible: overlapped domain specifications and


overlapped closure specifications

 Figure 4.7c shows overlapped domains and Figure 4.7d shows dual closure assignment.

Figure 4.7: Domain Ambiguities and Contradictions

Simplifying The Topology:

 The programmer's and tester's reaction to complex domains is the same - simplify

 There are three generic cases: concavities, holes and disconnected pieces.

 Programmers introduce bugs and testers misdesign test cases by: smoothing out concavities
(Figure 4.8a), filling in holes (Figure 4.8b), and joining disconnected pieces (Figure 4.8c).
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 4.8: Simplifying the topology. RECTIFYING


BOUNDARY CLOSURES:
 If domain boundaries are parallel but have closures that go every which way (left, right,
left . . .) the natural reaction is to make closures go the same way (see Figure 4.9).
 If the main processing concerns about one or two domains and the spaces between them are
rejected, the likely treatment of closures is to make all boundaries point the same way

Figure 4.9: Forcing Closure Consistency.

3.5 DOMAIN TESTING:


DOMAIN TESTING STRATEGY: The domain-testing strategy is simple, although possibly tedious (slow).

1. Domains are defined by their boundaries; therefore, domain testing concentrates test points on or
near boundaries.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. Classify what can go wrong with boundaries, then define a test strategy for each case. Pick
enough points to test for all recognized kinds of boundary errors.
3. Because every boundary serves at least two different domains, test points used to check one
domain can also be used to check adjacent domains. Remove redundant test points.
4. Run the tests and by posttest analysis (the tedious part) determine if any boundaries are faulty
and if so, how.
5. Run enough tests to verify every boundary of every domain.

Domain Bugs And How To Test For Them:

 An interior point (Figure 4.10) is a point in the domain such that all points within an arbitrarily
small distance (called an epsilon neighborhood) are also in the domain.
 A boundary point is one such that within an epsilon neighborhood there are points both in the
domain and not in the domain.
 An extreme point is a point that does not lie between any two other arbitrary but distinct
points of a (convex) domain.

Figure 4.10: Interior, Boundary and Extreme points.

 An on point is a point on the boundary.


 If the domain boundary is closed, an off point is a point near the boundary but in the adjacent domain.
 If the boundary is open, an off point is a point near the boundary but in the domain being tested; see
Figure 4.11. You can remember this by the acronym COOOOI: Closed Off Outside, Open Off Inside.

Figure 4.11: On points and Off points.

 Figure 4.12 shows generic domain bugs: closure bug, shifted boundaries, tilted
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

boundaries, extra boundary, missing boundary.

Figure 4.12: Generic Domain Bugs.

Testing One Dimensional Domains:

 Figure 4.13 shows possible domain bugs for a one-dimensional open domain
boundary.
 The closure can be wrong (i.e., assigned to the wrong domain) or the boundary (a
point in this case) can be shifted one way or the other, we can be missing a boundary, or
we can have an extra boundary.

Figure 4.13: One Dimensional Domain Bugs, Open Boundaries.

 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
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

rather than B.
 In Figure 4.13c we've suffered a boundary shift to the left. 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 distinguish between a shift and a closure error, but we do
know that we have a bug.
 Figure 4.13d shows a shift the other way. The on point doesn't tell us anything because the
boundary shift doesn't change the fact that the test point will be processed in B. To detect
this shift we need a point close to the boundary but within
A. The boundary is open, therefore by definition, the off point is in A (Open Off Inside).
 The same open off point also suffices to detect a missing boundary because what should
have been processed in A is now processed in B.
 To detect an extra boundary we have to look at two domain boundaries. In this context an
extra boundary means that A has been split in two. The two off points that we selected
before (one for each boundary) does the job. If point C had been a closed boundary, the on
test point at C would do it.
 For closed domains look at Figure 4.14. As for the open boundary, a test point on the
boundary detects the closure bug. The rest of the cases are similar to the open boundary,
except now the strategy requires off points just outside the domain.

Figure 4.14: One Dimensional Domain Bugs, Closed Boundaries.

Testing Two Dimensional Domains:

 Figure 4.15 shows possible domain boundary bugs for a two-dimensional domain.
 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.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

For Closed Boundaries:

1. Closure Bug: Figure 4.15a shows a faulty closure, such as might be caused by using a
wrong operator (for example, x >= k when x > k was intended, or vice versa). The two on
points detect this bug because those values will get B rather than A processing.
2. Shifted Boundary: In Figure 4.15b the bug is a shift 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 off point (closed off
outside) catches this bug. Figure 4.15c shows a shift down that is caught by the two on
points.
3. Tilted Boundary: A tilted boundary occurs when coefficients in the boundary inequality
are wrong. For example, 3x + 7y > 17 when 7x + 3y > 17 was intended. Figure 4.15d has a
tilted boundary, which creates erroneous domain segments A' and B'. In this example the
bug is caught by the left on point.
4. Extra Boundary: An extra boundary is created by an extra predicate. An extra boundary
will slice through many different domains and will therefore cause many test failures for the
same bug. The extra boundary in Figure 4.15e is caught by two on points, and depending on
which way the extra boundary goes, possibly by the off point also.
5. Missing Boundary: A missing boundary is created by leaving a boundary predicate out. A
missing boundary will merge different domains and will cause many test failures although
there is only one bug. A missing boundary, shown in Figure 4.15f, is caught by the two on
points because the processing for A and B is the same - either A or B processing.

Figure 6.16 : Domain testing strategy


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 The above figure 6.16 summarizes domain testing for two dimensional domains it shows a
domain all but one of whose boundaries are closed.

 There are two on points (closed circles) for each segment and one off point(open circle)
 The on points for two adjacent boundary segments are shared if both segments are open or if
both are closed.

Equality & Inequality Predicates

 Equality predicates such as x+y=17 define lower-level dimensions


 We get two test points for equality predicates by considering adjacent domains as shown in
above figure
 There are three domains A,B and C . A and B are planar while c,defined by the equality
boundary predicate between A and B
 The test point for A is a and for B is b and on C there are c c— Testing n-Dimensional
domains
 The domains defined over an n-dimensional input space with p boundary segments, the
domain testing strategy generalize to require atmost (n+1)p strategy.

 Equality predicates defined over m dimensions(m<n) create a subspace of n- m


dimensions, which is then tested the same way as n dimension

Procedure For Testing: The procedure is conceptually is straight forward. It can be done by hand
for two dimensions and for a few domains and practically impossible for more than two variables.

1. Identify input variables.


2. Identify variable which appear in domain defining predicates, such as control flow
predicates.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Interpret all domain predicates in terms of input variables.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

4. For p binary predicates, there are at most 2 p combinations of TRUE-FALSE values and therefore, at
most 2p domains. Find the set of all non null domains. The result is a boolean expression in the
predicates consisting a set of AND terms joined by OR's. For example ABC+DEF+GHI Where the
capital letters denote predicates. Each
product term is a set of linear inequality that defines a domain or a part of a multiply connected domains.
5. Solve these inequalities to find all the extreme points of each domain using any of the linear
programming methods.

Variations, Tools Effectiveness

 The basic domain testing strategy is N*1 strategy because it uses N on points and one off point
 Clarke strategy uses N on and N off points per boundary segment(N*N strategy) and
strategies based on the vertex
 Richardson and Clarke used the generalization strategy i.e, partition and analysis which includes
verification, both structural and functional information

3.6 DOMAIN AND INTERFACE TESTING

Introduction:

 We defined integration testing as testing the correctness of the interface between two otherwise
correct components.
 Components A and B have been demonstrated to satisfy their component tests, and as part of the
act of integrating them we want to investigate possible inconsistencies across their interface.
 Interface between any two components is considered as a subroutine call.
 We're looking for bugs in that "call" when we do interface testing.
 Let's assume that the call sequence is correct and that there are no type incompatibilities.
 For a single variable, the domain span is the set of numbers between (and including) the smallest
value and the largest value. For every input variable we want (at least): compatible domain spans
and compatible closures (Compatible but need not be Equal).

Domains And Range:

 The set of output values produced by a function is called the range of the function, in contrast
with the domain, which is the set of input values over which the function is defined.
 For most testing, our aim has been to specify input values and to predict and/or confirm output
values that result from those inputs.
 Interface testing requires that we select the output values of the calling routine i.e. caller's range
must be compatible with the called routine's domain.
 An interface test consists of exploring the correctness of the following mappings:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

caller domain --> caller range(caller unit test) caller range --> called domain(integration
test) domain --> called range (called unit test)

Closure Compatibility:
 Assume that the caller's range and the called domain spans the same numbers - for example,
0 to 17.
 Figure 4.16 shows the four ways in which the caller's range closure and the called's domain
closure can agree.
 The thick line means closed and the thin line means open. Figure 4.16 shows the four cases
consisting of domains that are closed both on top
(17) and bottom (0), open top and closed bottom, closed top and open bottom, and open top
and bottom.

Figure 4.16: Range / Domain Closure Compatibility.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Figure 4.17 shows the twelve different ways the caller and the called can 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.

Figure 4.17: Equal-Span Range / Domain Compatibility Bugs.

Span Compatibility:

 Figure 4.18 shows three possibly harmless span incompatibilities.

Figure 4.18: Harmless Range / Domain Span incompatibility bug (Caller


Span is smaller than Called).

 In all cases, the caller's range is a subset of the called's domain. That's not necessarily a bug.
 The routine is used by many callers; some require values inside a range and some don't. This
kind of span incompatibility is a bug only if the caller expects the called routine to validate the
called number for the caller.
 Figure 4.19a shows the opposite situation, in which the called routine's domain has a smaller
span than the caller expects. All of these examples are buggy.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 4.19: Buggy Range / Domain Mismatches

 In Figure 4.19b the ranges and domains don't line up; hence good values are rejected, bad values
are accepted, and if the called routine isn't robust enough, we have crashes.
 Figure 4.19c combines these notions to show various ways we can have holes in the domain:
these are all probably buggy.

Interface Range / Domain Compatibility Testing:


 For interface testing, bugs are more likely to concern single variables rather than peculiar
combinations of two or more variables.
 Test every input variable independently of other input variables to confirm compatibility of the
caller's range and the called routine's domain span and closure of every domain defined for that
variable.
 There are two boundaries to test and it's a one-dimensional domain; therefore, it requires one on
and one off point per boundary or a total of two on points and two off points for the domain -
pick the off points appropriate to the closure (COOOOI).
 Start with the called routine's domains and generate test points in accordance to the domain-
testing strategy used for that routine in component testing.

3.7 DOMAINS AND TESTABILITY

Linearizing Transformations

 We often convert non linear boundaries to equivalent linear boundaries this is done by applying linear
transformations
 The methods are
1. Polynomials: A boundary is specified by a polynomial or multinomial in several variables
for example each term x,x2,x3 is replaced by y1=x,y2=x2
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. Logarithmic transformations: products such as xyz can be linearized by substituting


u=log(x),v=log(y),z=log(y)
3. More general transforms are by using taylor series expansion we can linearize

Coordinate transformations

 Nice boundaries are parallel sets .Parallel boundaries sets are sets of linearly related boundaries they
differ only by constant
 It is an O(n2) procedure for n boundary equations
 Generally we have n equalities and m variables and convert the inequalities into equalities
 Select the equation and apply a procedure called Gram-schmidt orthogonalization which transforms
original set of variables x into a new

A canonical program form

Figure 4.1: Schematic Representation of Domain Testing.

The input variable is going to be linearized and orthogonalizes so that inequalities can be removed

The routine structure will be

1. Input the data


2. Apply linearizing transforms to as many predicates as possible
3. Transform to an orthogonal coordinate syste
4. For each set of parallel hyperplanes in the orthogonal space determine the case
5. Test the remaining inequalities to determine the required database
6. Now direct the program to the correct case process routine by a control flow predicate

Testing is clearly divided into the following:

 Testing the predicate


 Testing the coordinate systems
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Testing the individual case selections


 Testing the control flow
 Testing the case processing
Great Insights

 A good coordinate systems can break the back of many tough problems. Make the domain design as
explicit
 Look the transformations to new, orthogonal, coordinate sets therefore it is easy to test
 Testers will test the domains based on the specifications to a minimal set.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

these, the fact that nesting is ignored (nested loops, nested IF-THEN-ELSE, and so on) is probably the most
serious critique. A Basic statement such as

100 A = B + C @ D = SIN(A) N=9

is less bug-prone than

100 D = SIN(B + C) N=6

3.4. Token Count

Levitin, in his incisive critique of linguistic metrics (LEVI86), makes a strong argument for the use of program
token count rather than lines of code, statement count, or Halstead’s length. A token in a programming language
is the basic syntactic unit from which programs are constructed. Tokens include keywords, labels, constants,
strings, and variable names. Token counting is easy because the first stage of compilation is to translate the
source code into equivalent numerical tokens. The number of tokens is easily obtained as a by-product of
compilation. Token count gets around the subjectivity problems we have with statement counts and lines of code.

4. STRUCTURAL METRICS

4.1. General

Structural metrics take the opposite viewpoint of linguistic metrics. Linguistic complexity is ignored while
attention is focused on control-flow or data-flow complexity—metrics based on the properties of flowgraph
models of programs. Graph theory is more than a half-century old but the study of graph-theoretic problems and
metrics goes back three centuries: see MAYE72. If it’s a graph (i.e., it consists of links and nodes) then there are
hundreds of interesting metrics that can be applied to it: metrics whose mathematical properties have been
studied in minute detail. The thrust of structural metrics research has not been so much the invention of new
graph-theoretic metrics but the investigation of the utility of known graph-theoretic metrics. McCabe’s use of the
cyclomatic number (MCCA76) is an archetypal example.

4.2. Cyclomatic Complexity (McCabe’s Metric)

4.2.1. Definition

McCabe’s cyclornatic complexity metric (MCCA76) is defined as:

M = L — N + 2P
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

where

L = the number of links in the graph

N = the number of nodes in the graph

P = the number of disconnected parts of the graph (e.g., a calling program and a subroutine)

The number M that appeared alongside the flowgraphs in Chapter 3 was McCabe’s metric for that flowgraph. In
all the examples, except for the one on page 73, there was only one connected part, and consequently the value of
P was 1. Figure 7.1 shows some more examples and their associated M values.

4.2.2. Applications to Test Plan Completeness and Inspections

Evaluate the cyclomatic complexity of the program’s design (e.g., from the design control flowgraph). As part of
self-inspection, reevaluate the complexity by counting decisions in the code. Any significant difference should be
explained, because it’s more likely that the difference is due to a missing path, an extra path, or an unplanned
deviation from the design than to something else. Having verified the code’s cyclomatic complexity, compare the
number of planned test cases to the code’s complexity. In particular, count how many test cases are intended to
provide coverage. If the number of covering test cases is less than the cyclomatic complexity, there is reason for
caution, because one of the following may be true:

1. You haven’t calculated the complexity correctly. Did you miss a decision?

2. Coverage is not really complete; there’s a link that hasn’t been covered.

3. Coverage is complete, but it can be done with a few more but simpler paths.

4. It might be possible to simplify the routine.

4.2.3. When to Subroutine

McCabe’s metric can be used to help decide whether it pays to make a piece of code which is common to two or
more links into a subroutine. Consider the graph of Figure 7.3. The program has a common part that consists of
Nc nodes and Lc links. This is the part being considered for conversion to a subroutine. This common part recurs
k times in the body of the main program. The main program has Nm nodes and Lm links over and above the
common part.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

EMBEDDED SUBROUTINE FOR


COMMON PART COMMON PART

Main nodes Nm + kNc Nm

Main links Lm + kLc Lm + k

Subnodes 0 Nc + 2

Sublinks 0 Lc

Main complexity Lm + kLc – Nm + kNc + 2 Lm + k

Subcomplexity 0 L c – Nc – 2 + 2 = L c – Nc = M

Total complexity + 2 Lm + kLc – Nm + kNc + 2 L m + L c – Nm – Nc + k + 2

.2.4. A Refinement

Myers (MYER77) points out a weakness of McCabe’s metric and suggests the use of a refinement thereto. A
decision statement in languages such as FORTRAN can contain a compound predicate of the form: IF A & B &
C THEN . . . . A statement such as this could be implemented as a string of IFs, resulting in a different
complexity measure. Figure 7.4 shows three alternate, equivalent, representations of the same IF-THEN-ELSE
statement. If the compound predicate is used in a single statement as in the first case, the complexity of the
construct is only two, but if it is broken down into its constituent parts, the complexity increases to four.
However, intuitively, all three constructs should have the same complexity. The refinement consists of
accounting for each term of the predicate expression separately. For a predicate expression of the form A&B&C .
. . , each predicate should be counted as if it was a decision. In more complicated expressions, such as A&B&C
OR D&E . . . , again count each predicate. If a predicate appears more than once in an expression, you can take a
pessimistic point of view and count each appearance or a slightly optimistic point of view and count only the first
appearance.

4.2.5. How Good a Measure; A Critique


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Statistics on how well McCabe’s metric correlates with design, test, and debugging difficulty are encouraging
(BELF79, CHEN78A, CURT79A, ENDR75, FEUE79A, FEUE79B, LIPO77, SCHN79A, SCHN79B,
SCHN79D, SHEP79C, THAY76, WALS79, ZOLN77).* The reported results confirm the utility of McCabe’s
metric as a convenient rule of thumb that is significantly superior to statement count.

*
Not all of these references provide direct information for McCabe’s metric. Some (ENDR75, THAY76) provide
correlations to decision counts and similar metrics that can be converted to McCabe’s metric. Note also that if we
forget the structural basis of cyclomatic complexity and merely use equivalent binary decision count or simple
predicate count, then this metric can be obtained by purely linguistic means.

4.3. Other Structural Metrics

Many other structural metrics have been proposed and investigated. Chen (CHEN78A) combines structural
properties with information theoretic concepts. Gong (GONG85) combines decisions and nesting depth.
Rodriguez and Tsai (RODR86) apply structural concepts to data flowgraphs, as do Tai (TAIK84) and Tsai et al.
(TSAI86). Van Verth (VANV87) proposes using a combination of control flow and data flow, as does
Whitworth (WHIT80B). This list is incomplete as the number of papers on alternate complexity metrics is as
great as those on alternate testing strategies. The problem with these metrics is that confirming statistics on their
usefulness is lacking. It is intuitively clear that cyclomatic complexity over data flowgraphs should be as useful a
metric as cyclomatic complexity over control flowgraphs but corroboration is still lacking (OVIE80).

. HYBRID METRICS

The appearance of McCabe’s and Halstead’s metrics spurred the proposal, development, refinement, and
validation of a host of similar and related metrics, or totally different alternatives based on different assumptions.
Some of those cited below preceded McCabe’s and Halstead’s work and some followed. It’s too early to tell
which will be experimentally confirmed independently over a range of projects and applications, no matter how
rational and sensible their basis might be. Some of the more interesting and promising alternatives are presented
in BAKE79A, BAKE80, BELF79, CHAP79, CHEN78A, DEYO79, EVAN84, FEUE79B, GILB77, LIPO77,
MCCL78B, PAIG80, RAMA88, SCHN79B, VANV87, WHIT80B, and ZONL77. Most of these metrics and
their variations recognize one or more weaknesses in the popular metrics and seek to measure reliability and/or
predict bug counts through refinement or alternative formulation of the problem. It is inevitable that increased
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

predictability and fidelity can only be achieved at a cost of increased sophistication, complexity of evaluation,
and difficulty of use.

PATH PRODUCTS AND PATH EXPRESSION:

 MOTIVATION:

o Flow graphs are being an abstract representation of programs.

o Any question about a program can be cast into an equivalent question about an appropriate
flowgraph.

o Most software development, testing and debugging tools use flow graphs analysis techniques.

 PATH PRODUCTS:

o Normally flow graphs used to denote only control flow connectivity.

o The simplest weight we can give to a link is a name.

o Using link names as weights, we then convert the graphical flow graph into an equivalent
algebraic like expressions which denotes the set of all possible paths from entry to exit for the
flow graph.

o Every link of a graph can be given a name.

o The link name will be denoted by lower case italic letters.

o In tracing a path or path segment through a flow 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
concatenating 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:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 5.1: Examples of paths.

 PATH EXPRESSION:

o Consider a pair of nodes in a graph and the set of paths between those node.

o Denote that set of paths by Upper case letter such as X,Y. From Figure 5.1c, the members of the
path set can be listed as follows:

ac, abc, abbc, abbbc, abbbbc.............

o Alternatively, the same set of paths can be denoted by :

ac+abc+abbc+abbbc+abbbbc+...........

o The + sign is understood to mean "or" between the two nodes of interest, paths ac, or abc, or abbc,
and so on can be taken.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Any expression that consists of path names and "OR"s and which denotes a set of paths between
two nodes is called a "Path Expression.".

 PATH PRODUCTS:

o The name of a path that consists of two successive path segments is conveniently expressed by the
concatenation or Path Product of the segment names.

o For example, if X and Y are defined as X=abcde,Y=fghij,then the path corresponding to X


followed by Y is denoted by

XY=abcdefghij

o Similarly,

o YX=fghijabcde

o aX=aabcde

o 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

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 repetitions:

o a1 = a; a2 = aa; a3 = aaa; an = aaaa . . . n times.

Similarly, if
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

X = abcde

then

X1 = abcde

X2 = abcdeabcde = (abcde)2

X3 = abcdeabcdeabcde = (abcde)2abcde

= abcde(abcde)2 = (abcde)3

o The path product is not commutative (that is XY!=YX).

o The path product is Associative.

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:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 5.2: Examples of path sums.

The first set of parallel paths is denoted by X + Y + d and the second set by U + V + W + h + i + j. The set of all
paths in this flowgraph is f(X + Y + d)g(U + V + W + h + i + j)k

o The path is a set union operation, it is clearly Commutative and Associative.

o RULE 2: X+Y=Y+X

o RULE 3: (X+Y)+Z=X+(Y+Z)=X+Y+Z

 DISTRIBUTIVE LAWS:

o The product and sum operations are distributive, and the ordinary rules of multiplication 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 (Absorption 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,
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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 identical path expressions reduces to the same path expression.

 LOOPS:

o Loops can be understood as an infinite 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+..............

Figure 5.3: Examples of path loops.

o This potentially infinite sum is denoted by b* for an individual link and by X* when X is a path
expression.

Figure 5.4: Another example of path loops.

o The path expression for the above figure is denoted by the notation:

ab*c=ac+abc+abbc+abbbc+................

o Evidently,
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

aa*=a*a=a+ and XX*=X*X=X+

o It is more convenient to denote the fact that a loop cannot be taken more than a certain, say n,
number of times.

o A bar is used under the exponent to denote the fact as follows:

Xn = X0+X1+X2+X3+X4+X5+..................+Xn

 RULES 6 - 16:

o The following rules can be derived from the previous rules:

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 matter how often 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 aft by a graph that has no paths , there wont be any paths.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

REDUCTION PROCEDURE:

 REDUCTION PROCEDURE ALGORITHM:

o This section presents a reduction procedure for converting a flowgraph whose links are labeled
with names into a path expression that denotes the set of all entry/exit paths in that flowgraph. The
procedure is a node-by-node removal algorithm.

o The steps in Reduction Algorithm are as follows:

1. Combine all serial links by multiplying their path expressions.

2. Combine all parallel links by adding their path expressions.

3. Remove all self-loops (from any node to itself) by replacing them with a link of the form
X*, where X is the path expression of the link in that loop.

STEPS 4 - 8 ARE IN THE ALGORIHTM'S LOOP:

4. Select any node for removal other than the initial or final node. Replace it with a set of
equivalent links whose path expressions correspond to all the ways you can form a product
of the set of inlinks with the set of outlinks of that node.

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

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

7. Remove all self-loops as in step 3.

8. Does the graph consist of a single link between the entry node and the exit node? If yes,
then the path expression for that link is a path expression for the original flowgraph;
otherwise, return to step 4.

o A flowgraph can have many equivalent path expressions between a given pair of nodes; that is,
there are many different ways to generate the set of all paths between two nodes without affecting
the content of that set.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o The appearance of the path expression depends, in general, on the order in which nodes are
removed.

 CROSS-TERM STEP (STEP 4):

o The cross - term step is the fundamental step of the reduction algorithm.

o It removes a node, thereby reducing the number of nodes by one.

o Successive applications of this step eventually get you down to one entry and one exit node. The
following diagram shows the situation at an arbitrary node that has been selected for removal:

o From the above diagram, one can infer:

o (a + b)(c + d + e) = ac + ad + + ae + bc + bd + be

 LOOP REMOVAL OPERATIONS:

o There are two ways of looking at the loop-removal operation:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o In the first way, we remove the self-loop and then multiply 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.

 A REDUCTION PROCEDURE - EXAMPLE:

o Let us see by applying this algorithm to the following graph where we remove several nodes in
order; that is

Figure 5.5: Example Flowgraph for demonstrating reduction procedure.

o Remove node 10 by applying step 4 and combine by step 5 to yield

o Remove node 9 by applying step4 and 5 to yield


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Remove node 7 by steps 4 and 5, as follows:

o Remove node 8 by steps 4 and 5, to obtain:

o PARALLEL TERM (STEP 6):


Removal of node 8 above led to a pair of parallel links between nodes 4 and 5. combine them to
create a path expression for an equivalent link whose path expression is c+gkh; that is
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o LOOP TERM (STEP 7):


Removing node 4 leads to a loop term. The graph has now been replaced with the following
equivalent simpler graph:

o Continue the process by applying the loop-removal step as follows:

o Removing node 5 produces:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Remove the loop at node 6 to yield:

o Remove node 3 to yield:

o Removing the loop and then node 6 result in the following expression:

o a(bgjf)*b(c+gkh)d((ilhd)*imf(bjgf)*b(c+gkh)d)*(ilhd)*e

o You can practice by applying the algorithm on the following flowgraphs and generate their
respective path expressions:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 5.6: Some graphs and their path expressions.

APPLICATIONS:

 APPLICATIONS:

o The purpose of the node removal algorithm is to present one very generalized concept- the path
expression and way of getting it.

o Every application follows this common pattern:

1. Convert the program or graph into a path expression.

2. Identify a property of interest and derive an appropriate set of "arithmetic" rules that
characterizes the property.

3. Replace the link names by the link weights for the property of interest. The path
expression has now been converted to an expression in some algebra, such as ordinary
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

algebra, regular expressions, or boolean algebra. This algebraic expression summarizes the
property of interest over the set of all paths.

4. Simplify or evaluate the resulting "algebraic" expression to answer the question you asked.

 HOW MANY PATHS IN A FLOWGRAPH ?

o The question is not simple. Here are some ways you could ask it:

1. What is the maximum number of different paths possible?

2. What is the fewest number of paths possible?

3. How many different paths are there really?

4. What is the average number of paths?

o Determining the actual number of different paths is an inherently difficult problem because there
could be unachievable paths resulting from correlated and dependent predicates.

o If we know both of these numbers (maximum and minimum number of possible paths) we have a
good idea of how complete our testing is.

o Asking for "the average number of paths" is meaningless.

 MAXIMUM PATH COUNT ARITHMETIC:

o Label each link with a link weight that corresponds to the number of paths that link represents.

o Also mark each loop with the maximum number of times that loop can be taken. If the answer is
infinite, you might as well stop the analysis because it is clear that the maximum number of paths
will be infinite.

o There are three cases of interest: parallel links, serial links, and loops.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o This arithmetic is an ordinary algebra. The weight is the number of paths in each set.

o EXAMPLE:

1. The following is a reasonably well-structured program.

Each link represents a single link and consequently is given a weight of "1" to start. Lets say the outer loop will
be taken exactly four times and inner Loop Can be taken zero or three times Its path expression, with a little
work, is:

Path expression: a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh

2. A: The flow graph should be annotated by replacing the link name with the maximum of
paths through that link (1) and also note the number of times for looping.

3. B: Combine the first pair of parallel loops outside the loop and also the pair in the outer
loop.

4. C: Multiply the things out and remove nodes to clear the clutter.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

5. For the Inner Loop:


D:Calculate the total weight of inner loop, which can execute a min. of 0 times and max.
of 3 times. So, it inner loop can be evaluated as follows:

13 = 10 + 11 + 12 + 13 = 1 + 1 + 1 + 1 = 4

6. E: Multiply the link weights inside the loop: 1 X 4 = 4

7. F: Evaluate the loop by multiplying the link wieghts: 2 X 4 = 8.

8. G: Simpifying the loop further results in the total maximum number of paths in the
flowgraph:

2 X 84 X 2 = 32,768.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Alternatively, you could have substituted a "1" for each link in the path expression and then
simplified, as follows:

a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh
= 1(1 + 1)1(1(1 x 1)31 x 1 x 1(1 + 1)1)41(1 x 1)31 x 1 x 1
= 2(131 x (2))413
= 2(4 x 2)4 x 4
= 2 x 84 x 4 = 32,768

o This is the same result we got graphically.

o Actually, the outer loop should be taken exactly four times. That doesn't mean it will be taken
zero or four times. Consequently, there is a superfluous "4" on the outlink in the last step.
Therefore the maximum number of different paths is 8192 rather than 32,768.

 STRUCTURED FLOWGRAPH:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Structured code can be defined in several different ways that do not involve ad-hoc rules such as
not using GOTOs.

o A structured flowgraph is one that can be reduced to a single link by successive application of the
transformations of Figure 5.7.

Figure 5.7: Structured Flowgraph Transformations.

o The node-by-node reduction procedure can also be used as a test for structured code.

o 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


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 5.8: Un-structured sub-graphs.

 LOWER PATH COUNT ARITHMETIC:

o A lower bound on the number of paths in a routine can be approximated for structured flow
graphs.

o The arithmetic is as follows:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o The values of the weights are the number of members in a set of paths.

o EXAMPLE:

1. Applying the arithmetic to the earlier example gives us the identical steps unitl step 3 (C)
as below:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. From Step 4, the it would be different from the previous example:

3. If you observe the original graph, it takes at least two paths to cover and that it can be done
in two paths.

4. If you have fewer paths in your test plan than this minimum you probably haven't covered.
It's another check.

 CALCULATING THE PROBABILITY:

o Path selection should be biased toward the low - rather than the high-probability paths.

o This raises an interesting question:

What is the probability of being at a certain point in a routine?


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

This question can be answered under suitable assumptions, primarily that all probabilities
involved are independent, which is to say that all decisions are independent and uncorrelated.

o We use the same algorithm as before : node-by-node removal of uninteresting nodes.

o Weights, Notations and Arithmetic:

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

2. Annotate each outlink with a weight equal to the probability of going in that direction.

3. Evidently, the sum of the outlink probabilities must equal 1

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

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

6. The arithmetic rules are those of ordinary arithmetic.

7. 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.

8. 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 PB, then the probability that you do either is PA + PB.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. For the series case, if you must do both things, and their probabilities are
independent (as assumed), then the probability that you do both is the product of
their probabilities.

9. For example, a loop node has a looping probability of PL and a probability of not looping
of PA, which is obviously equal to I - PL.

10. Following the above rule, all we've done is replace the outgoing probability with 1 - so
why the complicated rule? After a few steps in which you've removed nodes, combined
parallel terms, removed loops and the like, you might find something like this:

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

which is what we've postulated for any decision. In other words, division by 1 - PL renormalizes the outlink
probabilities so that their sum equals unity after the loop is removed.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o EXAMPLE:

1. Here is a complicated bit of logic. We want to know the probability associated with cases
A, B, and C.

2. Let us do this in three parts, starting with case A. Note that the sum of the probabilities 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 reduction procedure. To avoid clutter, we usually leave out
probabilities equal to 1.

CASE A:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Case B is simpler:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

4. Case C is similar and should yield a probability of 1 - 0.125 - 0.158 = 0.717:

5. This checks. It's a good idea when doing this sort of thing to calculate all the probabilities
and to verify that the sum of the routine's exit probabilities does equal 1.

6. If it doesn't, then you've made calculation error or, more likely, you've left out some
branching probability.

7. How about path probabilities? That's easy. Just trace the path of interest and multiply the
probabilities as you go.

8. Alternatively, write down the path name and do the indicated arithmetic operation.

9. Say that a path consisted of links a, b, c, d, e, and the associated probabilities were .2, .5,
1., .01, and I respectively. Path abcbcbcdeabddea would have a probability of 5 x 10-10.

10. Long paths are usually improbable.

 MEAN PROCESSING TIME OF A ROUTINE:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Given the execution time of all statements or instructions for every link in a flowgraph and the
probability for each direction for all decisions are to find the mean processing time for the routine
as a whole.

o The model has two weights associated with every link: the processing time for that link, denoted
by T, and the probability of that link P.

o The arithmetic rules for calculating the mean time:

o EXAMPLE:

1. Start with the original flow graph annotated with probabilities and processing time.

2. Combine the parallel links of the outer loop. The result is just the mean of the processing
times for the links because there aren't any other links leaving the first node. Also combine
the pair of links at the beginning of the flowgraph..
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Combine as many serial links as you can.

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 time, by using the arithmetic rules as follows:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 PUSH/POP, GET/RETURN:

o This model can be used to answer several different questions that can turn up in debugging.

o It can also help decide which test cases to design.

o The question is:

Given a pair of complementary operations such as PUSH (the stack) and POP (the stack),
considering the set of all possible paths through the routine, what is the net effect of the routine?
PUSH or POP? How many times? Under what conditions?

o Here are some other examples of complementary operations to which this model applies:

o GET/RETURN a resource block.

o OPEN/CLOSE a file.

START/STOP a device or process.

o EXAMPLE 1 (PUSH / POP):

1. Here is the Push/Pop Arithmetic:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. The numeral 1 is used to indicate that nothing of interest (neither PUSH nor POP) occurs
on a given link.

3. "H" denotes PUSH and "P" denotes POP. The operations are commutative, associative,
and distributive.

4. Consider the following flowgraph:

P(P + 1)1{P(HH)n1HP1(P + H)1}n2P(HH)n1HPH

5. Simplifying by using the arithmetic tables,


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

6. =(P2 + P){P(HH)n1(P + H)}n1(HH)n1

7. =(P2 + P){H2n1(P2 + 1)}n2H2n1

8. Below Table 5.9 shows several combinations of values for the two looping terms - M1 is
the number of times the inner loop will be taken and M2 the number of times the outer
loop will be taken.

Figure 5.9: Result of the PUSH / POP Graph Analysis.

9. These expressions state that the stack will be popped only if the inner loop is not taken.

10. The stack will be left alone only if the inner loop is iterated once, but it may also be
pushed.

11. For all other values of the inner loop, the stack will only be pushed.

o EXAMPLE 2 (GET / RETURN):


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

1. Exactly the same arithmetic tables used for previous example are used for GET /
RETURN a buffer block or resource, or, in fact, for any pair of complementary operations
in which the total number of operations in either direction is cumulative.

2. The arithmetic tables for GET/RETURN are:

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

3. Consider the following flowgraph:

4. G(G + R)G(GR)*GGR*R
= G(G + R)G3R*R
= (G + R)G3R*
= (G4 + G2)R*

5. This expression specifies the conditions under which the resources will be balanced on
leaving the routine.

6. If the upper branch is taken at the first decision, the second loop must be taken four times.

7. If the lower branch is taken at the first decision, the second loop must be taken twice.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

8. For any other values, the routine will not balance. Therefore, the first loop does not have
to be instrumented to verify this behavior because its impact should be nil.

 LIMITATIONS AND SOLUTIONS:

o The main limitation to these applications is the problem of unachievable paths.

o The node-by-node reduction procedure, and most graph-theory-based algorithms work well when
all paths are possible, but may provide misleading results when some paths are unachievable.

o The approach to handling unachievable paths (for any application) is to partition the graph into
subgraphs so that all paths in each of the subgraphs are achievable.

o The resulting subgraphs may overlap, because one path may be common to several different
subgraphs.

o Each predicate's truth-functional value potentially splits the graph into two subgraphs. For n
predicates, there could be as many as 2n subgraphs.

REGULAR EXPRESSIONS AND FLOW ANOMALY DETECTION:

 THE PROBLEM:

o The generic flow-anomaly detection problem (note: not just data-flow anomalies, but any flow
anomaly) is that of looking for a specific sequence of options considering all possible paths
through a routine.

o Let the operations be SET and RESET, denoted by s and r respectively, and we want to know if
there is a SET followed immediately a SET or a RESET followed immediately by a RESET
(an ss or an rr sequence).

o Some more application examples:

1. A file can be opened (o), closed (c), read (r), or written (w). If the file is read or written to
after it's been closed, the sequence is nonsensical. Therefore, cr and cw are anomalous.
Similarly, if the file is read before it's been written, just after opening, we may have a bug.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Therefore, or is also anomalous. Furthermore, oo and cc, though not actual bugs, are a
waste of time 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 flowgraph lead to anomalous sequences on any
path? If so, what sequences and under what circumstances?

3. The data-flow anomalies discussed in Unit 4 requires us to detect the dd, dk, kk,
and ku sequences. Are there paths with anomalous data flows?

 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) ABnC, then T will appear in AB2C. (HUANG's Theorem)

o As an example, let

A = pp
B = srr
C = rp
T = ss

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

o However, let

A = p + pp + ps
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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

(p + pp + ps)[psr + ps(r + ps)]2rp

Multiplying out the expression and simplifying shows that there is no p4 sequence.

o Incidentally, the above observation is an informal proof of the wisdom of looping twice discussed
in Unit 2. Because data-flow anomalies are represented by two-character sequences, it follows the
above theorem that looping twice is what you need to do to find such anomalies.

 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 utilitarian limit for manual application.

o There are some nice theorems for finding sequences that occur at the beginnings and ends of
strings but no nice algorithms for finding strings buried in an expression.

o Static flow analysis methods can't determine whether a path is or is not achievable. Unless the
flow analysis includes symbolic execution or similar techniques, the impact of unachievable paths
will not be included in the analysis.

o The flow-anomaly application, for example, doesn't tell us that there will be a flow anomaly - it
tells us that if the path is achievable, then there will be a flow anomaly. Such analytical problems
go away, of course, if you take the trouble to design routines for which all paths are achievable.

SUMMARY:

 A flowgraph annotated with link names for every link can be converted into a path expression that
represents the set of all paths in that flowgraph. A node-by-node reduction procedure is used.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 By substituting link weights for all links, and using the appropriate arithmetic rules, the path expression is
converted into an algebraic expression that can be used to determine the minimum and maximum number
of possible paths in a flowgraph, the probability that a given node will be reached, the mean processing
time of a routine, and other models.

 With different, suitable arithmetic rules, and by using complementary operators as weights for the links,
the path expression can be converted into an expression that denotes, over the set of all possible paths,
what the net effect of the routine is.

 With links annotated with the appropriate weights, the path expression is converted into a regular
expression that denotes the set of all operator sequences over the set of all paths in a routine. Rules for
determining whether a given sequence of operations are possible are given. In other words, we have a
generalized flow-anomaly detection method that'll work for data-flow anomalies or any other flow
anomaly.

All flow analysis methods lose accuracy and utility if there are unachievable paths. Expand the accuracy and
utility of your analytical tools by designs for which all paths are achievable. Such designs are always possible.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Unit IV
Linguistic –Metrics – Structural Metric – Path Products and Path Expressions. Syntax Testing–
Formats–Test Cases

METRICS, WHAT AND WHY

2.2. Historical Perspective

There’s no record of programming labor estimates on ENIAC, but I’m sure they fell far short of reality. The first
programmer, Lady Lovelace, who coded for Charles Babbage’s wonderful but unfinished computer in the
nineteenth century, I’m sure often said “Just one more week, Mr. Babbage, and it’ll be done.” Lucky for her the
hardware was never finished, so she didn’t have to go beyond desk checking. By the mid-1950s individual
programmers had coalesced into programming groups, which meant there was now a new profession—
programmer manager. The managers, who were responsible for productivity and quality, began to measure
software effort in terms of “number of lines of code.” That was used to predict programming costs, testing costs,
running time, number of bugs, salaries, the gross national product, the inflation rate of the peso, and who knows
what else. It is today still the primary quantitative measure in use: “Count the number of lines of code, and you
know all there is to know 2.3. Objectives

2.3.1. How Big Is It?

Science begins with quantification: you can’t do physics without a notion of length and time; you can’t do
thermodynamics until you measure temperature. The most fundamental question you can ask is “How big is it?”
Without defining what “big” means, it’s obvious that it makes no sense to say “This program will need more
testing than that program” unless we know how big they are relative to one another. Comparing two strategies
also needs a notion of size. The number of tests required by a strategy should be normalized to size. For example,
“Strategy A needs 1.4 tests per unit of size, while strategy B needs 4.3 tests per unit of size.”

What is meant by “size” is not obvious in the early phases of science development. Newton’s use of mass instead
of weight was a breakthrough for physics, and early researchers in thermodynamics had heat, temperature, and
entropy hopelessly confused. We seem to be doing about as well (or as badly) as the sixteenth- and seventeenth-
century physicists did at a comparable phase of development. “Size” isn’t obvious for software. .3.2. The
Questions
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Our objective in this book is not to quantify all of computer science, but only to explore those metrics of
complexity that have proved their worth in practice. To see what kinds of metrics we need, let’s ask some
questions:

1. When can we stop testing?

2. How many bugs can we expect?

3. Which test technique is more effective?

4. Are we testing hard or are we testing smart?

5. Do we have a strong program or a weak test suite?

2.3.3. Desirable Metric Properties

A useful metric should satisfy several requirements:**

**
A formal examination of metrics requirements by Weyuker (WEYU88B) formally extends these concepts and
evaluates the extent to which several popular metrics, including statement count, cyclomatic number, Halstead’s
effort metric, and dataflow complexity do or do not meet them.

1. It can be calculated, uniquely, for all programs to which we apply it.

2. It need not be calculated for programs that change size dynamically or programs that in principle cannot be
debugged.

3. Adding something to a program (e.g., instructions, storage, processing time) can never decrease the measured
complexity.

2.3.4. Metrics Taxonomy

There’s no agreement in the literature on how to classify metrics—and there are so many metrics to classify.
Here are some broad categories: linguistic metrics, structural metrics, and hybrid metrics. Each can be applied to
either programs or specifications; to date, however, application to programs has dominated. The taxonomy is not
rigid because a narrowly defined linguistic metric can define a structural property. For example, cyclomatic
complexity can be defined in terms of links and nodes in the control flowgraph or alternatively by the number of
equivalent branches in the program.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Linguistic Metrics—Metrics based on measuring properties of program or specification text without interpreting
what that text means or the ordering of components of the text. For example: lines of code, number of statements,
number of unique operators, number of unique operands, total number of operators, total number of operands,
total number of keyword appearances, total number of tokens.

Structural Metrics—Metrics based on structural relations between objects in the program—usually metrics on
properties of control flowgraphs or data flowgraphs; for example, number of links, number of nodes, nesting
depth.

Hybrid Metrics—Metrics based on some combination of structural and linguistic properties of a program or
based on a function of both structural and linguistic properties

3. LINGUISTIC METRICS

3.1. General

Linguistic metrics measure some property of text without interpreting what is measured. A metric is (mainly)
linguistic if its value doesn’t change when you rearrange the text. Linguistic metrics, to date, have been applied
mostly to program text. They can be just as easily applied to formal specifications, but because formal,
processable specifications are rare, there is almost no experience with such usage; but see RAMA85.

3.2. Lines of Code, Statement Count, and Related Metrics

3.2.1. What Is It?

Count the number of lines of code in a program and use that number as a measure of complexity. If then, bugs
appear to occur at 1% per line, a 1000-line program should have 10 bugs and a 10,000 line program should have
100. Going further, if we find that it takes an average of twenty tests to find a bug, we might infer (empirically)
the expected number of tests needed per line of code.

3.2.2. What to Count and Not Count

Early users of lines of code did not include data declarations, comments, or any other lines that did not result in
object code. Later users decided to include declarations and other unexecutable statements but still excluded
comments and blank lines. The reason for this shift is the recognition that contemporary code can have 50% or
more data statements and that bugs occur as often in such statements as in “real” code. There is a rationale for
including comments. The quality of comments materially affects maintenance costs because the maintenance
programmer will depend on the comments more than anything else to do her job. Conversely, too many blank
lines and wordy but information-poor comments will increase maintenance effort. The problem with including
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

comments is that we must be able to distinguish between useful and useless comments, and there’s no rigorous
way to do that. The same can be said of blank lines and formatting text: a little helps us read the code but too
much forces us into excessive page turning.

3.2.3. Statement Counts

Some of the difficulties with lines of code can be overcome by using statements instead—but this evokes new
problems that are as bad as those of lines of code. The problem, aptly stated by Levitin (LEVI86) is that there’s
no unique way to count statements in some languages (e.g., Pascal), and there’s no simple rule for defining
“statement” across different languages. Just as subjectivity is involved in applying lines of code, there’s
subjectivity in deciding what is and what is not to be called a statement (for some languages).

3.2.4. How Good (Bad) Are They?

Thayer, Lipow and Nelson, in their monumental software reliability study (THAY76) showed error rates ranging
from 0.04% to 7% when measured against statement counts, with the most reliable routine being one of the
largest. The same lack of useful correlation is shown in Rubey (RUBE75). Curtis, Sheppard, and Milliman
(CURT79A) show that lines of code is as good as other metrics for small programs, but is optimistic for big
programs. Moderate performance is also reported for lines of code by Schneidewind (SCHN79A). The definitive
report on the relation between program size and bug rate is Lipow’s (LIPO82). In his study of 115,000 JOVIAL
statements, he found a nonlinear relation between bugs per line of code and statements; but also included other
factors related to language type and modularization. Small programs had an error rate of 1.3% to 1.8%, with big
programs increasing from 2.7% to 3.2%. Lipow’s study, however, and most of the others, only included
executable lines and not data declarations. The bottom line is that lines of code is reasonably linear for small
programs (under 100 lines) but increases nonlinearly with program size. It seems to correlate with maintenance
costs.

3.3. Halstead’s Metrics

3.3.1. What Are They?

Halstead’s metrics are based on a combination of arguments derived from common sense, information theory,
and psychology. The clearest exposition is still to be found in Halstead’s Elements of Software Science
(HALS77). It’s an easy-to-read little book that should be read before applying these metrics. The following
exposition is intended only as an introductory overview. The set of metrics are based on two, easily measured,
parameters of programs:

n1 = the number of distinct operators in the program (e.g., keywords)


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

n2 = the number of distinct operands in the program (e.g., data objects)

From these he defines program length, which is not to be confused with the number of statements in a program,
by the following relation:

H = n1 log2 n1 + n2 log2 n2 (1)*

3.3.2. How Good?

Confirmation of these metrics has been extensively published by Halstead and others. The most solid
confirmation of the bug prediction equation is by Lipow (LIPO82), who compared actual to predicted bug counts
to within 8% over a range of programs sizes from 300 to 12,000 executable statements. The analysis was of
postcompilation bugs, so that syntax errors caught by the compiler are properly excluded. However, of the
115,000 statements in the experiment, only the 75,000 executable statements were examined. It would be
interesting to see whether better accuracy would have been obtained had all declarations been included in the
analysis. Ottenstein, in an earlier report (OTTE79), showed similar good correlation. Curtis (CURT79A) shows
that Halstead’s metrics are at least twice as good as lines of code and are not improved by augmenting them with
lines of code or with McCabe’s metric.

3.3.3. The Hidden Assumptions and Weaknesses

Because Halstead’s metric is the best established (serious) linguistic metric we have, it’s fitting that it be
subjected to the harshest criticism. There are fewer hidden assumptions in Halstead’s work than in other
comparable efforts, but some assumptions and weaknesses still remain. Some of the following weaknesses apply
to all linguistic metrics.

1. Modularity—Modularity is not ignored because each call, together with the parameters of the call
sequence, will contribute to the values of n1, n2, N1, and N2, and therefore to the predicted bug count. Note
that Halstead treats each distinct subroutine call as a unique operator and not just as the one keyword
“CALL.” In this respect, the impact of hypermodularity on bug rate is not ignored.

2. 2. Database Impact and Declarations—Halstead isn’t to be faulted on this one. It’s just that most
evaluators and confirmers have continued the erroneous practice of ignoring unexecutable statements
such as declarations and data statements—which is to say that most initialization and data structure bugs
are ignored. They can’t be faulted for this entirely, because in many cases errors in data declarations and
initializing data statements are not even counted as bugs.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Opera/Operand Ambiguity—There is a hidden assumption that code is code and data are data, and never
the twain should meet. If Halstead’s metrics are rigidly applied to an assembly language program that
does extensive modification of its own code (ugh!) it will predict the same bug count as a routine that
performs the same operations on a fixed data area.

4. Data-Type Distinctions—In strongly typed languages that force the explicit declaration of all types and
prohibit mixed-type operations unless a type conversion statement has been inserted, the weakness does
not exist if we count all type conversation statements, whether or not they result in object code. If we
count all declarations, including user-defined type declarations, there is no weakness in Halstead’s
metrics.

5. Call Depth—No notice is made of call depth. A routine that calls ten different subroutines as a sequence
of successive calls would actually be considered more complex than a routine that had ten nested calls. If
the totality of the routines and all that it calls were considered, the bug prediction would be the same for
both because the total operator and operand counts would be the same.

6. Operator Types—An IF-THEN-ELSE statement is given the same weight as a FOR-UNTIL, even though it’s
known that loops are more troublesome. This is an example of a broader criticism—that operators and operands
are treated equally, with no correlation to the bug incidence associated with specific operators or with operand
types.

7. General Structure Issues—Of these, the fact that nesting is ignored (nested loops, nested IF-THEN-ELSE,
and so on) is probably the most serious critique. A Basic statement such as

100 A = B + C @ D = SIN(A) N=9

is less bug-prone than

100 D = SIN(B + C) N=6

3.4. Token Count

Levitin, in his incisive critique of linguistic metrics (LEVI86), makes a strong argument for the use of program
token count rather than lines of code, statement count, or Halstead’s length. A token in a programming language
is the basic syntactic unit from which programs are constructed. Tokens include keywords, labels, constants,
strings, and variable names. Token counting is easy because the first stage of compilation is to translate the
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

source code into equivalent numerical tokens. The number of tokens is easily obtained as a by-product of
compilation. Token count gets around the subjectivity problems we have with statement counts and lines of code.

4. STRUCTURAL METRICS

4.1. General

Structural metrics take the opposite viewpoint of linguistic metrics. Linguistic complexity is ignored while
attention is focused on control-flow or data-flow complexity—metrics based on the properties of flowgraph
models of programs. Graph theory is more than a half-century old but the study of graph-theoretic problems and
metrics goes back three centuries: see MAYE72. If it’s a graph (i.e., it consists of links and nodes) then there are
hundreds of interesting metrics that can be applied to it: metrics whose mathematical properties have been
studied in minute detail. The thrust of structural metrics research has not been so much the invention of new
graph-theoretic metrics but the investigation of the utility of known graph-theoretic metrics. McCabe’s use of the
cyclomatic number (MCCA76) is an archetypal example.

4.2. Cyclomatic Complexity (McCabe’s Metric)

4.2.1. Definition

McCabe’s cyclornatic complexity metric (MCCA76) is defined as:

M = L — N + 2P

where

L = the number of links in the graph

N = the number of nodes in the graph

P = the number of disconnected parts of the graph (e.g., a calling program and a subroutine)

The number M that appeared alongside the flowgraphs in Chapter 3 was McCabe’s metric for that flowgraph. In
all the examples, except for the one on page 73, there was only one connected part, and consequently the value of
P was 1. Figure 7.1 shows some more examples and their associated M values.

4.2.2. Applications to Test Plan Completeness and Inspections

Evaluate the cyclomatic complexity of the program’s design (e.g., from the design control flowgraph). As part of
self-inspection, reevaluate the complexity by counting decisions in the code. Any significant difference should be
explained, because it’s more likely that the difference is due to a missing path, an extra path, or an unplanned
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

deviation from the design than to something else. Having verified the code’s cyclomatic complexity, compare the
number of planned test cases to the code’s complexity. In particular, count how many test cases are intended to
provide coverage. If the number of covering test cases is less than the cyclomatic complexity, there is reason for
caution, because one of the following may be true:

1. You haven’t calculated the complexity correctly. Did you miss a decision?

2. Coverage is not really complete; there’s a link that hasn’t been covered.

3. Coverage is complete, but it can be done with a few more but simpler paths.

4. It might be possible to simplify the routine.

4.2.3. When to Subroutine

McCabe’s metric can be used to help decide whether it pays to make a piece of code which is common to two or
more links into a subroutine. Consider the graph of Figure 7.3. The program has a common part that consists of
Nc nodes and Lc links. This is the part being considered for conversion to a subroutine. This common part recurs
k times in the body of the main program. The main program has Nm nodes and Lm links over and above the
common part.

EMBEDDED SUBROUTINE FOR


COMMON PART COMMON PART

Main nodes Nm + kNc Nm

Main links Lm + kLc Lm + k

Subnodes 0 Nc + 2

Sublinks 0 Lc

Main complexity Lm + kLc – Nm + kNc + 2 Lm + k

Subcomplexity 0 L c – Nc – 2 + 2 = L c – Nc = M
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Total complexity + 2 Lm + kLc – Nm + kNc + 2 L m + L c – Nm – Nc + k + 2

.2.4. A Refinement

Myers (MYER77) points out a weakness of McCabe’s metric and suggests the use of a refinement thereto. A
decision statement in languages such as FORTRAN can contain a compound predicate of the form: IF A & B &
C THEN . . . . A statement such as this could be implemented as a string of IFs, resulting in a different
complexity measure. Figure 7.4 shows three alternate, equivalent, representations of the same IF-THEN-ELSE
statement. If the compound predicate is used in a single statement as in the first case, the complexity of the
construct is only two, but if it is broken down into its constituent parts, the complexity increases to four.
However, intuitively, all three constructs should have the same complexity. The refinement consists of
accounting for each term of the predicate expression separately. For a predicate expression of the form A&B&C .
. . , each predicate should be counted as if it was a decision. In more complicated expressions, such as A&B&C
OR D&E . . . , again count each predicate. If a predicate appears more than once in an expression, you can take a
pessimistic point of view and count each appearance or a slightly optimistic point of view and count only the first
appearance.

4.2.5. How Good a Measure; A Critique

Statistics on how well McCabe’s metric correlates with design, test, and debugging difficulty are encouraging
(BELF79, CHEN78A, CURT79A, ENDR75, FEUE79A, FEUE79B, LIPO77, SCHN79A, SCHN79B,
SCHN79D, SHEP79C, THAY76, WALS79, ZOLN77).* The reported results confirm the utility of McCabe’s
metric as a convenient rule of thumb that is significantly superior to statement count.

*
Not all of these references provide direct information for McCabe’s metric. Some (ENDR75, THAY76) provide
correlations to decision counts and similar metrics that can be converted to McCabe’s metric. Note also that if we
forget the structural basis of cyclomatic complexity and merely use equivalent binary decision count or simple
predicate count, then this metric can be obtained by purely linguistic means.

4.3. Other Structural Metrics


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Many other structural metrics have been proposed and investigated. Chen (CHEN78A) combines structural
properties with information theoretic concepts. Gong (GONG85) combines decisions and nesting depth.
Rodriguez and Tsai (RODR86) apply structural concepts to data flowgraphs, as do Tai (TAIK84) and Tsai et al.
(TSAI86). Van Verth (VANV87) proposes using a combination of control flow and data flow, as does
Whitworth (WHIT80B). This list is incomplete as the number of papers on alternate complexity metrics is as
great as those on alternate testing strategies. The problem with these metrics is that confirming statistics on their
usefulness is lacking. It is intuitively clear that cyclomatic complexity over data flowgraphs should be as useful a
metric as cyclomatic complexity over control flowgraphs but corroboration is still lacking (OVIE80).

. HYBRID METRICS

The appearance of McCabe’s and Halstead’s metrics spurred the proposal, development, refinement, and
validation of a host of similar and related metrics, or totally different alternatives based on different assumptions.
Some of those cited below preceded McCabe’s and Halstead’s work and some followed. It’s too early to tell
which will be experimentally confirmed independently over a range of projects and applications, no matter how
rational and sensible their basis might be. Some of the more interesting and promising alternatives are presented
in BAKE79A, BAKE80, BELF79, CHAP79, CHEN78A, DEYO79, EVAN84, FEUE79B, GILB77, LIPO77,
MCCL78B, PAIG80, RAMA88, SCHN79B, VANV87, WHIT80B, and ZONL77. Most of these metrics and
their variations recognize one or more weaknesses in the popular metrics and seek to measure reliability and/or
predict bug counts through refinement or alternative formulation of the problem. It is inevitable that increased
predictability and fidelity can only be achieved at a cost of increased sophistication, complexity of evaluation,
and difficulty of use.

PATH PRODUCTS AND PATH EXPRESSION:

 MOTIVATION:

o Flow graphs are being an abstract representation of programs.

o Any question about a program can be cast into an equivalent question about an appropriate
flowgraph.

o Most software development, testing and debugging tools use flow graphs analysis techniques.

 PATH PRODUCTS:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Normally flow graphs used to denote only control flow connectivity.

o The simplest weight we can give to a link is a name.

o Using link names as weights, we then convert the graphical flow graph into an equivalent
algebraic like expressions which denotes the set of all possible paths from entry to exit for the
flow graph.

o Every link of a graph can be given a name.

o The link name will be denoted by lower case italic letters.

o In tracing a path or path segment through a flow 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
concatenating 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:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 5.1: Examples of paths.

 PATH EXPRESSION:

o Consider a pair of nodes in a graph and the set of paths between those node.

o Denote that set of paths by Upper case letter such as X,Y. From Figure 5.1c, the members of the
path set can be listed as follows:

ac, abc, abbc, abbbc, abbbbc.............

o Alternatively, the same set of paths can be denoted by :

ac+abc+abbc+abbbc+abbbbc+...........

o The + sign is understood to mean "or" between the two nodes of interest, paths ac, or abc, or abbc,
and so on can be taken.

o Any expression that consists of path names and "OR"s and which denotes a set of paths between
two nodes is called a "Path Expression.".

 PATH PRODUCTS:

o The name of a path that consists of two successive path segments is conveniently expressed by the
concatenation or Path Product of the segment names.

o For example, if X and Y are defined as X=abcde,Y=fghij,then the path corresponding to X


followed by Y is denoted by

XY=abcdefghij

o Similarly,

o YX=fghijabcde

o aX=aabcde

o Xa=abcdea

XaX=abcdeaabcde
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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

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 repetitions:

o a1 = a; a2 = aa; a3 = aaa; an = aaaa . . . n times.

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 commutative (that is XY!=YX).

o The path product is Associative.

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.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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:

Figure 5.2: Examples of path sums.

The first set of parallel paths is denoted by X + Y + d and the second set by U + V + W + h + i + j. The set of all
paths in this flowgraph is f(X + Y + d)g(U + V + W + h + i + j)k

o The path is a set union operation, it is clearly Commutative and Associative.

o RULE 2: X+Y=Y+X

o RULE 3: (X+Y)+Z=X+(Y+Z)=X+Y+Z

 DISTRIBUTIVE LAWS:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o The product and sum operations are distributive, and the ordinary rules of multiplication 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 (Absorption 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 identical path expressions reduces to the same path expression.

 LOOPS:

o Loops can be understood as an infinite 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+..............

Figure 5.3: Examples of path loops.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o This potentially infinite sum is denoted by b* for an individual link and by X* when X is a path
expression.

Figure 5.4: Another example of path loops.

o The path expression for the above figure is denoted by the notation:

ab*c=ac+abc+abbc+abbbc+................

o Evidently,

aa*=a*a=a+ and XX*=X*X=X+

o It is more convenient to denote the fact that a loop cannot be taken more than a certain, say n,
number of times.

o A bar is used under the exponent to denote the fact as follows:

Xn = X0+X1+X2+X3+X4+X5+..................+Xn

 RULES 6 - 16:

o The following rules can be derived from the previous rules:

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+


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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 matter how often 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 aft by a graph that has no paths , there wont be any paths.

REDUCTION PROCEDURE:

 REDUCTION PROCEDURE ALGORITHM:

o This section presents a reduction procedure for converting a flowgraph whose links are labeled
with names into a path expression that denotes the set of all entry/exit paths in that flowgraph. The
procedure is a node-by-node removal algorithm.

o The steps in Reduction Algorithm are as follows:

1. Combine all serial links by multiplying their path expressions.

2. Combine all parallel links by adding their path expressions.

3. Remove all self-loops (from any node to itself) by replacing them with a link of the form
X*, where X is the path expression of the link in that loop.

STEPS 4 - 8 ARE IN THE ALGORIHTM'S LOOP:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

4. Select any node for removal other than the initial or final node. Replace it with a set of
equivalent links whose path expressions correspond to all the ways you can form a product
of the set of inlinks with the set of outlinks of that node.

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

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

7. Remove all self-loops as in step 3.

8. Does the graph consist of a single link between the entry node and the exit node? If yes,
then the path expression for that link is a path expression for the original flowgraph;
otherwise, return to step 4.

o A flowgraph can have many equivalent path expressions between a given pair of nodes; that is,
there are many different ways to generate the set of all paths between two nodes without affecting
the content of that set.

o The appearance of the path expression depends, in general, on the order in which nodes are
removed.

 CROSS-TERM STEP (STEP 4):

o The cross - term step is the fundamental step of the reduction algorithm.

o It removes a node, thereby reducing the number of nodes by one.

o Successive applications of this step eventually get you down to one entry and one exit node. The
following diagram shows the situation at an arbitrary node that has been selected for removal:

o From the above diagram, one can infer:

o (a + b)(c + d + e) = ac + ad + + ae + bc + bd + be
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 LOOP REMOVAL OPERATIONS:

o There are two ways of looking at the loop-removal operation:

o In the first way, we remove the self-loop and then multiply 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.

 A REDUCTION PROCEDURE - EXAMPLE:

o Let us see by applying this algorithm to the following graph where we remove several nodes in
order; that is

Figure 5.5: Example Flowgraph for demonstrating reduction procedure.

o Remove node 10 by applying step 4 and combine by step 5 to yield


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Remove node 9 by applying step4 and 5 to yield

o Remove node 7 by steps 4 and 5, as follows:

o Remove node 8 by steps 4 and 5, to obtain:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o PARALLEL TERM (STEP 6):


Removal of node 8 above led to a pair of parallel links between nodes 4 and 5. combine them to
create a path expression for an equivalent link whose path expression is c+gkh; that is

o LOOP TERM (STEP 7):


Removing node 4 leads to a loop term. The graph has now been replaced with the following
equivalent simpler graph:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Continue the process by applying the loop-removal step as follows:

o Removing node 5 produces:

o Remove the loop at node 6 to yield:

o Remove node 3 to yield:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Removing the loop and then node 6 result in the following expression:

o a(bgjf)*b(c+gkh)d((ilhd)*imf(bjgf)*b(c+gkh)d)*(ilhd)*e

o You can practice by applying the algorithm on the following flowgraphs and generate their
respective path expressions:

Figure 5.6: Some graphs and their path expressions.

APPLICATIONS:

 APPLICATIONS:

o The purpose of the node removal algorithm is to present one very generalized concept- the path
expression and way of getting it.

o Every application follows this common pattern:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

1. Convert the program or graph into a path expression.

2. Identify a property of interest and derive an appropriate set of "arithmetic" rules that
characterizes the property.

3. Replace the link names by the link weights for the property of interest. The path
expression has now been converted to an expression in some algebra, such as ordinary
algebra, regular expressions, or boolean algebra. This algebraic expression summarizes the
property of interest over the set of all paths.

4. Simplify or evaluate the resulting "algebraic" expression to answer the question you asked.

 HOW MANY PATHS IN A FLOWGRAPH ?

o The question is not simple. Here are some ways you could ask it:

1. What is the maximum number of different paths possible?

2. What is the fewest number of paths possible?

3. How many different paths are there really?

4. What is the average number of paths?

o Determining the actual number of different paths is an inherently difficult problem because there
could be unachievable paths resulting from correlated and dependent predicates.

o If we know both of these numbers (maximum and minimum number of possible paths) we have a
good idea of how complete our testing is.

o Asking for "the average number of paths" is meaningless.

 MAXIMUM PATH COUNT ARITHMETIC:

o Label each link with a link weight that corresponds to the number of paths that link represents.

o Also mark each loop with the maximum number of times that loop can be taken. If the answer is
infinite, you might as well stop the analysis because it is clear that the maximum number of paths
will be infinite.

o There are three cases of interest: parallel links, serial links, and loops.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o This arithmetic is an ordinary algebra. The weight is the number of paths in each set.

o EXAMPLE:

1. The following is a reasonably well-structured program.

Each link represents a single link and consequently is given a weight of "1" to start. Lets say the outer loop will
be taken exactly four times and inner Loop Can be taken zero or three times Its path expression, with a little
work, is:

Path expression: a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh

2. A: The flow graph should be annotated by replacing the link name with the maximum of
paths through that link (1) and also note the number of times for looping.

3. B: Combine the first pair of parallel loops outside the loop and also the pair in the outer
loop.

4. C: Multiply the things out and remove nodes to clear the clutter.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

5. For the Inner Loop:


D:Calculate the total weight of inner loop, which can execute a min. of 0 times and max.
of 3 times. So, it inner loop can be evaluated as follows:

13 = 10 + 11 + 12 + 13 = 1 + 1 + 1 + 1 = 4

6. E: Multiply the link weights inside the loop: 1 X 4 = 4

7. F: Evaluate the loop by multiplying the link wieghts: 2 X 4 = 8.

8. G: Simpifying the loop further results in the total maximum number of paths in the
flowgraph:

2 X 84 X 2 = 32,768.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Alternatively, you could have substituted a "1" for each link in the path expression and then
simplified, as follows:

a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh
= 1(1 + 1)1(1(1 x 1)31 x 1 x 1(1 + 1)1)41(1 x 1)31 x 1 x 1
= 2(131 x (2))413
= 2(4 x 2)4 x 4
= 2 x 84 x 4 = 32,768

o This is the same result we got graphically.

o Actually, the outer loop should be taken exactly four times. That doesn't mean it will be taken
zero or four times. Consequently, there is a superfluous "4" on the outlink in the last step.
Therefore the maximum number of different paths is 8192 rather than 32,768.

 STRUCTURED FLOWGRAPH:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Structured code can be defined in several different ways that do not involve ad-hoc rules such as
not using GOTOs.

o A structured flowgraph is one that can be reduced to a single link by successive application of the
transformations of Figure 5.7.

Figure 5.7: Structured Flowgraph Transformations.

o The node-by-node reduction procedure can also be used as a test for structured code.

o 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


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 5.8: Un-structured sub-graphs.

 LOWER PATH COUNT ARITHMETIC:

o A lower bound on the number of paths in a routine can be approximated for structured flow
graphs.

o The arithmetic is as follows:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o The values of the weights are the number of members in a set of paths.

o EXAMPLE:

1. Applying the arithmetic to the earlier example gives us the identical steps unitl step 3 (C)
as below:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. From Step 4, the it would be different from the previous example:

3. If you observe the original graph, it takes at least two paths to cover and that it can be done
in two paths.

4. If you have fewer paths in your test plan than this minimum you probably haven't covered.
It's another check.

 CALCULATING THE PROBABILITY:

o Path selection should be biased toward the low - rather than the high-probability paths.

o This raises an interesting question:

What is the probability of being at a certain point in a routine?


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

This question can be answered under suitable assumptions, primarily that all probabilities
involved are independent, which is to say that all decisions are independent and uncorrelated.

o We use the same algorithm as before : node-by-node removal of uninteresting nodes.

o Weights, Notations and Arithmetic:

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

2. Annotate each outlink with a weight equal to the probability of going in that direction.

3. Evidently, the sum of the outlink probabilities must equal 1

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

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

6. The arithmetic rules are those of ordinary arithmetic.

7. 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.

8. 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 PB, then the probability that you do either is PA + PB.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. For the series case, if you must do both things, and their probabilities are
independent (as assumed), then the probability that you do both is the product of
their probabilities.

9. For example, a loop node has a looping probability of PL and a probability of not looping
of PA, which is obviously equal to I - PL.

10. Following the above rule, all we've done is replace the outgoing probability with 1 - so
why the complicated rule? After a few steps in which you've removed nodes, combined
parallel terms, removed loops and the like, you might find something like this:

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

which is what we've postulated for any decision. In other words, division by 1 - PL renormalizes the outlink
probabilities so that their sum equals unity after the loop is removed.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o EXAMPLE:

1. Here is a complicated bit of logic. We want to know the probability associated with cases
A, B, and C.

2. Let us do this in three parts, starting with case A. Note that the sum of the probabilities 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 reduction procedure. To avoid clutter, we usually leave out
probabilities equal to 1.

CASE A:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Case B is simpler:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

4. Case C is similar and should yield a probability of 1 - 0.125 - 0.158 = 0.717:

5. This checks. It's a good idea when doing this sort of thing to calculate all the probabilities
and to verify that the sum of the routine's exit probabilities does equal 1.

6. If it doesn't, then you've made calculation error or, more likely, you've left out some
branching probability.

7. How about path probabilities? That's easy. Just trace the path of interest and multiply the
probabilities as you go.

8. Alternatively, write down the path name and do the indicated arithmetic operation.

9. Say that a path consisted of links a, b, c, d, e, and the associated probabilities were .2, .5,
1., .01, and I respectively. Path abcbcbcdeabddea would have a probability of 5 x 10-10.

10. Long paths are usually improbable.

 MEAN PROCESSING TIME OF A ROUTINE:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Given the execution time of all statements or instructions for every link in a flowgraph and the
probability for each direction for all decisions are to find the mean processing time for the routine
as a whole.

o The model has two weights associated with every link: the processing time for that link, denoted
by T, and the probability of that link P.

o The arithmetic rules for calculating the mean time:

o EXAMPLE:

1. Start with the original flow graph annotated with probabilities and processing time.

2. Combine the parallel links of the outer loop. The result is just the mean of the processing
times for the links because there aren't any other links leaving the first node. Also combine
the pair of links at the beginning of the flowgraph..
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Combine as many serial links as you can.

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 time, by using the arithmetic rules as follows:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 PUSH/POP, GET/RETURN:

o This model can be used to answer several different questions that can turn up in debugging.

o It can also help decide which test cases to design.

o The question is:

Given a pair of complementary operations such as PUSH (the stack) and POP (the stack),
considering the set of all possible paths through the routine, what is the net effect of the routine?
PUSH or POP? How many times? Under what conditions?

o Here are some other examples of complementary operations to which this model applies:

o GET/RETURN a resource block.

o OPEN/CLOSE a file.

START/STOP a device or process.

o EXAMPLE 1 (PUSH / POP):

1. Here is the Push/Pop Arithmetic:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

2. The numeral 1 is used to indicate that nothing of interest (neither PUSH nor POP) occurs
on a given link.

3. "H" denotes PUSH and "P" denotes POP. The operations are commutative, associative,
and distributive.

4. Consider the following flowgraph:

P(P + 1)1{P(HH)n1HP1(P + H)1}n2P(HH)n1HPH

5. Simplifying by using the arithmetic tables,


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

6. =(P2 + P){P(HH)n1(P + H)}n1(HH)n1

7. =(P2 + P){H2n1(P2 + 1)}n2H2n1

8. Below Table 5.9 shows several combinations of values for the two looping terms - M1 is
the number of times the inner loop will be taken and M2 the number of times the outer
loop will be taken.

Figure 5.9: Result of the PUSH / POP Graph Analysis.

9. These expressions state that the stack will be popped only if the inner loop is not taken.

10. The stack will be left alone only if the inner loop is iterated once, but it may also be
pushed.

11. For all other values of the inner loop, the stack will only be pushed.

o EXAMPLE 2 (GET / RETURN):


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

1. Exactly the same arithmetic tables used for previous example are used for GET /
RETURN a buffer block or resource, or, in fact, for any pair of complementary operations
in which the total number of operations in either direction is cumulative.

2. The arithmetic tables for GET/RETURN are:

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

3. Consider the following flowgraph:

4. G(G + R)G(GR)*GGR*R
= G(G + R)G3R*R
= (G + R)G3R*
= (G4 + G2)R*

5. This expression specifies the conditions under which the resources will be balanced on
leaving the routine.

6. If the upper branch is taken at the first decision, the second loop must be taken four times.

7. If the lower branch is taken at the first decision, the second loop must be taken twice.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

8. For any other values, the routine will not balance. Therefore, the first loop does not have
to be instrumented to verify this behavior because its impact should be nil.

 LIMITATIONS AND SOLUTIONS:

o The main limitation to these applications is the problem of unachievable paths.

o The node-by-node reduction procedure, and most graph-theory-based algorithms work well when
all paths are possible, but may provide misleading results when some paths are unachievable.

o The approach to handling unachievable paths (for any application) is to partition the graph into
subgraphs so that all paths in each of the subgraphs are achievable.

o The resulting subgraphs may overlap, because one path may be common to several different
subgraphs.

o Each predicate's truth-functional value potentially splits the graph into two subgraphs. For n
predicates, there could be as many as 2n subgraphs.

REGULAR EXPRESSIONS AND FLOW ANOMALY DETECTION:

 THE PROBLEM:

o The generic flow-anomaly detection problem (note: not just data-flow anomalies, but any flow
anomaly) is that of looking for a specific sequence of options considering all possible paths
through a routine.

o Let the operations be SET and RESET, denoted by s and r respectively, and we want to know if
there is a SET followed immediately a SET or a RESET followed immediately by a RESET
(an ss or an rr sequence).

o Some more application examples:

1. A file can be opened (o), closed (c), read (r), or written (w). If the file is read or written to
after it's been closed, the sequence is nonsensical. Therefore, cr and cw are anomalous.
Similarly, if the file is read before it's been written, just after opening, we may have a bug.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Therefore, or is also anomalous. Furthermore, oo and cc, though not actual bugs, are a
waste of time 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 flowgraph lead to anomalous sequences on any
path? If so, what sequences and under what circumstances?

3. The data-flow anomalies discussed in Unit 4 requires us to detect the dd, dk, kk,
and ku sequences. Are there paths with anomalous data flows?

 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) ABnC, then T will appear in AB2C. (HUANG's Theorem)

o As an example, let

A = pp
B = srr
C = rp
T = ss

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

o However, let

A = p + pp + ps
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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

(p + pp + ps)[psr + ps(r + ps)]2rp

Multiplying out the expression and simplifying shows that there is no p4 sequence.

o Incidentally, the above observation is an informal proof of the wisdom of looping twice discussed
in Unit 2. Because data-flow anomalies are represented by two-character sequences, it follows the
above theorem that looping twice is what you need to do to find such anomalies.

 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 utilitarian limit for manual application.

o There are some nice theorems for finding sequences that occur at the beginnings and ends of
strings but no nice algorithms for finding strings buried in an expression.

o Static flow analysis methods can't determine whether a path is or is not achievable. Unless the
flow analysis includes symbolic execution or similar techniques, the impact of unachievable paths
will not be included in the analysis.

o The flow-anomaly application, for example, doesn't tell us that there will be a flow anomaly - it
tells us that if the path is achievable, then there will be a flow anomaly. Such analytical problems
go away, of course, if you take the trouble to design routines for which all paths are achievable.

SUMMARY:

 A flowgraph annotated with link names for every link can be converted into a path expression that
represents the set of all paths in that flowgraph. A node-by-node reduction procedure is used.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 By substituting link weights for all links, and using the appropriate arithmetic rules, the path expression is
converted into an algebraic expression that can be used to determine the minimum and maximum number
of possible paths in a flowgraph, the probability that a given node will be reached, the mean processing
time of a routine, and other models.

 With different, suitable arithmetic rules, and by using complementary operators as weights for the links,
the path expression can be converted into an expression that denotes, over the set of all possible paths,
what the net effect of the routine is.

 With links annotated with the appropriate weights, the path expression is converted into a regular
expression that denotes the set of all operator sequences over the set of all paths in a routine. Rules for
determining whether a given sequence of operations are possible are given. In other words, we have a
generalized flow-anomaly detection method that'll work for data-flow anomalies or any other flow
anomaly.

 All flow analysis methods lose accuracy and utility if there are unachievable paths. Expand the accuracy
and utility of your analytical tools by designs for which all paths are achievable. Such designs are always
possible.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Unit V
Logic Based Testing–Decision Tables–Transition Testing–States, State Graph, State Testing.

OVERVIEW OF LOGIC BASED TESTING:

 INTRODUCTION:

o The functional requirements of many programs can be specified 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 often used words in programmers' vocabularies but one of their least
used techniques.

o Boolean algebra is to logic as arithmetic is to mathematics. Without it, the tester or programmer is
cut off 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 software logic testing.
Because hardware testing automation is 10 to 15 years ahead of software testing automation,
hardware testing methods and its associated theory is a fertile ground for software testing
methods.

o As programming and test techniques have improved, the bugs have shifted closer to the process
front end, to requirements and their specifications. These bugs range from 8% to 30% of the total
and because they're first-in and last-out, they're the costliest of all.

o The trouble with specifications is that they're hard to express.

o Boolean algebra (also known as the sentential calculus) is the most basic of all logic systems.

o Higher-order logic systems are needed and used for formal specifications.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Much of logical analysis can be and is embedded in tools. But these tools incorporate methods to
simplify, transform, and check specifications, and the methods are to a large extent based on
boolean algebra.

KNOWLEDGE BASED SYSTEM:


 The knowledge-based system (also expert system, or "artificial intelligence" system) has
become the programming construct of choice for many applications that were once
considered very difficult.

 Knowledge-based systems incorporate knowledge from a knowledge domain such as


medicine, law, or civil engineering into a database. The data can then be queried and
interacted with to provide solutions to problems in that domain.

 One implementation of knowledge-based systems is to incorporate the expert's knowledge


into a set of rules. The user can then provide data and ask questions based on that data.

 The user's data is processed through the rule base to yield conclusions (tentative or
definite) and requests for more data. The processing is done by a program called
the inference engine.

 Understanding knowledge-based systems and their validation problems requires an


understanding of formal logic.

o Decision tables are extensively used in business data processing; Decision-table preprocessors as
extensions to COBOL are in common use; boolean algebra is embedded in the implementation of
these processors.

o Although programmed tools are nice to have, most of the benefits of boolean algebra can be
reaped by wholly manual means if you have the right conceptual tool: the Karnaugh-Veitch
diagram is that conceptual tool.

DECISION TABLES:

 Figure 6.1 is a limited - entry decision table. It consists of four areas called the condition stub, the
condition entry, the action stub, and the action entry.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Each column of the table is a rule that specifies the conditions under which the actions named in the
action stub will take place.

 The condition stub is a list of names of conditions.

Figure 6.1 : Examples of Decision Table.


 A more general decision table can be as below:

Figure 6.2 : Another Examples of Decision Table.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 A rule specifies whether a condition should or should not be met for the rule to be satisfied. "YES" means
that the condition must be met, "NO" means that the condition must not be met, and "I" means that the
condition plays no part in the rule, or it is immaterial to that rule.

 The action stub names the actions the routine will take or initiate if the rule is satisfied. If the action entry
is "YES", the action will take place; if "NO", the action will not take place.

 The table in Figure 6.1 can be translated as follows:

Action 1 will take place if conditions 1 and 2 are met and if conditions 3 and 4 are not met (rule 1) or if
conditions 1, 3, and 4 are met (rule 2).

 "Condition" is another word for predicate.

 Decision-table uses "condition" and "satisfied" or "met". Let us use "predicate" and TRUE / FALSE.

 Now the above translations become:

1. Action 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. Action 2 will be taken if the predicates are all false, (rule 3).

3. Action 3 will take place if predicate 1 is false and predicate 4 is true (rule 4).

 In addition to the stated rules, we also need a Default Rule that specifies the default action to be taken
when all other rules fail. The default rules for Table in Figure 6.1 is shown in Figure 6.3

Figure 6.3 : The default rules of Table in Figure 6.1


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 DECISION-TABLE PROCESSORS:

1. Decision tables can be automatically translated into code and, as such, are a higher-order language

2. If the rule is satisfied, the corresponding action takes place

3. Otherwise, rule 2 is tried. This process continues until either a satisfied rule results in an action or
no rule is satisfied and the default action is taken

4. Decision tables have become a useful tool in the programmers kit, in business data processing.

 DECISION-TABLES AS BASIS FOR TEST CASE DESIGN:

1. The specification is given as a decision table or can be easily converted into one.

2. The order in which the predicates are evaluated does not affect interpretation of the rules or the
resulting action - i.e., an arbitrary permutation of the predicate order will not, or should not, affect
which action takes place.

3. The order in which the rules are evaluated does not affect the resulting action - i.e., an arbitrary
permutation of rules will not, or should not, affect which action takes place.

4. Once a rule is satisfied and an action selected, no other rule need be examined.

5. If several actions can result from satisfying a rule, the order in which the actions are executed
doesn't matter

 DECISION-TABLES AND STRUCTURE:

1. Decision tables can also be used to examine a program's structure.

2. Figure 6.4 shows a program segment that consists of a decision tree.

3. These decisions, in various combinations, can lead to actions 1, 2, or 3.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 6.4 : A Sample Program


4. If the decision appears on a path, put in a YES or NO as appropriate. If the decision does not
appear on the path, put in an I, Rule 1 does not contain decision C, therefore its entries are: YES,
YES, I, YES.

5. The corresponding decision table is shown in Table 6.1

6. RULE 1 RULE 2 RULE 3 RULE 4 RULE 5 RULE 6

CONDITION A YES YES YES NO NO NO


CONDITION B YES NO YES I I I
CONDITION C I I I YES NO NO
CONDITION D YES I NO I YES NO

ACTION 1 YES YES NO NO NO NO


ACTION 2 NO NO YES YES YES NO
ACTION 3 NO NO NO NO NO YES
7. Table 6.1 : Decision Table corresponding to Figure 6.4

8. As an example, expanding the immaterial cases results as below:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

9. Similalrly, If we expand the immaterial cases for the above Table 6.1, it results in Table 6.2 as
below:

10. R1 RULE 2 R3 RULE 4 R5 R6

CONDITION A YY YYYY YY NNNN NN NN


CONDITION B YY NNNN YY YYNN NY YN
CONDITION C YN NNYY YN YYYY NN NN
CONDITION D YY YNNY NN NYYN YY NN
11. Table 6.2 : Expansion of Table 6.1

12. Sixteen cases are represented in Table 6.1, and no case appears twice.

13. Consequently, the flowgraph appears to be complete and consistent.

14. As a first check, before you look for all sixteen combinations, count the number of Y's and N's in
each row. They should be equal. We can find the bug that way.

 ANOTHER EXAMPLE - A TROUBLE SOME PROGRAM:

1. Consider the following specification whose putative flowgraph is shown in Figure 6.5:

1. If condition A is met, do process A1 no matter what other actions are taken or what other
conditions are met.

2. If condition B is met, do process A2 no matter what other actions are taken or what other
conditions are met.

3. If condition C is met, do process A3 no matter what other actions are taken or what other
conditions are met.

4. If none of the conditions is met, then do processes A1, A2, and A3.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

5. When more than one process is done, process A1 must be done first, then A2, and then
A3. The only permissible cases are: (A1), (A2), (A3), (A1,A3), (A2,A3) and (A1,A2,A3).

2. Figure 6.5 shows a sample program with a bug.

Figure 6.5 : A Troublesome Program


3. The programmer tried to force all three processes to be executed for the cases but forgot that
the B and C predicates would be done again, thereby bypassing processes A2 and A3.

4. Table 6.3 shows the conversion of this flowgraph into a decision table after expansion.

Table 6.3 : Decision Table for Figure 6.5

PATH EXPRESSIONS:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 GENERAL:

o Logic-based testing is structural testing when it's applied to structure (e.g., control flowgraph of
an implementation); it's functional testing when it's applied to a specification.

o In logic-based testing we focus on the truth values of control flow predicates.

o A predicate is implemented as a process whose outcome is a truth-functional value.

o For our purpose, logic-based testing is restricted to binary predicates.

o We start by generating path expressions by path tracing as in Unit V, but this time, our purpose is
to convert the path expressions into boolean algebra, using the predicates' truth values (e.g., A
and ) as weights.

 BOOLEAN ALGEBRA:

o STEPS:

1. Label each decision with an uppercase letter that represents the truth value of the
predicate. The YES or TRUE branch is labeled with a letter (say A) and the NO or FALSE
branch with the same letter overscored (say ).

2. The truth value of a path is the product of the individual labels. Concatenation 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".
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 6.5 : A Troublesome Program


o Using this convention, the truth-functional values for several of the nodes can be expressed in
terms of segments from previous nodes. Use the node name to identify the point.

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:

1. Boolean algebra has three operators: X (AND), + (OR) and (NOT)

2. X : meaning AND. Also called multiplication. A statement such as AB (A X B) means "A


and B are both true". This symbol is usually left out as in ordinary algebra.

3. + : meaning OR. "A + B" means "either A is true or B is true or both".

4. meaning NOT. Also negation or complementation. This is read as either "not A" or "A
bar". The entire expression under the bar is negated.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

5. The following are the laws of boolean algebra:

o In all of the above, a letter can represent a single sentence or an entire boolean algebra expression.

o Individual letters in a boolean algebra expression are called Literals (e.g. A,B)

o The product of several literals is called a product term (e.g., ABC, DE).

o An arbitrary boolean expression that has been multiplied out so that it consists of the sum of
products (e.g., ABC + DEF + GH) is said to be in sum-of-products form.

o The result of simplifications (using the rules above) is again in the sum of product form and each
product term in such a simplified version is called a prime implicant. For example, ABC + AB +
DEF reduces by rule 20 to AB + DEF; that is, AB and DEF are prime implicants.

o The path expressions of Figure 6.5 can now be simplified by applying the rules.

o The following are the laws of boolean algebra:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o Similarly,

o The deviation from the specification is now clear. The functions should have been:

 Loops complicate things because we may have to solve a boolean equation to determine what predicate-
value combinations lead to where.

KV CHARTS:

 INTRODUCTION:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o If you had to deal with expressions in four, five, 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 routine you're
testing.

o Karnaugh-Veitch chart reduces boolean algebraic manipulations to graphical trivia.

o Beyond six variables these diagrams get cumbersome and may not be effective.

 SINGLE VARIABLE:

o Figure 6.6 shows all the boolean functions of a single variable and their equivalent representation
as a KV chart.

Figure 6.6 : KV Charts for Functions of a Single Variable.


o The charts show all possible truth values that the variable A can have.

o A "1" means the variable’s value is "1" or TRUE. A "0" means that the variable's value is 0 or
FALSE.

o The entry in the box (0 or 1) specifies whether the function that the chart represents is true or false
for that value of the variable.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o We usually do not explicitly put in 0 entries but specify only the conditions under which the
function is true.

 TWO VARIABLES:

o Figure 6.7 shows eight of the sixteen possible functions of two variables.

Figure 6.7 : KV Charts for Functions of Two Variables.


o Each box corresponds to the combination of values of the variables for the row and column of that
box.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o A pair may be adjacent either horizontally or vertically but not diagonally.

o Any variable that changes in either the horizontal or vertical direction does not appear in the
expression.

o In the fifth chart, the B variable changes from 0 to 1 going down the column, and because the A
variable's value for the column is 1, the chart is equivalent to a simple A.

o Figure 6.8 shows the remaining eight functions of two variables.

Figure 6.8 : More Functions of Two Variables.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

o The first chart has two 1's in it, but because they are not adjacent, each must be taken separately.

o They are written using a plus sign.

o It is clear now why there are sixteen functions of two variables.

o Each box in the KV chart corresponds to a combination of the variables' values.

o That combination might or might not be in the function (i.e., the box corresponding to that
combination might have a 1 or 0 entry).

o Since n variables lead to 2n combinations of 0 and 1 for the variables, and each such combination
(box) can be filled or not filled, leading to 22n ways of doing this.

o Consequently for one variable there are 221 = 4 functions, 16 functions of 2 variables, 256
functions of 3 variables, 16,384 functions of 4 variables, and so on.

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 negation of a chart is gotten by reversing
all the 0 and 1 entries in the chart.

OR

 THREE VARIABLES:

o KV charts for three variables are shown below.


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

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:


Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Figure 6.8 : KV Charts for Functions of Three Variables.


o You'll notice that there are several ways to circle the boxes into maximum-sized covering groups.

 FOUR VARIABLES AND MORE:

o The same principles hold for four and more variables.

STATES, STATE GRAPHS, AND TRANSITION TESTING


(1) State Graphs:
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(i) States
 State is a condition or situation during which an object undergoes throughout its life time.
 States are represented by nodes.
 States are numbered or identified by characters or words or whatever else is convenient.
 A state graph consists of a set of states in order to represent the behavior of the system.
 To understand the concept of states let us consider the following examples.
Example 1: A program that detects the character sequence ZCZC can be in the following states.
1. Neither ZCZC nor any part of it has been detected.
2. Z has been detected.
3. ZC has been detected.
4. ZCZ has been detected.
5. ZCZC has been detected.
Example 2: A moving automobile whose engine is running can have the following states with respect to
transmission.
1. Reverse gear.
2. Neutral gear.
3. First gear.
4. Second gear.
5. Third gear.
6. Four gear.
Example 3: A person’s checkbook can have the following states with respect to bank balance.
1. Equal.
2. Less than.
3. Greater than.
Example 4: A word processing program menu can be in the following states with respect to file
transmission.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

1. Create document.
2. Copy document.
3. Delete document.
4. Rename document.
5. Compress document.
6. Saving document
7. Copy disc.
8. Format disc
9. Backup disc
10. Recover from backup

(ii) Inputs and Transitions:

 Some thing is modeled and given is called input. Input may be values or variables.
 A state graph takes input provided to states.
 As a result of these inputs the state changes is known as transition.
 That is changing from one state to other state is called transition.
 Transitions are denoted by links that join the states.
 The input that causes the transition is represented on the link. So the inputs are link weights.
 A finite state machine is represented by a state graph having a finite number of states and a finite
number of transitions between states.
The ZCZC detection example can have the following types of inputs.
Z
C
Any character other than Z or C which will be denoted by A.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

The above state graph is interpreted as follows.


1. If a system is in the NONE state, and it receives A or C then it is in NONE state only.
2. In NONE state if Z is received, the system enters into Z state. In Z state if it receives Z it will remain
in the same state. If C is received it will go to the ZC state or if any other character say A is received
then it will go back to the NONE state.
3. In ZC state if it receives Z it will enter into ZCZ state. If C or A is received it enter into NONE state.
4. In ZCZ state if it receives Z it enter into the Z state. If A is received it enters into the NONE state.
5. In ZCZ state if it receives C it enter into the ZCZC state. In ZCZC state if it receives Z or C or A then
it will remain in the same state only.
(iii) Outputs:

 Outputs are based on the input values.


 When an input is applied to a state it is processed in order to produce an output.
 Each input and output of the state graph is separated by a slash ‘/’ symbol.
 Outputs are also link weights. If more than one input having the same output than it can be represented
by input1, input 2, input 3…/output.
Example: Let us consider a tape control recovery system. This system contains two inputs OK & Error. OK means
“No write errors”. Error means “There may be write errors”. The outputs are Rewrite, Erase, None, Out of
service. Here None means no special action is taken.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 At state 1 if no write errors are detected (input = OK) no special action is taken (output=NONE). If
error is detected (input=ERROR) backspace the tape one block and rewrite the block (output
=REWRITE) i.e. enter into state 2.
 At state 2 if the rewrite is successful (input= OK) no action is taken (output=NONE) and return to
state 1.
 If the rewrite is not successful try another back space and rewrite (output=REWRITE) i.e. enter into
state 4.
 If there are two successive rewrites and a third error occurs then backspace ten centimeters and erase
(output=ERASE) i.e. from state 4 to state 5.
 If there are two successive rewrites and a third no error occurs then it enter into state 3 & then state 1.
At state 3 if any error is detected then it enter into state 2 and rewrite.
 At state 5 if the erasure works (input=OK) no action is taken and return to initial state.
 If it does not work, backspace another ten centimeters and erase. i.e. enter into state 6.
 At state 6 if the erasure works (input=OK) no action is taken and return to initial state
 If the second erasure does not work put the tape control out of service i.e enter into state 7

(iv) State Table:

 If state graph has a large number of states and transitions, then it is difficult to follow them.
 Therefore a state table is used, as an easiest way to represent all the states, inputs, transitions and
outputs of the state graph.
 A state table is defined as a tabular representation of a state graph.
 It consists of
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

1. Each row represents a state.


2. Each column represents an input condition.
3. The box at the intersection of row and column represents the next state and the output.
 The state table for the tape control system is shown below.

STATE OK ERROR
1 1/NONE 2/REWRITE
2 1/NONE 4/REWRITE
3 1/NONE 2/REWRITE
4 3/NONE 5/ERASE
5 1/NONE 6/ERASE
6 1/NONE 7/OUT
7

. (v) Time Versus Sequence:

 State graphs don’t represent time-they represent sequence.


 A transition might take microseconds or centuries.
 A system may be in one state for milliseconds or years.
 The finite state machine model can be elaborated to include notions of time in addition to sequence,
such as Petri nets.
(vi) Software Implementation( public question)
1. Implementation and Operation:
 Here four tables are involved.
1. First table encode the input value. i.e. INPUT_TABLE_CODE.
2. A table that specifies the next state i.e. TRANSITION_TABLE
3. A table that specifies the output. i.e. OUTPUT_TABLE
4. A table that stores the present state of every device. i.e. DEVICE_TABLE. This routine operates as
follows.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

BEGIN PRESENT_STATE:=DEVICE_TABLE ACCEPT INPUT_VALUE


INPUT_CODE:=INPUT_CODE_TABLE
POINTER:=INPUT_CODE#PRESENT_STATE NEW_STATE:=TRANSITION_TABLE
OUTPUT_CODE:=OUTPUT_TABLE
CALL OUTPUT_HANDLER DEVICE_TABLE:=NEW_STATE END
Steps:
1. The present state is fetched from memory.
2. The present input value is fetched. If it is numerical it can be used directly. If it is not numerical
encode into a numerical value.
3. The present state and input code are combined.
4. The output table contains a pointer to the routine to be executed.
5. The same pointer is used to fetch the new state value, which is then stored.
2. Input encoding and Input Alphabet:
 Only the simplest finite state machines can use the inputs directly.
 In ZCZC detector there are 256 possible ASCII characters. But we are taken Z, C and OTHER.
 The input encoding here is for OTHER=0, for Z=1, for C=2.
 The different encoded input values are called the input alphabet.

3. Output encoding and Output Alphabet:


 A single character output for a link is rare.
 So we want to output a string of characters.
 These can be encode into a convenient output alphabet.

4. State codes and State-Symbol products:


 The term state-symbol product is used to convert the combined state and input code into a pointer to
compact table.
5. Application Comments for Designers:
 An explicit state table implementation is advantageous when either the control function is likely to
change in the future or when the system has many similar, but slightly different control functions.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

6. Application Comments for Testers


 Independent testers are not usually taken with either implementation details or the economics of this
approach.
 If the programmers have implemented an explicit finite state machine then much of our work has been
done for us.
 Sometimes showing the programmers the kinds of tests developed from a state graph description can
lead them to consider it as an implementation technique.

(2) Good State Graphs and Bad State Graphs:

(i) General:

 In testing we deal with a good state graph and also with a bad one.
 The following figure shows examples of improper or bad state graphs.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(2)State Bugs
 The bugs in states are called state bugs. The state bugs arise due to the following reasons.

1. Number of States:
 A State graph consists of the number of states. It represents behavior of the system.
 In practice the state is directly or indirectly recorded.
 State table is used to record the number of states of the state graph.
 In state table the state bugs are occurred because of missing states.
 That is in state table if the number of states are not recorded or missed then the result might be the
bugs.
 To find the missing states, first find the number of states
 The number of states is founded by as follows.
1. Identify all the component factors of the state.
2. Identify all the allowable values for each factor.
3. Now the number of states is the product of the factors and allowable values.
 Functional specifications are used to find the factors of the state. They may also helpful to find the
number of possible values for each factor.
2. Impossible States:
 A state that is not possible is called impossible states.
 For example a broken engine cannot run, so running a broken engine state is impossible state.
 There are some combination of factors that are impossible, they are GEAR: R, N, 1, 2, 3, 4 = 6
factors
DIRECTION: forward, reverse, stopped = 3 factors ENGINE: running, stopped = 2 factors
TRANMISSION: ok, broken = 2 factors
ENGINE: ok, broken = 2 factors

TOTAL = 6 x 3 x 2 x 2 x2 =144 states.


 A broken engine cannot run so the combination of engine is 3 states. Therefore the total number of
states is 108. A car with a broken transmission does not move for long, there by further decreasing
the number of states.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

3. Equivalent States:
 Two states A, B are equivalent if every sequence of inputs starting from one state (s) produces
exactly the same sequence of outputs.
 Let us take an example of two equivalent states.
 In the below figure, let us assume the system is in state S.
 An input of ‘a’ begins a transition to state A and an input of ‘b’ begins a transition to
state B from S.
 If all the sequence of inputs from the state A generates exactly the same sequence of outputs as the
other state B, then we say that these two states are equivalent.

A
a

S C

b
B

 Because these two states are treated equally, the state graph can be minimized by combining these
two equivalent states as shown in the following figure.

a,b
S A,B C

 Equivalent states can be recognized by the following procedure.


1. The two states are differentiated only by the different input values. For example Consider the
following figure.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

d/y

e/y
A C
a
e/y
1
e/x
b
e/x
B C

d/y

Here except a, b inputs, the system behavior in two states A, B are identical for every input sequence.

2. There are two set of rows which except for the state name, have identical state graphs with respect
to transitions and outputs. The two sets can be merged. Let consider the following equivalent
states.

a/y
a/u

b/x b/u
A1 A2 A3
a/u

1 a/w b/y
a/w
b/y
b/u
b/x
B1 B2 B3
b/u

a/y
a/u
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

The Decision table to the above figure is shown below:

STATE OK ERROR
1 A1/u B1/u
A1 A1/y A2/x
B1 B1/y B2/x
A2 B2/w A3/u
B2 A2/w B3/u
A3 A3/u B2/y
B3 B3/u A2/y
The merged equivalent states are represented by as follows
a/y a/w a/u

b/x b/u
a/u,b/u
1 A1 B1 A2 B2 A3 B3

b/y

The Unmergeable states are represented by as follows

a/y a/w
a/u

b/x b/u
A1 A2 A3
a/u

1
b/y
b/u
b/x
B1 B2 B3
b/u

a/y
a/w a/u
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

Transition Bugs

 The connectivity between two or more states is known as transition.


 The bug in transition is called Transition Bug.

1. Unspecified and Contradictory Transitions:


 A transition is specified between states. If a transition may occur between states and not
specified (i.e. unspecified transition) then the transition bug occurs.
 If a transition is not possible in the state then there must be a method that prevents the
occurrence of input in that state.
 If there is no such method available then the occurrence of input becomes inefficient.
 So to avoid transition bug one transition must be specified for every input state combination.
 A program does not contain contradictions, if one input must be processed at a time to
produce desired output. If a transition does not possible between states and the transition is
specified then a contradictory transition may occur.
 That is if a programmer does not take all the measures of a program then contradictory
transitions may occur because of transitions may not be possible between some of the states.
For example if a single bit of a state is misplaced by the programmer then it doubles the
number of states in the state graph and performs the contradictory transitions. This
contradiction gives a transition bug.

2. Example
 The following example shows how to convert a specification into a state graph and how
contradictions can come out.
OK

ERROR ERROR ERROR ERROR ERROR


0 1 2 3 4 5

Rule 1:

 The program will maintain an error counter which will be incremented whenever there is an error.
Here there are only two input values OK, ERROR.
 These values make it easier to detect ambiguities and contradictions in a state table.

123
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

INPUT
STATE OK ERROR
0 0/NONE 1/
1 2/
2 3/
3 4/
4 5/
5 6/
6 7/
7 8/
Rule 2:If there is an error rewrite the block.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/REWRITE
3 4/REWRITE
4 5/REWRITE
5 6/REWRITE
6 7/REWRITE
7 8/REWRITE
Rule 3: If there are three errors, erase 10 centimeters of tape and rewrite the block.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/REWRITE,ERASE,REWRITE
3 4/REWRITE,ERASE,REWRITE
4 5/REWRITE,ERASE,REWRITE
5 6/REWRITE,ERASE,REWRITE
6 7/REWRITE,ERASE,REWRITE
7 8/REWRITE,ERASE,REWRITE
Rule 4: If there are three erasures and another error occur, then put out of service.
INPUT124
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/ERASE,REWRITE
3 4/ERASE,REWRITE
4 5/ERASE,REWRITE
5 6/OUT
6
7
Rule 5:

 If the erasure was successful return to the normal state and clear the error counter.
INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 2/REWRITE
2 3/ERASE,REWRITE
3 0/NONE 4/ERASE,REWRITE
4 0/NONE 5/ERASE,REWRITE
5 0/NONE 6/OUT
6

Rule 6:

 If the rewrite was unsuccessful increment the error counter, and try another rewrite.
Rule 7:

 If the rewrite was successful decrement the error counter and return to the previous state. INPUT
STATE OK ERROR
0 0/NONE 1/REWRITE
1 0/NONE 2/REWRITE
2 1/NONE 3/ERASE,REWRITE
3 0/NONE 4/ERASE,REWRITE
2/NONE
4 0/NONE 5/ERASE,REWRITE
3/NONE
125
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

5 0/NONE 6/OUT
4/NONE
6

Rule 7 A:

 If there have been no erasures and the rewrite is successful return to the previous state.

3. Unreachable States:
 An un reachable state is like unreachable code If a transition is not specified between two
states then that states are unreachable. That is if any incorrect transition occurs then the state
becomes unreachable.
 There may be a transition from unreachable states to other states.

4. Dead States:
 A dead state is a state that once entered cannot be left.
 In programming, a set of states may be dead because a program has two stages.
 In the first stage an initialization process takes place that consists of number of states to be
initialized.
 In the second stage strongly connected set of functional states takes place in which operations
of the states cannot be completed. So the functional states become dead states. The only
solution to this problem is system restart.

(3) Output Errors:


 The errors in output are called output errors.
 The states, the transitions, and the inputs may be correct & there may be no dead or unreachable states,
but the output for the transition may be incorrect.
 Output actions must be verified independently for states and transitions.
(4) Encoding Bugs:
 Encoding is a process of converting or coding the inputs, transitions, and outputs of the state.
 Encoding process is applied in both explicit and implicit finite state machines.
 The encoding bugs are more common at the time of input coding, output coding and state coding in an
explicit state machine.
 The encoding bugs may also exist in an implicit finite state machine, because of different views made
by programmer and tester. 126
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 The behavior of a finite state machine is invariant under all encodings.


 That is say that the states are numbered 1 to n.
 If you renumber the states by an arbitrary permutation, the finite state machine is unchanged. Similarly
for input and output code is unchanged.
 Therefore if you present your version of the finite state machine with a different encoding and if the
programmer objects to renaming then there is encoding bugs.
 You may have to look at the implementation for these, especially the data dictionary.
 The implementation of the fields as bunch of bits tells you the potential size of the code.
 If the number of code value is less than this potential, there is an encoding process.
 In strongly typed languages with user defined semantic types the encoding process is probably a type
conversion a set membership to integer.
 Again you may have to look at the program to spot potential bugs of this kind.

(3) State Testing:

(i) Impact of Bugs:

 Let us say that a routine is specified as a state graph that has been verified as correct in all details.
 From the following the bugs may occur.
1. Wrong number of states
2. Wrong transition
3. Wrong output for a given transition
4. Pair of states are wrongly made equivalent
5. Set of states are split to create in equivalent duplicates.
6. Set of states become dead.

7. Set of states become unreachable.


(ii) Principles:( public question)

 State testing is defined as a functional testing technique to test the functional bugs in the entire
system.
 The principles for state testing are very similar to the principles of path testing.
 For path testing it is not possible to test every possible path in a flowgraph.
 Similarly for state testing it is not possible to test every possible path in a state graph.
 In a state graph a path is a sequence of transitions
127 caused by a sequence of inputs.
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 In state testing the primary interest is given to the states and transitions rather than outputs.
 In state testing define a set of covering input sequences and for each step in each input sequence
define the expected next state, the expected transition and the expected output code.
 A set of tests consists of three sets of sequences
1. Input sequences.
2. Corresponding transitions
3. Output sequences.

(iii) Limitations and extensions:

The limitation is: State transition coverage in a state graph does not guarantee complete testing. The
extension:
 Chow defines a hierarchy of paths and methods for combining paths.
 The simplest is called a 0 switch which corresponds to test each transition independently.
 The next level consists of testing transition sequences consisting of two transitions called 1 switch.
The maximum length switch is an n-1 switch where n is the number of states.
The different advantages are
 State testing is useful when the error corrections are less expensive.
 State testing is also useful when the testers want to detect a specified input.
 A state testing is specifically designed for catching the deep bugs.
 A state testing provides easiness during the design of tests. The different disadvantages are
 State testing does not provide through testing because when a test is completed there might be some
bugs remains in the system. Testers require large number of input sequences to catch transition
errors, missing states etc..

(iv) What to model:

 Combination of hardware & software can be modeled sufficiently complicated state graph.
 The state graph is behavioral model that is it is functional rather than structural.

(v) Getting the data:

 Here labor intensive data gathering is needed and needs more meetings to resolves issues.

128
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

(vi) Tools:

 Tools for hardware logic designs are needed.

(4) Testability tips:

(i) A balm for programmers:

 The key to testability design is easy that is we can easily build explicit finite state machines.

(ii) How big How small:

 For two finite state machines there are only eight good and bad ones.
 For three finite state machines there are eighty possible good and bad one.
 Similarly for Four state machines 2700 most of which are bad and for five state machines 275000
most of which are bad. For six state machines 100 millions most of which are bad.
(iii) Switches, Flags and unachievable paths :

 The functionality of switches and flags are almost similar in the state testing.
 Switches or flags are used as essential tool for state testing to test the finite state machine in every
possible state.
 A flag or switch value is set at the initial process of finite state machine, and then this value is
evaluated and tested.
 Depending on its value the specific path is selected to find an easiest way for testing the finite state
machine.
 Mostly the switch or flag works on true or false condition.
 In figure a flag is set to p in the program. This p variable is assigned to some value which can be
evaluated.
 Depending on its value a path is separated into branches in order to proceed testing in either way
that is u or x
 This also can be done by removing a flag and separating v path into two different paths w,y as
shown in the above figure.
 Unachievable paths those paths which don’t interact with each other.
 Here there are four paths u,w,x,y in that two are not achievable and two are achievable.
 That is u is not achievable to path y and path x is not achievable to path w & u is achievable to path
w and path x is achievable to path y. 129
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

 Finally both the paths uw and xy are needed to cover the branches.
 In the above figure there are three flag variables p,q,r in the program.
 These variables are assigned some values that can be evaluated and based on which the paths are
separated into branches.
 The main benefit of using this implementation is to remove the unnecessary combination from the
decision tree as shown in the figure c.

(iv) Essential and inessential finite state behavior:

 To understand an essential and inessential finite state behavior, we need to know the concept of
finite state machines and combinational machines.
 There is a difference between finite state machines and combinational machines in terms of quality.
 In combinational machines a path is chosen depending on the truth values of predicates.
 The predicate truth values are the values which once determined will never change and always
remains constant.
 In these machines a path is equivalent to a Boolean algebraic expression over the predicates
 Further more it does not matter in which order the decisions are made.

(v) Design guide lines:

 Fine state machine is represented by a state graph having a finite number of states and a finite
number of transitions between states
 Finite state machine (FSM) is a functional testing tool and programming testing tool.
 That is it is an essential tool for state testing in order to identify or model the behavior of software.
 The different guide lines are given below.
1. Initially learn the procedure of finite state machine that are used in both hardware and software.
2. Design an abstract machine in such a way that it works properly and satisfies the user
requirements.
3. Design an explicit finite state machine.
4. Prototype test must be conducted thoroughly to determine the processing time and space of
explicit finite state machine design.
5. If time or space is more effecting the overall system, then use shortcuts to complete the design

process.
6. If there are more than a few numbers of states then use hierarchical design to represent them.
130
Mangayarkarasi College of Arts and Science for Women
Affiliated to Madurai Kamaraj University | Accredited with ‘A’ Grade by NAAC (3rd Cycle) Approved by UGC Under
Section 2(f) Status| ISO 9001:2015 Certified Institution
Paravai, Madurai-625402

7. If there is large number of states then software tools and programming languages must be
developed.
8. The capability to initialize to an arbitrary state must be inbuilt together with the transition
verification instrumentation.

http://www.mcr.org.in/sureshmudunuri/stm/unit4.php#domains_paths

131

You might also like