CN103207833B - The disposal route of loop code and system in software test - Google Patents

The disposal route of loop code and system in software test Download PDF

Info

Publication number
CN103207833B
CN103207833B CN201310113328.XA CN201310113328A CN103207833B CN 103207833 B CN103207833 B CN 103207833B CN 201310113328 A CN201310113328 A CN 201310113328A CN 103207833 B CN103207833 B CN 103207833B
Authority
CN
China
Prior art keywords
subpath
loop body
path
loop
previous cycle
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201310113328.XA
Other languages
Chinese (zh)
Other versions
CN103207833A (en
Inventor
宫云战
黄俊飞
王雅文
王强
金大海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing University of Posts and Telecommunications filed Critical Beijing University of Posts and Telecommunications
Priority to CN201310113328.XA priority Critical patent/CN103207833B/en
Publication of CN103207833A publication Critical patent/CN103207833A/en
Application granted granted Critical
Publication of CN103207833B publication Critical patent/CN103207833B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses the disposal route of loop code in a kind of software test, first according to program control flowchart, search the loop body of tested code, determine subpath before the loop body of previous cycle body, determine all single sub path of previous cycle body again, combine described single sub path for combination subpath, when before described loop body, the collection routes of subpath and described combination subpath is for reaching, determine that described combination subpath is previous cycle body stator path really, when before determining described loop body, subpath and the described collection routes determining subpath are for reaching, generating test use case, and according to described test case, perform tested code, catch the actual execution route of described previous cycle body, repeat above-mentioned steps, until process all loop bodies of tested code.The invention also discloses the disposal system of loop code in a kind of software test simultaneously.Dirigibility of the present invention is high, can save human cost, avoid path explosion.

Description

The disposal route of loop code and system in software test
Technical field
The present invention relates to software testing technology, be specifically related to disposal route and the system of loop code in a kind of software test.
Background technology
Software test is in a controlled environment, carry out the process that source program (tested code) analyzes or perform, and its basic goal finds with the least possible time and manpower and corrects fault potential in software and defect, and then raising software quality.It is comprehensive closely bound up that the accuracy rate of software test and test path generate.
In prior art, by the node in traversal program controlling stream graph, generate test path, utilize test case to perform source program along test path.When the node in program control flowchart is sequential node and source program is sequential statement, then can generate a clear and definite test path; But when occurring in program control flowchart occurring loop statement in branch node and source program, existing conventional treatment method is as tactful in 0-1 or 0-K is tactful, loop statement is regarded as and judges that statement processes, miss the generation in partial test path in the middle of invisible, test path generates do not make the accuracy rate of software test decline comprehensively.In addition, also as artificial nominative testing path, loop statement is processed by manual method, which substantially increases human cost; Moreover manual method dirigibility is poor, be difficult to the demand adapting to different engineering project.
Summary of the invention
In view of this, fundamental purpose of the present invention is the disposal route and the system that provide loop code in a kind of software test, can ensure that test path generates comprehensive, dirigibility is high, can save human cost.
For achieving the above object, technical scheme of the present invention is achieved in that
The invention provides the disposal route of loop code in a kind of software test, described method comprises:
According to program control flowchart, search the loop body of tested code;
Determine subpath before the loop body of previous cycle body;
Determine all single sub path of previous cycle body, combine described single sub path for combination subpath, when the collection routes of subpath and described combination subpath is for reaching before described loop body, determine that described combination subpath is previous cycle body stator path really;
When before determining described loop body, subpath and the described collection routes determining subpath are for reaching, generating test use case;
According to described test case, perform tested code, catch the actual execution route of described previous cycle body.
In such scheme, described method also comprises:
After the actual execution route of all loop bodies of tested code is captured, generates the complete test path of tested code, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
In such scheme, describedly determine subpath before the loop body of previous cycle body, comprising:
Determine previous cycle body be first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point for reaching time, determine that the path between the Ingress node of described program control flowchart to previous cycle body starting point is subpath before loop body;
Determine that previous cycle body is first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point is unreachable time, described infeasible paths is transformed into reachable path, determines that described reachable path is subpath before loop body;
Determine that previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is for reaching, before determining described new loop body, subpath is subpath before loop body;
Determine that previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is unreachable, subpath before described new loop body is transformed into reachable path, and before determining described new loop body, subpath is subpath before loop body.
In such scheme, the described all single sub path determining previous cycle body, comprising:
Travel through the node on tested program in machine code controlling stream graph according to the order of sequence, the set in the path between the loop body start node traversed to loop body end node is all single sub path of loop body.
In such scheme, the described single sub path of described combination is combination subpath, determines that described combination subpath is previous cycle body stator path really, comprising:
The single sub path chosen successively in described all single sub path is target subpath, other single sub path are with reference to subpath, gathering described at least one with reference to subpath and described target subpath is described combination subpath or to gather described target subpath be described combination subpath, and utilizes target subpath stator path really described in the coordinates measurement strategy generating that circulates.
In such scheme, described determine described loop body before subpath and the described collection routes determining subpath for reaching time, generating test use case, comprising:
Choose successively and determine subpath, determine that subpath is half single sub path described in sub cost sum before set loop body, when determining described half single sub path for reaching, generate the test case of described half single sub path.
In such scheme, the complete test path of the tested code of described generation, generates complete test case, and utilizes the coverage test criterion preset tested code to be performed to the coverage test of described complete test case, comprising:
Set loop body before subpath, determine last loop body of the tested code of sub cost sum to program control flowchart Egress node between path be complete test path, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
Present invention also offers the disposal system of loop code in a kind of software test, described system comprises: search unit, the first determining unit, the second determining unit, generation unit and capturing unit; Wherein,
Describedly search unit, for according to program control flowchart, search the loop body of tested code;
Described first determining unit, for determine previous cycle body loop body before subpath;
Described second determining unit, for determining all single sub path of previous cycle body, combine described single sub path for combination subpath, when the collection routes of subpath and described combination subpath is for reaching before described loop body, determine that described combination subpath is previous cycle body stator path really;
Described generation unit, for subpath before determining described loop body and described determine the collection routes of subpath for reaching time, generating test use case;
Described capturing unit, for according to described test case, performs tested code, catches the actual execution route of described previous cycle body.
In such scheme, described system also comprises test cell;
Described test cell, after captured for the actual execution route of all loop bodies of tested code, generate the complete test path of tested code, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
In such scheme, described second determining unit, be further used for traveling through the node on tested program in machine code controlling stream graph according to the order of sequence, the set in the path between the loop body start node traversed to loop body end node is all single sub path of loop body, the single sub path chosen successively in described single sub path is target subpath, other single sub path are with reference to subpath, gathering reference subpath and described target subpath described at least one is described combination subpath, or to gather described target subpath be described combination subpath, and target subpath stator path really described in the coordinates measurement strategy generating of utilization circulation.
The disposal route of loop code and system in software test provided by the invention, first according to program control flowchart, search the loop body of tested code, determine subpath before the loop body of previous cycle body, determine all single sub path of previous cycle body again, combine described single sub path for combination subpath, and by the collection routes of subpath before described loop body and described combination subpath for reaching time, determine that described combination subpath is previous cycle body stator path really, then when before determining described loop body, subpath and the described collection routes determining subpath are for reaching, generating test use case, and according to described test case, perform tested code, catch the actual execution route of described previous cycle body, repeat above-mentioned steps until process all loop bodies of described tested code, after the actual execution route of all loop bodies of tested code is captured, generate complete test path and coverage test is carried out to described tested code.The present invention can realize generating test path comprehensive, and dirigibility is higher, without the need to artificial nominative testing path; Also utilize accessibility to judge to get rid of non-reachable path, retain reachable path simultaneously, process resource can be saved, avoid the path explosion problem occurred in software test.
Accompanying drawing explanation
Fig. 1 is the realization flow schematic diagram of the disposal route of loop code in software test of the present invention;
Fig. 2 is the program control flowchart schematic diagram of the specific embodiment of the invention;
The schematic diagram that Fig. 3 (a) ~ 3 (b) is specific embodiments of the invention;
Fig. 4 is the composition structural representation of the disposal system of loop code in software test of the present invention.
Embodiment
The invention provides the disposal route of loop code in a kind of software test, as shown in Figure 1, described method comprises:
Step 1: according to program control flowchart, search the loop body of tested code;
Step 2: determine subpath before the loop body of previous cycle body;
Step 3: all single sub path determining previous cycle body, combine described single sub path for combination subpath, when the collection routes of subpath and described combination subpath is for reaching before described loop body, determine that described combination subpath is previous cycle body stator path really;
Step 4: when subpath and the described collection routes determining subpath are for reaching before determining described loop body, generating test use case;
Step 5: according to described test case, performs tested code, catches the actual execution route of described previous cycle body.
Further, after the actual execution route of all loop bodies of catching described tested code, described method also comprises:
Step 6: the complete test path generating tested code, generates complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
Here, described coverage test criterion comprises: branch's covering, statement covering, Condition Coverage Testing etc.
In technique scheme, described step 2 is the situation of the loop body that can find tested code, when finding tested code loop body, continues to perform step 6.
Further, described step 2 is:
Determine previous cycle body be first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point for reaching time, determine that the path between the Ingress node of described program control flowchart to previous cycle body starting point is subpath before loop body;
Determine that previous cycle body is first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point is unreachable time, described infeasible paths is transformed into reachable path, determines that described reachable path is subpath before loop body;
Determine that previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is for reaching, before determining described new loop body, subpath is subpath before loop body;
Determine that previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is unreachable, subpath before described new loop body is transformed into reachable path, and before determining described new loop body, subpath is subpath before loop body.
Here, describedly described infeasible paths is transformed into reachable path, subpath before described new loop body is transformed into reachable path mainly adopts branch's substitute mode.
Further, described step 3 is:
Describedly determine that all single sub path of previous cycle body are:
Travel through the node on tested program in machine code controlling stream graph according to the order of sequence, the set in the path between the loop body start node traversed to loop body end node is all single sub path of loop body.
Here, be called for short that described loop body start node is loop body starting point, loop body end node is loop body end point.
The described single sub path of described combination for combination subpath, determine described combination subpath be previous cycle body really stator path be:
The single sub path chosen successively in described all single sub path is target subpath, other single sub path are as reference subpath, gathering described at least one with reference to subpath and described target subpath is described combination subpath or to gather described target subpath be described combination subpath, and utilizes target subpath stator path really described in the coordinates measurement strategy generating that circulates.
Further, described step 4 is:
Choose successively and determine subpath, determine that subpath is half single sub path described in sub cost sum before set loop body, when determining described half single sub path for reaching, generate the test case of described half single sub path.
In described step 5, do by the code of the previous cycle body to actual motion the actual execution route that mark catches previous cycle body.
Further, described step 6 is:
Subpath before set loop body, determine that subpath is complete test path after sub cost sum loop body, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
Here, after defining described loop body subpath be described tested code last loop body to program control flowchart Egress node between path.
Concrete, described step 2 is:
Here, subpath prepath before the loop body of described previous cycle body is represented;
Step 21: when finding the loop body of tested code, determines that whether previous cycle body is first loop body of tested code further;
When determining that previous cycle body is first loop body of tested code, continue to perform step 22;
When determining that previous cycle body is not first loop body of tested code, continue to perform step 24;
Step 22: determine whether the path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point is to reach;
When being defined as reaching, continue to perform step 23;
When being defined as unreachable, continue to perform step 27;
Here, accessibility criterion is: in path, all variable-values are not all for empty, then think that path is to reach; Have the value of a variable in path at least for empty, then think that path is unreachable; When the explanation of the technical program, every relating to can to reach with inaccessible judgement implication all with identical herein, repeats no more.
Step 23: determine that the path between described Ingress node to previous cycle body starting point is subpath prepath before the loop body of previous cycle body, step 2 flow process terminates;
Step 24: by subpath before the loop body of the set of paths Cheng Xin between a upper loop body to previous cycle body of the actual execution route of the upper loop body that captures in subpath, step 5 before the loop body of a upper loop body of tested code, tested code, continues to perform step 25;
Step 25: before determining described new loop body, whether subpath is to reach;
When being defined as reaching, perform step 26;
When being defined as unreachable, perform step 27;
Step 26: before determining described new loop body, subpath is subpath prepath before the loop body of previous cycle body (non-first loop body), and step 2 flow process terminates;
Step 27: reachable path is transformed into described infeasible paths, and determine that described reachable path is subpath prepath before the loop body of previous cycle body, step 2 flow process terminates;
Wherein, infeasible paths is transformed into reachable path by the main branch's substitute mode that adopts: the backward traversal of carrying out node from the unreachable node location on program control flowchart, carries out branch's replacement to other branch nodes in path.
Concrete, described step 3 is:
Described determine described combination subpath be previous cycle body really stator path be:
Here, the Article 1 single sub path chosen in previous cycle body is current subpath;
Step 31: using current single sub path as target subpath pathk, other single sub path are as reference subpath path1...pathk-1;
Here, the value arranging iteration degree of depth k is less than or equal to iteration depth threshold.
Step 32: the coordinates measurement strategy utilizing circulation, described target subpath is determined to the generation of subpath, next single sub path chosen in previous cycle body is current subpath, return step 31, until using all single sub path of previous cycle body all as a target subpath.
Here, the coordinates measurement strategy of described circulation make use of depth-first principle:
Step 321: initialization iteration degree of depth k, before the loop body of set previous cycle body, subpath and described target subpath are collection routes, determine whether described collection routes is to reach;
When being defined as reaching, be defined as described target subpath for determining subpath;
Here, for convenience of describe, also can by do not relate to other with reference to subpath wall scroll described in target subpath for combination subpath;
When being defined as unreachable, perform step 322;
Step 322: iteration degree of depth k is from adding 1, in the current iteration degree of depth, single sub path (with reference to the subpath) pathk-1 of single sub path (with reference to subpath) path1... kth-1 execution loop body of set first time execution loop body and target subpath (the subpath pathk of kth time execution loop body) are for combining subpath; And the collection routes of subpath and described combination subpath is collection routes before gathering loop body, determine whether described collection routes can reach;
When can reach, determine that described combination subpath is for determining subpath;
Time unreachable, continue to perform step 322, until iteration degree of depth k is iteration depth threshold (maximal value).
Here, described iteration depth threshold is formulated according to the needs of engineering project.
Concrete, described step 4 is:
Here, choose and currently determine that subpath is Article 1 determination subpath;
Step 41: subpath and currently determine that subpath is half single sub path before the loop body of set previous cycle body, determines whether described half single sub path is to reach;
When being defined as reaching, generate the test case of described half single sub path;
When being defined as unreachable, perform step 42;
Step 42: choose next and determine that subpath is currently determine subpath, turn back to step 41, until all of previous cycle body are determined that subpath processes.
Below with loop body be first loop body Cyc1 of tested code Program, the initial value of iteration degree of depth k for 1, iteration depth threshold is 3, described first loop body Cyc1 has two branch node C and C ' for example and elaborate to technical scheme of the present invention.
Arranging loop body start node is loop body starting point LoopHead, and loop body end node is loop body end point LoopOut; The left child node of described branch node C is A, right child node is B; The left child node of described branch node C ' is A ', right child node is B '; On the program control flowchart of described tested code Program, before described branch node C ' is positioned at described branch node C.
Described step 1 is specifically as follows: definition queue, is used for storing loop body starting point LoopHead in tested code Program; Travel through the node of the program control flowchart of tested code Program, when finding loop body starting point, loop body starting point is pressed into queue, when finding loop body end point LoopOut corresponding to described loop body starting point LoopHead, element (being pressed into the node into queue) in queue is carried out the dequeue operation of node, determine that now queue is for time empty, then think that the element of firm dequeue is a loop body; Here, be occur in pairs to the description of node in program control flowchart, as loop body starting point LoopHead be for_head, corresponding loop body end point LoopOut is for_out; Loop body starting point LoopHead is while_head, corresponding loop body end point LoopOut is while_out.
Described step 2 is specifically as follows: when finding first loop body Cyc1 starting point of tested code Program, backward traversal program controlling stream graph, namely from described first loop body Cyc1 starting point, searching of the Ingress node of described program control flowchart is carried out to the Ingress node direction of described program control flowchart, find described Ingress node, when determining path between described Ingress node to a first loop body Cyc1 starting point for reaching, before determining the loop body of first loop body Cyc1, subpath prepath is that the Ingress node of the program control flowchart of tested code Program is to the path between self starting point.
Described step 3 is specifically as follows: in superincumbent description, path between the loop body start node LoopHead to loop body end node LoopOut traversed has at least one, why says that at least having a paths can traverse previous cycle body end point LoopOut from previous cycle body starting point LoopHead and consider that program control flowchart has the existence of branch node.For branch node, be handled as follows in the present embodiment:
Definition stack, is used for storing all single sub path of described first loop body Cyc1; When the node of program control flowchart is not pressed into and pushes on, be all designated " access ";
Fig. 2 is the program control flowchart schematic diagram of the specific embodiment of the invention, in figure, each zero represents a node, composition graphs 2, the node of traversal program controlling stream graph, by the node traversed as left child node A ', the branch node C of branch node C ', branch node C ' and as described in the left child node A (referred to as C ' A ' CA) of branch node C be pressed into successively push on time, and identify above-mentioned node for " accessing "; Described C ' A ' CA is Article 1 single sub path;
Characteristic because of stack is first-in last-out, when searching the Article 2 single sub path of first loop body Cyc1, all nodes in Article 1 single sub path is carried out Pop operations, and order of popping is for stack top element is to bottommost element, so the left child node A of the branch node C in Article 1 individual paths is first carried out Pop operations, now described left child node A is still designated " accessing ", and when traversing described branch node C, determine that child node that whether described branch node C also exists other is designated " access ", here, the right child node B finding described branch node C is designated " access ", then the right child node B press-in of described branch node C is pushed on, form Article 2 single sub path C ' A ' CB, node in Article 2 single sub path from the node in Article 1 single sub path except the child node of described branch node C is different, all the other are identical node,
When searching Article 3 single sub path, all nodes in Article 2 single sub path are carried out Pop operations, the right child node B of described branch node C first pops, and is still designated " accessing "; When traversing described branch node C, determine that child node that whether described branch node C also exists other is designated " access ", here, because described branch node C only has two child node A and B, now described two child node A and B all pop, the left child node A popped, right child node B are again designated " access ", at this moment described branch node C pops, and is designated " access ".Next, the left child node A ' of described branch node C ' pops, replacement operation is not done to the left child node A ' of described branch node C ', namely to the change that the left child node A ' of the described branch node C ' popped does not make a check mark, is still designated " accessing "; When traversing described branch node C ', find described branch node C ' also to have right child node B ' and be designated " access ", then right for described branch node C ' child node B ' press-in is pushed on, and be designated " accessing ", now be positioned at described branch node C below described branch node C ' and left child node A thereof to be " access ", described branch node C and left child node A thereof press-in is pushed on, and is designated " accessing ", form Article 3 single sub path C ' B ' CA;
When searching Article 4 single sub path, the node of Article 3 single sub path is carried out Pop operations, the left child node A of described branch node C first carries out Pop operations, still be designated " accessing ", and when traversing described branch node C, the right child node finding now described branch node C is designated " access ", then the right child node B press-in of described branch node C pushed on, form Article 4 single sub path C ' B ' CB;
By that analogy, all single sub path of first loop body Cyc1 can be found.
The specific embodiment that Fig. 3 (a) ~ 3 (b) is implementation method of the present invention, in the present embodiment, described determine first loop body Cyc1 really the process of stator path and step 4 can be specially:
As shown in Fig. 3 (a), all single sub path finding described first loop body Cyc1 are followed successively by: single sub path p1, single sub path p2, single sub path p3 and single sub path p4.
As shown in Fig. 3 (b), using described single sub path p1 as target subpath, other single sub path p2 described, p3 and p4, as with reference to subpath, carry out the generation determining subpath.
Step 3211: arrange iteration degree of depth k=1, determines whether the collection routes of subpath prepath and described target subpath p1 is to reach before the loop body of described first loop body Cyc1;
When being defined as reaching, determining that described target subpath p1 is for determining subpath, continuing to perform step 411;
When being defined as unreachable, perform step 3221;
Step 3221: trace back to reference to subpath p2 (path1), the iteration degree of depth is carried out adding 1 operation, i.e. k=2, gathering described is that p2p1 combines subpath with reference to subpath p2 (path1), target subpath p1 (pathk), and whether the collection routes that before determining described loop body, subpath prepath and described p2p1 combines subpath can reach;
When being defined as reaching, determining that described p2p1 combines subpath for determining subpath, continuing to perform step 411;
When being defined as unreachable, continue to perform step 3222;
Step 3222: the iteration degree of depth is carried out adding 1 operation, i.e. k=3, gather described with reference to subpath p2 (path1), with reference to subpath p2 (path2), target subpath p1 (pathk) is p2p2p1 subpath, whether the collection routes that before determining described loop body, subpath prepath and described p2p2p1 combines subpath can reach;
When being defined as reaching, determining that described p2p2p1 combines subpath for determining subpath, continuing to perform step 411;
When being defined as unreachable, continue to perform step 3223;
Step 3223: iteration degree of depth k=3, gathering described is that p2p3p1 combines subpath with reference to subpath p2 (path1), with reference to subpath p3 (path2), target subpath p1 (pathk), and whether the collection routes that before determining described loop body, subpath prepath and described p2p3p1 combines subpath can reach;
When being defined as reaching, determining that described combination p2p3p1 subpath is for determining subpath, continuing to perform step 411;
When being defined as unreachable, continue to perform step 3224;
Step 3224: iteration degree of depth k=3, gathering described is that p2p4p1 combines subpath with reference to subpath p2 (path1), with reference to subpath p4 (path2), target subpath p1 (pathk), and whether the collection routes that before determining described loop body, subpath prepath and described p2p4p1 combines subpath can reach;
When being defined as reaching, determining that described p2p4p1 combines subpath for determining subpath, continuing to perform step 411;
When being defined as unreachable, in the current iteration degree of depth (for iteration depth threshold), process with all combination subpaths that described reference subpath p2, reference subpath pn (n=3 or 4) and target subpath p1 are set, now will perform step 3225;
Step 3225: trace back to reference to subpath p3 (path1), the iteration degree of depth is carried out subtracting 1 operation, i.e. k=2, gathering described is p3p1 combination subpath with reference to subpath p3 (path1) and target subpath p1 (pathk), determines that described p3p1 combines subpath and whether can reach;
When being defined as reaching, determining that described p3p1 combines subpath for determining subpath, continuing to perform step 411;
When being defined as unreachable, continue to perform step 3226;
Step 3226: the iteration degree of depth is carried out adding 1 operation, i.e. k=3, gathering described is p3p2p1 combination subpath with reference to subpath p3 (path1), with reference to subpath p2 (path2) and target subpath p1 (pathk), and whether the collection routes that before determining described loop body, subpath prepath and described p3p2p1 combines subpath can reach;
When being defined as reaching, determining that described p3p2p1 combines subpath for determining subpath, continuing to perform step 411;
By that analogy, until to determine in described first loop body Cyc1 all determine subpath;
Step 411: subpath prepath and describedly determine that subpath is half single sub path before gathering the loop body of described first loop body Cyc1, when determining described half single sub path for reaching, generate the test case of described half single sub path, according to described test case, perform tested code, caught the actual execution route of described first loop body Cyc1 by the code identifying actual motion.
Described above to the process of first loop body Cyc1 of tested code Program in the present embodiment, when also having other loop bodies (second loop body ... M loop body in tested code Program, M value be greater than 1 positive integer) time, determine all subpaths of other loop bodies described, determine describedly to determine that the process of subpath is similar to described first loop body, before the loop body of just other loop bodies described, before the value of subpath prepath and the loop body of described first loop body, the value of subpath path is slightly different, concrete with reference to the step 21 ~ step 27 in technique scheme.
After all loop bodies of tested code Program complete according to technique scheme process, subpath before gathering the loop body of described tested code Program, determine sub cost sum loop body after subpath be complete test path, generate complete test case, utilize coverage test criterion, as branch's covering, statement covering etc. to perform the coverage test of complete test case to tested code.
Here, after described loop body subpath be described tested code Program last loop body to program control flowchart Egress node between path.
In the present invention, described loop body is the outermost loop of described tested code.
For the disposal route of loop code in above-mentioned software test, the present invention also describes the disposal system of loop code in a kind of software test, as shown in Figure 4, described system comprises: search unit 400, first determining unit 401, second determining unit 402, generation unit 403 and capturing unit 404; Wherein,
Describedly search unit 400, for according to program control flowchart, search the loop body of tested code;
Described first determining unit 401, for determine previous cycle body loop body before subpath;
Described second determining unit 402, for determining all single sub path of previous cycle body, combine described single sub path for combination subpath, when the collection routes of subpath and described combination subpath is for reaching before described loop body, determine that described combination subpath is previous cycle body stator path really;
Described generation unit 403, for subpath before determining described loop body and described determine the collection routes of subpath for reaching time, generating test use case;
Described capturing unit 404, for according to described test case, performs tested code, catches the actual execution route of described previous cycle body.
Wherein, described system also comprises test cell 405;
Described capturing unit 404 is described test cell 405 after having caught the actual execution route of all loop bodies of described tested code, for generating the complete test path of tested code, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
Here, described coverage test criterion comprises branch's covering, statement covering, Condition Coverage Testing etc.
Further, described unit 400 of searching is searched according to the loop body of program control flowchart to tested code of tested code, find described tested code when having loop body, notify described first determining unit 401, described first determining unit 401 determines that whether previous cycle body is first loop body of tested code.
Described first determining unit 401 is defined as previous cycle body when being first loop body of tested code, and when determining path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point for reaching, determine that the path between the Ingress node of described program control flowchart to previous cycle body starting point is subpath before the loop body of previous cycle body;
Described first determining unit 401 determine that previous cycle body is first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point is unreachable time, adopt branch's substitute mode that described infeasible paths is transformed into reachable path, determine that described reachable path is subpath before loop body;
Described first determining unit 401 determines that previous cycle body is non-first loop body of tested code, before gathering the loop body of a upper loop body of tested code the actual execution route of the upper loop body that subpath, described capturing unit 404 capture, tested code a upper loop body to previous cycle body between path be subpath before new loop body, when before described new loop body, subpath is for reaching, before determining described new loop body, subpath is subpath before loop body;
Described first determining unit 401 determines that previous cycle body is non-first loop body of tested code, before gathering the loop body of a upper loop body of tested code the actual execution route of the upper loop body that subpath, described capturing unit 404 capture, tested code a upper loop body to previous cycle body between path be subpath before new loop body, when before described new loop body, subpath is unreachable, subpath before described new loop body is transformed into reachable path, and before determining described new loop body, subpath is subpath before loop body;
Here, adopt branch's substitute mode that described infeasible paths is transformed into reachable path: the backward traversal of carrying out node from the unreachable node location on program control flowchart, branch's replacement is carried out to other branch nodes in path; Accessibility criterion is: in path, all variable-values are not all for empty, then think that path is to reach; Have the value of a variable in path at least for empty, then think that path is unreachable; In the present invention, every relating to can to reach with inaccessible judgement implication all with identical herein, repeats no more.
Described second determining unit 402 travels through the node on tested program in machine code controlling stream graph according to the order of sequence, the set at least one path between the loop body start node traversed to loop body end node is all single sub path in loop body, the single sub path chosen successively in described single sub path is target subpath, other single sub path are as reference subpath, gathering reference subpath and described target subpath described at least one is described combination subpath, and target subpath stator path really described in the coordinates measurement strategy generating of utilization circulation.
Here, be called for short that described loop body start node is loop body starting point, loop body end node is loop body end point.
Described generation unit 403 is chosen successively and is determined subpath, determines that subpath is half single sub path, when determining described half single sub path for reaching, generate the test case of described half single sub path before set loop body described in sub cost sum.
Described capturing unit 404 does by the code of the previous cycle body to actual motion the actual execution route that mark catches previous cycle body, and the actual execution route of the previous cycle body captured is sent to described first determining unit 401, before being convenient to the loop body to next loop body of previous cycle body, subpath carries out assignment.
After described first determining unit 401, second determining unit 402, generation unit 403 and capturing unit 404 have caught the actual execution route of all loop bodies of described tested code, notify described test cell 405, subpath before described test cell 405 gathers loop body, determine sub cost sum loop body after subpath be complete test path, generate complete test case, utilize coverage test criterion to perform the coverage test of complete test case to tested code.
Here, after described loop body subpath be described tested code last loop body to program control flowchart Egress node between path.
The disposal route of loop code and system in software test provided by the invention, loop body in tested code is mainly handled as follows: first according to program control flowchart, search the loop body of tested code, determine subpath before the loop body of loop body, determine all single sub path of previous cycle body again, combine described single sub path for combination subpath, when the collection routes of subpath and described combination subpath is for reaching before described loop body, determine that described combination subpath is previous cycle body stator path really; Then subpath and describedly determine that the path of subpath is half single sub path before gathering described loop body, when determining described half single sub path for reaching, generate the test case of described half single sub path, and according to described test case, perform tested code, catch the actual execution route of described loop body, after as above method processes all loop bodies of described tested code, generate complete test path, complete test case, complete test path is performed to the coverage test of described complete test case.Different with 0-K strategy from the 0-1 strategy of prior art, the present invention can all possible paths of generation cycle body, and accessibility judgement is carried out to all possible paths generated, non-reachable path can be got rid of, retain reachable path, so can test path be made on the one hand to generate more comprehensively, avoid on the other hand waste and the path explosion of tested code process resource; Meanwhile, the present invention is compared with the method in existing artificial nominative testing path, and saving manpower, dirigibility are significantly improved.
The above, be only preferred embodiment of the present invention, be not intended to limit protection scope of the present invention.

Claims (8)

1. the disposal route of loop code in software test, it is characterized in that, described method comprises:
According to program control flowchart, search the loop body of tested code;
Determine subpath before the loop body of previous cycle body;
Before described loop body subpath comprise following any one:
Previous cycle body be first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point for reaching time, Ingress node to the path between previous cycle body starting point of described program control flowchart is subpath before loop body;
Previous cycle body be first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point is unreachable time, described infeasible paths is transformed into reachable path, and described reachable path is subpath before loop body;
Previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is for reaching, before described new loop body, subpath is subpath before loop body;
Previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is unreachable, subpath before described new loop body is transformed into reachable path, described in be transformed into the described new loop body of reachable path before subpath be subpath before loop body;
Determine all single sub path of previous cycle body, combine described single sub path for combination subpath, when before described loop body, the collection routes of subpath and described combination subpath is for reaching, determine that described combination subpath is previous cycle body stator path really, all single sub path of described loop body are travel through the node on tested program in machine code controlling stream graph according to the order of sequence, the set in the path between the loop body start node traversed to loop body end node;
When before determining described loop body, subpath and the described collection routes determining subpath are for reaching, generating test use case;
According to described test case, perform tested code, catch the actual execution route of described previous cycle body.
2. the disposal route of loop code in software test according to claim 1, it is characterized in that, described method also comprises:
After the actual execution route of all loop bodies of tested code is captured, generates the complete test path of tested code, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
3. the disposal route of loop code in software test according to claim 1, is characterized in that, the described single sub path of described combination is combination subpath, determines that described combination subpath is previous cycle body stator path really, comprising:
The single sub path chosen successively in described all single sub path is target subpath, other single sub path are with reference to subpath, gathering described at least one with reference to subpath and described target subpath is described combination subpath or to gather described target subpath be described combination subpath, and utilizes target subpath stator path really described in the coordinates measurement strategy generating that circulates.
4. the disposal route of loop code in software test according to claim 1, is characterized in that, described determine described loop body before subpath and described when determining the collection routes of subpath for reaching, generating test use case, comprising:
Choose successively and determine subpath, determine that subpath is half single sub path described in sub cost sum before set loop body, when determining described half single sub path for reaching, generate the test case of described half single sub path.
5. according to the disposal route of loop code in the arbitrary described software test of claim 2 to 4, it is characterized in that, the complete test path of the tested code of described generation, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of described complete test case, comprising:
Set loop body before subpath, determine last loop body of the tested code of sub cost sum to program control flowchart Egress node between path be complete test path, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
6. the disposal system of loop code in software test, it is characterized in that, described system comprises: search unit, the first determining unit, the second determining unit, generation unit and capturing unit; Wherein,
Describedly search unit, for according to program control flowchart, search the loop body of tested code;
Described first determining unit, for determine previous cycle body loop body before subpath, before described loop body subpath comprise following any one:
Previous cycle body be first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point for reaching time, Ingress node to the path between previous cycle body starting point of described program control flowchart is subpath before loop body;
Previous cycle body be first loop body of tested code and path between the Ingress node of the program control flowchart of tested code to previous cycle body starting point is unreachable time, described infeasible paths is transformed into reachable path, and described reachable path is subpath before loop body;
Previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is for reaching, before described new loop body, subpath is subpath before loop body;
Previous cycle body is non-first loop body of tested code and path between a upper loop body to previous cycle body of subpath before gathering the loop body of a upper loop body of tested code, the actual execution route of a upper loop body captured, tested code is subpath before new loop body, when before described new loop body, subpath is unreachable, subpath before described new loop body is transformed into reachable path, described in be transformed into the described new loop body of reachable path before subpath be subpath before loop body;
Described second determining unit, for determining all single sub path of previous cycle body, combine described single sub path for combination subpath, when before described loop body, the collection routes of subpath and described combination subpath is for reaching, determine that described combination subpath is previous cycle body stator path really, all single sub path of described loop body are travel through the node on tested program in machine code controlling stream graph according to the order of sequence, the set in the path between the loop body start node traversed to loop body end node;
Described generation unit, for subpath before determining described loop body and described determine the collection routes of subpath for reaching time, generating test use case;
Described capturing unit, for according to described test case, performs tested code, catches the actual execution route of described previous cycle body.
7. the disposal system of loop code in software test according to claim 6, it is characterized in that, described system also comprises test cell;
Described test cell, after captured for the actual execution route of all loop bodies of tested code, generate the complete test path of tested code, generate complete test case, and utilize the coverage test criterion preset tested code to be performed to the coverage test of complete test case.
8. the disposal system of loop code in the software test according to claim 6 or 7, it is characterized in that, described second determining unit, be further used for traveling through the node on tested program in machine code controlling stream graph according to the order of sequence, the set in the path between the loop body start node traversed to loop body end node is all single sub path of loop body, the single sub path chosen successively in described single sub path is target subpath, other single sub path are with reference to subpath, gathering reference subpath and described target subpath described at least one is described combination subpath, or to gather described target subpath be described combination subpath, and target subpath stator path really described in the coordinates measurement strategy generating of utilization circulation.
CN201310113328.XA 2013-04-02 2013-04-02 The disposal route of loop code and system in software test Expired - Fee Related CN103207833B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310113328.XA CN103207833B (en) 2013-04-02 2013-04-02 The disposal route of loop code and system in software test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310113328.XA CN103207833B (en) 2013-04-02 2013-04-02 The disposal route of loop code and system in software test

Publications (2)

Publication Number Publication Date
CN103207833A CN103207833A (en) 2013-07-17
CN103207833B true CN103207833B (en) 2016-04-06

Family

ID=48755062

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310113328.XA Expired - Fee Related CN103207833B (en) 2013-04-02 2013-04-02 The disposal route of loop code and system in software test

Country Status (1)

Country Link
CN (1) CN103207833B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302994B (en) * 2023-02-28 2023-10-10 浙江大学 Hierarchical matching method, device and equipment for program paths and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6694456B1 (en) * 1997-12-09 2004-02-17 Siemens Aktiengesellschaft Method for checking path coverage in software tests
CN102073587A (en) * 2010-12-27 2011-05-25 北京邮电大学 Static detection method for inaccessible route in program

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6694456B1 (en) * 1997-12-09 2004-02-17 Siemens Aktiengesellschaft Method for checking path coverage in software tests
CN102073587A (en) * 2010-12-27 2011-05-25 北京邮电大学 Static detection method for inaccessible route in program

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
BPEL4WS Unit Testing:Test case generation using a concurrent path analysis Approach;Jun Yan等;《17th International Symposium on Software Reliablity Engineering(ISSRE"06)》;20061130;第75-84页 *
单元覆盖测试中基于区间运算的路径选择;王思岚等;《清华大学学报(自然科学版) 》;20111031;第51卷(第S1期);第1402-1413页 *
基于Z路径覆盖的测试用例自动生成技术研究;夏辉等;《软件技术》;20060331(第3期);第92-94页 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302994B (en) * 2023-02-28 2023-10-10 浙江大学 Hierarchical matching method, device and equipment for program paths and storage medium

Also Published As

Publication number Publication date
CN103207833A (en) 2013-07-17

Similar Documents

Publication Publication Date Title
CN102708045B (en) Dynamic symbol executing method for relieving path explosion
CN103116540B (en) Dynamic symbolic execution method based on overall situation super block dominator graph
CN105653474B (en) A kind of allocating cache controller towards coarseness dynamic reconfigurable processor
CN104008053B (en) A kind of dynamic symbol executive path search method for vulnerability mining
CN113171039B (en) Cleaning robot cleaning control method and device, computer equipment and storage medium
CN109428785A (en) A kind of fault detection method and device
CN102546639A (en) Network-oriented penetration testing scheme automatic-generation method
CN104503901A (en) Guiding symbol execution method based on static path analysis
Chu et al. Precise cache timing analysis via symbolic execution
CN103207833B (en) The disposal route of loop code and system in software test
CN104063307B (en) A kind of method for testing software and system
CN109658249A (en) A kind of block chain performance optimization method
CN102420797A (en) Topology mapping method and system
CN105528296B (en) A kind of class cluster test method of object-oriented software
US10009151B2 (en) Packet storage method, information processing apparatus, and non-transitory computer-readable storage medium
Hartmanns Modest-a unified language for quantitative models
CN109919826A (en) A kind of diagram data compression method and figure computation accelerator for figure computation accelerator
JP2005216078A (en) Generation system for transaction profile for computer system performance measurement analysis, generation method therefor and program
CN104112228A (en) Supervision data acquisition system and method used for small loan company
Beldiceanu et al. New filtering for the cumulative constraint in the context of non-overlapping rectangles
CN101217428A (en) A retrospective paradigm route level network topology detecting method based on topology tree
CN105159835B (en) A kind of pitching pile location acquiring method based on global superblock dominating figure
Gnesi et al. On the Fly Verification of Network of Automata.
Evangelista et al. Hybrid on-the-fly LTL model checking with the sweep-line method
Han et al. A heuristic model-based test prioritization method for regression testing

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20160406