Escolar Documentos
Profissional Documentos
Cultura Documentos
Path Testing
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
CONTENTS
1 Introduction.................................................................................................1
2 Sample Function.........................................................................................1
3 Path Testing................................................................................................3
3.1 Identification of Process Block............................................................3
3.2 Identification of Decision statements..................................................5
3.3 Identification of Junctions and exit statements...................................7
3.4 Control Flow graph..............................................................................9
3.5 List of Decision nodes.......................................................................10
3.6 List of variables that affect the decision............................................10
3.7 Identification of Predicates................................................................10
3.8 Predicate names for truth and false..................................................10
3.9 Control flow graph with named predicates........................................11
3.10 Predicate Descriptions......................................................................12
3.10.1 Predicate: A................................................................................12
3.10.2 Predicate: B................................................................................12
3.10.3 Predicate: C...............................................................................12
3.11 Predicate Interpretation:....................................................................12
3.11.1 Predicate: A................................................................................12
3.11.2 Predicate: B................................................................................12
3.11.3 Predicate: C...............................................................................12
4 Cyclomatic Complexity.............................................................................13
4.1 Independent path list.........................................................................13
5 Proof for Coverage...................................................................................14
i
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
1 Introduction
2 Sample Function
void UpdateSegmentInformationForFunctionsInsymbolTable
(
struct symbol_information *psSymbolpointer
)
{
int siNonZeroWhenFunctionIsAnInterruptFunction;
sSegmentInformation * psSegmentInformation;
Assert(psSymbolpointer != NULL);
if (is_symbol_a_function (psSymbolpointer))
{
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, INTERRUPT_INDEX );
if (siNonZeroWhenFunctionIsAnInterruptFunction == 0)
{
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, SWI_INDEX );
};
else
{
if ( siNonZeroWhenFunctionIsAnInterruptFunction )
psSegmentInformation = ( sSegmentInformation *)
1
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_INTERRUPT_FUNCTION
);
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *)psSegmentInformation;
}
else
{
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_NORMAL_FUNCTION
);
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *) psSegmentInformation;
else
{
3 Path Testing
2
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
The process blocks are highlighted and a unique name is assigned to each
process block.
void UpdateSegmentInformationForFunctionsInsymbolTable
(
struct symbol_information *psSymbolpointer
)
{
int siNonZeroWhenFunctionIsAnInterruptFunction;
sSegmentInformation * psSegmentInformation;
P1
Assert(psSymbolpointer != NULL);
if (is_symbol_a_function (psSymbolpointer))
{
siNonZeroWhenFunctionIsAnInterruptFuncion =
is_in_pragma ( psSymbolpointer, INTERRUPT_INDEX ); P2
if( siNonZeroWhenFunctionIsAnInterruptFunction == 0)
{
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, SWI_INDEX ); P3
};
else
{
if( siNonZeroWhenFunctionIsAnInterruptFunction )
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_INTERRUPT_FUNCTION
} ); P4
psSymbolpointer->spSegmentInformation =
else
( sSegmentInformation *)psSegmentInformation;
3
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_NORMAL_FUNCTION
); P5
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *) psSegmentInformation;
else
{
The decisions of the function are highlighted and a unique name is assigned
to each decision.
4
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
void UpdateSegmentInformationForFunctionsInsymbolTable
(
struct symbol_information *psSymbolpointer
)
{
int siNonZeroWhenFunctionIsAnInterruptFunction;
sSegmentInformation * psSegmentInformation;
Assert(psSymbolpointer != NULL);
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, INTERRUPT_INDEX );
if( siNonZeroWhenFunctionIsAnInterruptFunction == 0) D2
{
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, SWI_INDEX );
};
else
{
if( siNonZeroWhenFunctionIsAnInterruptFunction ) D3
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_INTERRUPT_FUNCTION
);
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *)psSegmentInformation;
}
else
{
5
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_NORMAL_FUNCTION
);
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *) psSegmentInformation;
else
{
The junctions and the exit of the function are highlighted. A unique name is
assigned to each junction.
6
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
void UpdateSegmentInformationForFunctionsInsymbolTable
(
struct symbol_information *psSymbolpointer
)
{
int siNonZeroWhenFunctionIsAnInterruptFunction;
sSegmentInformation * psSegmentInformation;
Assert(psSymbolpointer != NULL);
if (is_symbol_a_function (psSymbolpointer))
{
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, INTERRUPT_INDEX );
if( siNonZeroWhenFunctionIsAnInterruptFunction == 0)
{
siNonZeroWhenFunctionIsAnInterruptFunction =
is_in_pragma ( psSymbolpointer, SWI_INDEX );
};
else
{
}
J1
if( siNonZeroWhenFunctionIsAnInterruptFunction )
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_INTERRUPT_FUNCTION
);
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *)psSegmentInformation;
}
else
{
7
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
psSegmentInformation = ( sSegmentInformation *)
psGetActiveSegmentInformation
(
ACTIVE_SEG_INDEX_NORMAL_FUNCTION
);
psSymbolpointer->spSegmentInformation =
( sSegmentInformation *) psSegmentInformation;
}
Enter
J2
} a
else P1
{
b
}
c
J3F D1
T
}
P2
Exit of the function
d
F T
D2
e
g
P3
f
J1
n JJ1
F T
D2
k i
P5 P4
l j
3.4 Control Flow graph
J2
J2
m
J3
8
Exit
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
9
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
F C’ C T
3.9 Control flow graph with named predicates D2
k i
P5 P4
l j
J2
J2
10
m
J3
Exit
o
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
3.10.1 Predicate: A
This predicate checks whether the symbol present in the variable
"psSymbolpointer" is a symbol for a function or not. The variable is passed as
an argument to the function "is_symbol_a_function ". The function returns the
11
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
value 0 if the symbol is not for a function and a non-zero value if the symbol is
for a function.
3.10.2 Predicate: B
This predicate checks whether the variable "siNonZeroWhenFunctionIsAnInte
rruptFunction" is equal to zero or not. This variable will be set only when the
function which symbol pointer is to be updated is a normal interrupt function.
Here it is checked whether the variable is set by the function "is_in_pragma
(psSymbolpointer, INTERRUPT_INDEX)” The function will set the variable
only if the function is a normal interrupt function else resets.
3.10.3 Predicate: C
This predicate checks whether the variable "siNonZeroWhenFunctionIsAnInte
rruptFunction" is set or not. This variable will be set only when the function for
which symbol pointer is to be updated is a normal interrupt function or a SWI
interrupt function. Here it is checked whether the variable is set by the
functions "is_in_pragma (psSymbolpointer, INTERRUPT_INDEX)" or
is_in_pragma (psSymbolpointer, SWI_INDEX)". These functions will set the
variable only if the function is a normal interrupt function or a SWI interrupt
function.
3.11.1 Predicate: A
The predicate A will be true when the symbol passed as argument to the
function is a function symbol. If the symbol is not for a function then the
predicate A will fail.
3.11.2 Predicate: B
The predicate B will be true when the function-symbol passed as argument for
this function is for a normal interrupt function. Else it will be false.
3.11.3 Predicate: C
The predicate C will be true when the function-symbol passed as argument for
this function is for a normal interrupt function or for a SWI interrupt function.
Else it will be false.
4 Cyclomatic Complexity
Now we have to find the number of independent paths (i.e. basis set) to cover
all the control statements.
12
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
Applying the above formula in the control flow graph of our function, we shall
get the Cyclomatic complexity of the function.
Number of Edges = 15
Number of Nodes = 13
= 15 - 13 + 2
= 4
Hence the number of independent paths needed to cover all the control
statements is 4.
Path Predicates
a-b-n-o A’
a-b-c-d-e-f-h-i-j-m-o ABC
a-b-c-d-e-f-h-k-l-m-o ABC’
a-b-c-d-g-h-i-j-m-o AB’C
The above path list shows the possible number of independent paths in the
control flow graph. From the following decision table we can assure that
whether we have achieved the complete path coverage or not.
13
Path Testing/Chandra Kumar R
Dated: 07 Jan 2005
DECISIONS PROCESS-LINK
PATHS D1 D2 D3 a b c d e f g h i j k l m n o
a-b-n-o n y y y y
a-b-c-d-e-f-h-i-j-m-o y y y y y y y y y y y y y y
a-b-c-d-e-f-h-k-l-m-o y y n y y y y y y y y y y y
a-b-c-d-g-h-i-j-m-o y n y y y y y y y y y y y
COVERAGE y y y y y y y y y y y y y y y y y y
As per the decision table every decisions has ‘Yes’ and ‘No’ in its column and
every process-links are covered at least once.
14