Documente Academic
Documente Profesional
Documente Cultură
-1-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
that would be used for identifying the case generation system that
test cases. allows the tester/user to input a
‘C’ program. It will parse
Various problems addressed by this through the program. Based on
automatic test case generation tool are the internal structure of the
as follows: program, CFG (Control Flow
Graph) for the input program is
• Manual generation of test cases generated. This will provide a
leads to the wastage of resources graphical view of the logic of the
like time, money and manpower. program.
• Human biases are involved • The automatic test case
during the manual generation of generation tool will use this CFG
test cases. generated to generate the CFG
• The unavailability of a reliable matrix. Using this CFG matrix,
testing approach leads to the various possible paths through
production of an unreliable the program will be identified.
software product. • First, the automatic test case
• Software providers are losing generation tool will be
their confidence in users. implemented using random
affects the further level of testing • Finally, this tool will generate the
-2-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
-3-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
automatic test cases for the structured Symbolic Execution is performed using
programming language. Finally, the Random Testing Based Automatic Test
developer has selected ‘C’ Language as Data Generation technique, for this
the targeted structured language. Automatic Test Case Generation Tool.
Therefore, this Automatic Test Case 4.1 Working Of Automatic Test Case
Generation Tool will generate test cases Generation Tool based on Random
for a ‘C’ Language program and will use Testing:
the all testing strategies and techniques Step 1: The Automatic Test Case
that are already being decided by the Generation Tool will allow the user to
developer to use after a lot of research parse a ‘C’ Language program.
work done earlier (Refer Fig. 3.3). Step 2: The tool will convert the input
program source code into the
instrumented source code.
Step 3: The tool will generate the CFG
for the instrumented program.
Step 4: From the CFG of the program,
CFG matrix generated.
Step 5: Using the CFG matrix, all
possible paths will be identified as the
testing criteria used in the system is path
testing (all path testing).
Step 6: The tool will statically execute
feasible paths using Symbolic
Execution.
Step 7: Finally, the tool will generate
test cases for the symbolically executed
paths using Random Testing technique.
It is analysed for automatic test case
generation to go for the Computer Based 5. CFG
Testing technique - Symbolic Execution. CFG stands for Control Flow Graph. It
describes the logical structure of the
-4-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
program. It consists of nodes and edges. 19---if((a!=b) && (a!=c) && (b!=c))
Actually it is a directed graph which 20---printf(“scalene”);
shows the all possible ways for the flow 21---else
of control through the program 22---printf(“isosceles”);
beginning from the start node of the 23---}
program to the exit node of the program. 24---else
These various possible flows of control 25--- printf(“not a triangle”);
through the program are the various 26--- printf(“end of program”);
possible paths through the program.
Refer Fig. 3.5 for the CFG of program
Consider one simple example to better
mentioned above.
understand the concept of CFG.
-5-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
Feasible paths are the paths for which the other is Internal Variable. In
some input data is available to execute symbolic execution, the input variables
them and for infeasible paths vice-versa. of a program are assigned symbolic
values. These symbolic values are fixed
and unknown.
Symbolic execution basically
distinguishes between two types of
statements, one is the assignment
statement and the other is decision
making / branching statement.
First, the developer is discussing about
assignment statement. Suppose a
program P is having two input variables
a, b and an internal variable c.
The assignment statement is c = a + b
Other assignment statement is d = c - a
-6-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
& B>0 & C>0). If (A>0 & B>0 & C>0) Suppose if path: Node1-> Node3->
yields true then, the control flow of the Node4 ->Node14 is considered. Then,
program will move from node 1 to node the symbolic evaluation of this path
3 and if (A>0 & B>0 & C>0) yields yields the following path predicate
false then, the control flow of the expression:
program will move from node 1 to node ((A>0 && B>0 && C>0) AND !
2. So, during symbolic execution, the (A<B+C && B<A+C && C<A+B)).
predicate expression for case (when Now, using random testing the symbolic
condition (A>0 & B>0 & C>0) is true) is values are placed by randomly generated
expressed as (A>0 & B>0 & C>0) and in values and the values which will satisfy
other case (when condition (A>0 & B>0 this path predicate expression, means
& C>0) is false), the predicate those set of values can execute the path
expression will be !(A>0 & B>0 & and the set of values is one test data for
C>0). the program.
Similarly, it will be done for each 6.1 Random Testing Technique
decision making / branching statement.
Random Testing Technique is used in
Finally, for a particular path, all the
this automatic test case generation tool
predicates expressions are conjunctively
to select values randomly from the input
joined to form path predicate expression.
domain of the program input variables.
This path predicate expression will
These randomly generated values are
contain the input and internal variables
assigned to the symbolic values and then
in terms of symbolic values.
the predicate expressions for all decision
making nodes in a path are joined using
logical AND to form a conjunctive
clause for that particular path. Then,
randomly generated values are used to
satisfy the conjunctive clause. The
values which will be able to satisfy the
conjunctive clause for a path become the
test data for that path to execute.
7. Problems Identified After Research
-7-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
-8-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
-9-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
-10-
Automatic Test Case Generation Of ‘C’ Programs Using CFG
-11-