CN104035864A - Path generation method based on contradiction fragment mode - Google Patents

Path generation method based on contradiction fragment mode Download PDF

Info

Publication number
CN104035864A
CN104035864A CN201310693444.3A CN201310693444A CN104035864A CN 104035864 A CN104035864 A CN 104035864A CN 201310693444 A CN201310693444 A CN 201310693444A CN 104035864 A CN104035864 A CN 104035864A
Authority
CN
China
Prior art keywords
point
path
contradiction
follow
fragment
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.)
Granted
Application number
CN201310693444.3A
Other languages
Chinese (zh)
Other versions
CN104035864B (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 CN201310693444.3A priority Critical patent/CN104035864B/en
Publication of CN104035864A publication Critical patent/CN104035864A/en
Application granted granted Critical
Publication of CN104035864B publication Critical patent/CN104035864B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a path generation method based on a contradiction fragment mode. The method comprises the following steps: A, selecting a starting point from which the current path is generated from a control flow graph, and then carrying out step B; B, selecting a subsequent point, and then carrying out step C; C, after selecting the subsequent point successfully, carrying out step G, otherwise carrying out step D; D, carrying out step E after a previous point is found out by checking, otherwise carrying out step F; E, setting the previous point as the current point, and then carrying out step B; F, failing to generate the path because of returning to the starting point; G, successfully generating the path after checking that the subsequent point is the end point of the path, otherwise, carrying out step H; H, setting the subsequent point as the current point, and then carrying out step B. With the adoption of the method, that the current path fragment is the unreachable path can be quickly detected during generating the path, and thus the efficiency of judging the unreachable path is greatly raised.

Description

A kind of path generating method based on contradiction fragment schema
Technical field
The present invention relates to software testing technology, relate in particular to a kind of path generating method based on contradiction fragment schema.
Background technology
For the completeness to software test is weighed, industry has proposed multiple Test coverage criterion.No matter using any coverage criterion, is all to use to control flow graph generation pass to reach coverage requirement.Fact proved, according to the path of controlling flow graph generation, having is much unreachable path.
The reason that causes occurring a large amount of unreachable paths, mainly contains: 1) unreachable path must be that certain branch (branch of unreachable path process) due to certain predicate node cannot carry out; 2) the current branch of predicate node cannot to carry out must be the judgement that certain node before path has affected current predicate node, any one predicate on path is all inevitable relevant with path certain node before.
At present, path always generates from controlling flow graph, and control flow graph, cannot reflect the contact between predicate and its associated nodes.So, as long as exist predicate associated, by controlling the path of flow graph generation, just certainly exist unreachable path.
Make a general survey of the trend of software development, its complicacy is more and more higher, and predicate relation also becomes increasingly complex, so must cause a large amount of unreachable paths.But unreachable path is different from defect, defect is recoverable.In unreachable path, having fraction is through the path of unreachable point (dead code), should revise, and major part is the inevitable outcome of programmed logic, cannot revise.
To sum up, from the associated angle of predicate, starting with is to detect the most direct method in unreachable path.From the angle of problem space, be mainly divided into two classes: 1) total space detects: for all predicates, complete but efficiency is lower.2) heuristic detection: for the predicate that meets AD HOC, efficiency is high but have omission.Due to predicate One's name is legion, relation is complicated, " as simple logic how, select less associated predicate, but judge that more unreachable path is the key of raising the efficiency ".Heuristic detection, by pattern-recognition, is only selected less associated predicate; Again because pattern itself is that experience accumulation comes, thereby can judge more unreachable path.In a word, heuristic detection cost performance is high.
Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of path generating method based on contradiction fragment schema, to improve the judgement efficiency in unreachable path.
For achieving the above object, technical scheme of the present invention is achieved in that
A path generating method based on contradiction fragment schema, comprises the steps:
A, from control flow graph, select starting point that this path generates as current point, then perform step B;
B, select follow-up point, then perform step C;
If C successfully chooses follow-up point, perform step G; Otherwise execution step D;
D, check whether also have previous point, have and perform step E; Otherwise execution step F;
E, previous point is made as to current point, then performs step B;
F, owing to returning back to starting point, so generation pass failure;
G, checking whether follow-up point is the terminal in path, is successful generation pass; Otherwise execution step H;
H, a rear point are set to current point, then perform step B.
Wherein: in described step B, also need to access the follow-up point of current point.
Also comprise: according to different coverage criterions, the follow-up point of current point may be the follow-up point of controlling in flow graph, may be also forerunner's contact; In statement coverage criterion, take that to control certain point in the middle of flow graph be impact point, need to take and control flow graph starting point and find half paths as terminal; Take again control flow graph terminal as terminal finds another half paths; Finally be combined into a whole piece path; When looking for first half paths, selecting follow-up point is exactly to look for controlling forerunner's point in flow graph; When looking for later half paths, selecting follow-up point is exactly to look for controlling follow-up point in flow graph.
In described step D, when occurring there is no the situation of previous point, show that the starting point of this path generation cannot be reached home at all, the starting point that this path generates is a unreachable point.
The method that contradiction fragment is generated for path, mainly comprises the steps:
Whether A, judgement present node also have the follow-up point of non-selected mistake; If had, perform step B; Otherwise execution step D;
One of them of B, selection present node be the follow-up point of non-selected mistake also;
C, obtain the path segments that path starting point forms to the follow-up point of current selection, whether unreachable by contradiction fragment schema decision paths fragment; If be judged to be unreachablely, perform step A; Otherwise, judge and select follow-up putting successfully;
D, because all follow-up points of present node all cannot form reachable path, show that the path segments that path starting point forms to present node is unreachable path segments; Current path must point of rollback, and the previous point of current point of take is current point, continues to select follow-up point.
Wherein, steps A further comprises: when certain follow-up some P was selected, show that path segments that path starting point forms to P is judged to be by contradiction fragment schema unreachable, now need to reselect a follow-up point.
Step B comprises: need record current descendant node and be selected; After the rollback of path, while reselecting follow-up of current point, the follow-up some access flag arranging before need to emptying.
Step C comprises: first obtain the path segments that path starting point forms to present node, then with contradiction fragment schema, this path segments is carried out to unreachable judgement; If be judged to be unreachablely, need to select another follow-up point; Otherwise, show successfully to have selected the follow-up point of present node.
The path generating method of utilization based on contradiction fragment schema judged the method in unreachable path, comprising:
A, judgement path determine whether and comprise target predicate, if not, perform step e; If so, perform step b;
B, further whether judge before target predicate through the concentrated all points of contradiction point, if not, perform step e, if so, perform step c;
C, further judge that path segments, whether through removing the concentrated any point of point, if not, performs step e, otherwise, execution step d;
D, setting return results as unreachable, and finish this flow process;
E, setting return results as uncertain, and finish this flow process.
Path generating method based on contradiction fragment schema provided by the present invention, has the following advantages:
Whether, can in path fast detecting current path fragment be unreachable path, thereby greatly improve the efficiency of judging unreachable path if utilizing the method.The concept of the contradiction fragment schema that the inventive method proposes, analyzes classification to the reason that in program, unreachable path occurs, then carries out pattern-recognition and accurately detects.The inventive method can first be identified the contradiction fragment schema in unit under test, and is applied to path generation.Experiment showed, to utilize and of the present inventionly based on contradiction fragment schema, carry out the unreachable judgement in path, there is the higher efficiency of method of judging than interval arithmetic mode.Further, contradiction fragment schema is used for analyzing after path generation and path generation, in the situation that having impact point, the former efficiency is higher.
Accompanying drawing explanation
Fig. 1 is that the present invention is applied to the flow process that path generates and always schemes;
Fig. 2 is the flow process subgraph that the present invention is applied to select descendant node;
Fig. 3 the present invention is based on contradiction fragment schema path generating method for utilizing is judged the process flow diagram in unreachable path;
Fig. 4 is for appearing at target predicate point schematic diagram before in control flow graph;
Fig. 5 is contradiction fragment and contradiction predicate and the schematic diagram that is related to of removing point set;
Fig. 6 is that contradiction fragment schema is judged unreachable data flow diagram;
Fig. 7 is the inaccessible step schematic diagram of judgement after contradiction predicate generates for path;
Fig. 8 be IF-predicate consistent/complement mode definition schematic diagram;
Fig. 9 be IF-predicate consistent/schematic flow sheet of complement mode;
Fig. 9 A for the IF-predicate that obtained by process flow diagram described in Fig. 9 consistent/complement mode structure list process flow diagram;
Fig. 9 B is for processing the releasing point set schematic flow sheet between a plurality of contradiction predicates;
Fig. 9 C is for processing the releasing point set schematic flow sheet between current contradiction predicate
When Figure 10 is the predicate relation complementation of P and Q, M point is revised the predicate variable example of Q;
Figure 11 be contradiction fragment process current contradiction predicate cannot be for the example of the unreachable judgement in path;
Figure 12 is IF-predicate constant mode-definition schematic diagram;
Figure 13 is the schematic flow sheet of IF-predicate constant pattern;
Figure 13 A is the IF-predicate constant mode configuration list process flow diagram that process flow diagram obtains as shown in Figure 13;
Figure 14 is the P predicate variable assignment of the R Q example that the predicate variable assignment of R is another constant of naming a person for a particular job while being constant of naming a person for a particular job;
Figure 15 is the schematic diagram of one of contradiction fragment shown in Figure 14;
Figure 16 is two schematic diagram of contradiction fragment shown in Figure 14;
Figure 17 is WHILE-predicate constant mode-definition schematic diagram;
Figure 18 is the schematic flow sheet of WHILE-predicate constant pattern;
Figure 18 A is the process flow diagram of the WHILE-predicate constant mode configuration list that process flow diagram obtains as shown in Figure 18;
Exist Q to name a person for a particular job when Figure 19 is P point for WHILE statement in loop body example that the predicate variable assignment of P is constant;
Figure 20 is the schematic diagram of one of contradiction fragment shown in Figure 19;
Figure 21 is two schematic diagram of contradiction fragment shown in Figure 19;
Figure 22 be WHILE_IF predicate consistent/the definition schematic diagram of complement mode;
Figure 23 be WHILE_IF predicate consistent/process flow diagram of complement mode;
Figure 23 A for the WHILE_IF predicate that obtained by process flow diagram shown in Figure 23 consistent/complementary structure list process flow diagram;
Figure 24 is that P is the consistent example of predicate of WHILE statement Q P and Q while being the IF statement in WHILE loop body;
Figure 25 is one of contradiction fragment shown in Figure 24;
Figure 26 is two of contradiction fragment shown in Figure 24.
Embodiment
Below in conjunction with accompanying drawing and embodiments of the invention, the path generating method based on contradiction fragment schema of the present invention is described in further detail.
The implementation procedure of the inventive method comprises: the definition and the structure that 1, propose contradiction predicate, contradiction fragment and contradiction fragment schema; 2, contradiction fragment is generated for path.
Wherein, definition and the introduction about the construction thereof of described contradiction predicate, contradiction fragment and contradiction fragment schema are as follows.
1) definition and structure.
(1) target predicate, the entrance of judgement predicate contradiction.
(2) relating dot:
<1> and target predicate are quoted at least one identical variable.
Control the point that appears in flow graph before target predicate (have path, make target predicate appears at relating dot after).As shown in Figure 4.
(3) associated predicate, relating dot is predicate node.
(4) contradiction point: by the calculation to target predicate and relating dot thereof, those relating dots that draw contradiction are all contradiction points.For predicate, what conflict is branch, so contradiction point need to record branch corresponding to contradiction.
(5) contradiction point set, the set of contradiction point.
(6) contradiction predicate: target predicate+contradiction point set (they have formed contradiction).
(7) remove point:
<1> belongs to relating dot.
Belong to a certain group of contradiction predicate.
Appear in the middle of a certain group of contradiction predicate, cause judging whether former contradictory relation still exists.
(8) remove point set: remove the set of point.
(9) contradiction fragment: contradiction predicate+releasing point set.
Here, because contradiction predicate is all a part of controlling flow graph with removing point set, but need to be combined into an integral body, just can be used for judging unreachable path, so we express " several body synthesizes relatively independent integral body " this concept with this word of fragment.As shown in Figure 5.
(10) contradiction fragment schema: contradiction fragment is concrete predicate, the set that statement forms.By abstract syntax tree and control flow graph are analyzed, we can take out some structures, and these structures can produce contradiction fragment.This structure that comes from abstract syntax tree and control flow graph is called contradiction fragment schema.But not all structure all can occur in a large number in program, so just really have value through the really a large amount of structures that exist of checking.
A, contradiction fragment schema can effectively reduce quantity and the complexity of associated predicate.
B, the contradiction fragment schema through verifying, the possibility that detects unreachable path is larger.
(11) contradiction fragment schema is judged unreachable step: the following is contradiction fragment schema and judge inaccessible data flow diagram.As shown in Figure 6.
2) described contradiction predicate is generated for path.Generally, after our always path generation, then judge unreachable.As shown in Figure 7.
By to controlling stream graph traversal, select node, generation pass, then carries out unreachable judgement.
But, when if we choose Q point, discovery is from the path segments (starting point->...->P_T->...->Q_T) of starting point DaoQ_T branch, by contradiction fragment schema, can be judged to be unreachable, the subgraph shown in the square frame of below will no longer participate in routing, thereby can directly enter Q_F branch, carry out routing.Like this, reduce the point that participates in routing, improved path formation efficiency.
1, the present invention is based on the process flow diagram of the path generating method of contradiction fragment schema, as shown in Figure 1.
1.1, the object that path generates is exactly to generate reachable path according to coverage criterion, although coverage criterion is not quite similar, path generates and comprises following several basic step:
Steps A, from control flow graph, select starting point that this path generates as current point, then perform step B.
Step B, select follow-up point, then perform step C.
If step C successfully chooses follow-up point, enter step G; Otherwise execution step D.
Step D, check whether also have previous point, have and perform step E; Otherwise, execution step F.
Step e, previous point is made as to current point, then performs step B.
Step F, owing to returning back to starting point, so generation pass failure.
Step G, checking whether follow-up point is the terminal in path, is successful generation pass; Otherwise execution step H.
Step H, a rear point are set to current point, then perform step B.
1.2,, in described step B, need to access the follow-up point of current point.But according to different coverage criterions, the follow-up point of current point may be the follow-up point of controlling in flow graph, may be also forerunner's contact.In statement coverage criterion, take that to control certain point in the middle of flow graph be impact point, need to take and control flow graph starting point and find half paths as terminal, upwards look for; Take again control flow graph terminal as terminal finds another half paths, look for downwards.Finally be combined into a whole piece path.While looking for first half paths, the follow-up point that selects in this method is exactly to look for controlling forerunner's point in flow graph; While looking for later half paths, the follow-up point that selects in this method is exactly to look for controlling follow-up point in flow graph.
1.3, in described step D, there will be the situation that there is no previous point.This starting point that shows that this path generates cannot be reached home at all, and the starting point that this this path generates is a unreachable point (unreachable code).
2, contradiction fragment is for selecting the process flow diagram of descendant node, as shown in Figure 2.
2.1, contradiction fragment schema is applied in the generation of path, is applied in exactly the follow-up point of selecting present node, the method comprises the following steps:
Whether steps A, judgement present node have the follow-up point of selecting or not.If had, execution step B; Otherwise perform step D.
Here, certain follow-up some P was selected, and showed that path segments that path starting point forms to P is judged to be by contradiction fragment schema unreachable, so need to reselect a follow-up point.
One of them follow-up point of also not selecting of step B, selection present node;
Step C, obtain the path segments that path starting point forms to the follow-up point of current selection, whether unreachable by contradiction fragment schema decision paths fragment.If be judged to be unreachablely, perform step A; Otherwise select follow-up putting successfully.
Step D, because all follow-up points of present node all cannot form reachable path, show that the path segments that path starting point forms to present node is unreachable path segments.Current path must point of rollback (no longer comprising current point), and the previous point of current point of take is current point, continues to select follow-up point.
2.2,, in described step B, need record current descendant node and be selected.It should be noted that especially after the rollback of path, while reselecting follow-up of current point, because whole Segment changes, so the follow-up some access flag arranging before need to emptying.
2.3, in described step C, first obtain the path segments that path starting point forms to present node, then with contradiction fragment schema, this path segments is carried out to unreachable judgement.If be judged to be unreachablely, need to select another follow-up point; Otherwise, show successfully to have selected the follow-up point of present node.
3) optimisation strategy.
Consider extreme case: when program has N branch, if contradiction fragment could not reduce the node that participates in routing, the number of times of contradiction sheet segment call will reach the 2N order of magnitude.
We have following 2 kinds of optimisation strategy:
(1) reduce whole call number, first obtain the target predicate of contradictory fragment, only encounter target predicate and just call.
(2) reduce the number of modes relate to, pattern is pressed to statement classification of type, such as Select class, While class, Case class, for class and other; If Select node is only used Select class model to judge.
4) application scenarios.Application scenarios is divided into 2 classes: have impact point and there is no impact point.Wherein:
(1) there is impact point.
For certain target coverage element, find a paths.Such as, statement covers, branch covers.
Program for the branch node of a M statement node and N, statement covers need to find M paths, and branch's covering need to be found 2N paths.
Corresponding contradiction fragment judges that number of times mostly is 2 most n* M and 2 n* 2N.
So, have the situation of impact point to be suitable in routing.
(2) there is no impact point.
There is no concrete target coverage element, such as path covers, require to look for all paths.Program for the branch node of a M statement node and N, path covers need to find 2 npaths.
Corresponding contradiction fragment judges that number of times mostly is 2 most n* 2 n.And all paths ability 2 nbar, after path generates, then judges, only need call 2 ninferior.So, do not have the situation of impact point to be unsuitable in routing.
Below, in conjunction with specific embodiments of the invention, the processes such as path and unreachable judgement are elaborated:
Application the present invention carries out path generation and mainly contains two steps:
Steps A, pattern-recognition.
The decision method in step B, unreachable path, please refer to Fig. 3.
Wherein, steps A need identify the contradiction fragment schema that whether has appointment according to controlling flow graph.Provide the description of several patterns below.
Following pattern is all followed following principle: 1) abstract syntax tree is determined structure (arranged side by side or nested).2) between contradiction predicate, there is no skip instruction (GOTO, LABEL).3) algorithm of the releasing point set between processing contradiction predicate is public, so be only described in first pattern.
1) IF-predicate consistent/complement mode, as shown in Figure 8.
A, definition, with reference to figure 8.
Two IF statement: P arranged side by side and Q are brotherhoods on abstract syntax tree, and Q is the right brother of P.And, between P and Q, there is no skip instruction.Here, Q is target predicate, for guaranteeing that Q carries out after P, so between can not have skip instruction.
Two IF statement predicate relationship consistencies or complementation: P and Q predicate relationship consistency or complementation.
The point of not revising between contradiction predicate between predicate variable: P and the contradiction predicate of Q generation is not revised predicate variable.
B, its algorithm are as follows:
Input: AST.Output: contradiction set of segments.Be illustrated in figure 9 IF-predicate consistent/process flow diagram of complement mode.Obtain respectively IF-predicate consistent/complement mode structure list process flow diagram 9A, process the releasing point set process flow diagram 9B between a plurality of contradiction predicates, process the releasing point set process flow diagram 9C between current contradiction predicate.
C, specific embodiment are as follows:
file = fopen(fileName);
P: if(file==null)
{
M: file = fopen(backupFileName);
}
Q: if(file!=null)
{
file.write("success!");
}
The predicate relation complementation of P and Q, M point has been revised the predicate variable of Q.As shown in figure 10.
D, contradiction fragment, as shown in figure 11.Although Q_True and P_true also form contradiction predicate, but the in the situation that of P_true, removing some M must occur, so contradiction fragment <Q_True, { P_true}> is set to lose efficacy, cannot be for the unreachable judgement in path.
2) described IF-predicate constant pattern, it defines as shown in figure 12.
A, definition.
First IF predicate variable is initialized to the name a person for a particular job predicate variable of R of constant: P and is initialized as constant.
Between P and R, IF predicate variable is again initialized to another constant: Q and names a person for a particular job the predicate variable assignment of R for another constant.
The point of not revising between contradiction predicate between predicate variable: P, Q and the contradiction predicate of R formation is not revised predicate variable.
B, its algorithm are as follows.
Input: AST.
Output: contradiction set of segments.
Be IF-predicate constant model process figure as shown in figure 13, obtain the IF predicate constant mode configuration list process flow diagram shown in Figure 13 A.
C, specific embodiment are as follows:
P: int copy_patch_value = 0;
if (to_use >= 0)
{
M: copy_patch_value = 1;
}
Q: if (copy_patch_value) {
printf("copy file ...\n");
return 1;
}
The name a person for a particular job predicate variable assignment of R of P is constant, and the name a person for a particular job predicate variable assignment of R of Q is another constant.As shown in figure 14.
D, contradiction segment:
Wherein, first contradiction fragment, as shown in figure 15.Second contradiction fragment as shown in figure 16.
3) described WHILE-predicate constant pattern.
A, its definition, as shown in figure 17.
WHILE loop body exits according to predicate variable controlled circulation: P is WHILE statement.
In WHILE loop body, WHILE predicate variable is set to constant: the predicate variable of Q P is set to constant.
Between contradiction predicate, do not revise predicate variable: P and Q form between contradiction predicate point all do not revise predicate variable.
B, its algorithm are as follows.
Input: AST.Output: contradiction set of segments.Be the process flow diagram of WHILE-predicate constant pattern as shown in figure 18, obtain the list of WHILE-predicate constant mode configuration as shown in Figure 18 A.
Wherein, contradiction fragment 2=<P_False, Q_False}>, and the Q is here assignment statement, Q_False represents that Q does not occur.
C, specific embodiment, as shown in figure 19.
do {
enough_space = freeSpaceForFile();
if (!enough_space) {
Q: retry = 0;
}
P: } while (retry-- >0);
Wherein, P point is WHILE statement, and in loop body, having the name a person for a particular job predicate variable assignment of P of Q is constant.
D, contradiction fragment:
Wherein, contradiction fragment one, as shown in figure 20.Contradiction fragment two, as shown in figure 21.
4) described WHILE_IF-predicate consistent/complement mode.
A, its definition, as shown in figure 22.
Predicate relationship consistency/complementation of IF in the condition of WHILE and its loop body: P is WHILE statement, and Q is the IF statement in WHILE loop body, and the predicate logic of P and Q is consistent or complementary.
The point of not revising between contradiction predicate between predicate variable: Q and the contradiction predicate of P formation is not all revised predicate variable.
B, its algorithm are as follows.
Input: AST.
Output: contradiction set of segments.Be as shown in figure 23 WHILE-IF predicate consistent/complement mode process flow diagram, can obtain WHILE-IF predicate consistent/complementary structure list process flow diagram 23A.
C, specific embodiment, as shown in figure 24.
P: while ( stream->avail_out > 0 ) {
M: use(stream);
Q:I f ( stream->avail_out > 0 ) {
printf("need %d more bytes\n", ...);
}
}
Wherein, P is WHILE statement, and Q is the IF statement in WHILE loop body, and P is consistent with the predicate logic of Q.
D, contradiction fragment.
Wherein, first contradiction fragment as shown in figure 25.Second contradiction fragment as shown in figure 26.
Although <Q_True, { P_False}> and <Q_ False, { P_ True } > also forms contradiction predicate, but M point has been revised the predicate variable of Q, so these two contradiction predicates lost efficacy.
Fig. 3 the present invention is based on contradiction fragment schema path generating method for utilizing is judged the process flow diagram in unreachable path.As shown in Figure 3, the method comprises:
Step a, judgement path determine whether and comprise target predicate, if not, perform step e; If so, perform step b.
Step b, further whether judge before target predicate through the concentrated all points of contradiction point, if not, perform step e, if so, perform step c.
Step c, further judge that path segments, whether through removing the concentrated any point of point, if not, performs step e, otherwise, execution step d.
Steps d, setting return results as unreachable, and finish this flow process.
Step e, setting return results as uncertain, and finish this flow process.
The above, be only preferred embodiment of the present invention, is not intended to limit protection scope of the present invention.

Claims (9)

1. the path generating method based on contradiction fragment schema, is characterized in that, comprises the steps:
A, from control flow graph, select starting point that this path generates as current point, then perform step B;
B, select follow-up point, then perform step C;
If C successfully chooses follow-up point, perform step G; Otherwise execution step D;
D, check whether also have previous point, have and perform step E; Otherwise execution step F;
E, previous point is made as to current point, then performs step B;
F, owing to returning back to starting point, so generation pass failure;
G, checking whether follow-up point is the terminal in path, is successful generation pass; Otherwise execution step H;
H, a rear point are set to current point, then perform step B.
2. the path generating method based on contradiction fragment schema according to claim 1, is characterized in that, in described step B, also needs to access the follow-up point of current point.
3. the path generating method based on contradiction fragment schema according to claim 2, is characterized in that, also comprises: according to different coverage criterions, the follow-up point of current point may be the follow-up point of controlling in flow graph, may be also forerunner's contact; In statement coverage criterion, take that to control certain point in the middle of flow graph be impact point, need to take and control flow graph starting point and find half paths as terminal; Take again control flow graph terminal as terminal finds another half paths; Finally be combined into a whole piece path; When looking for first half paths, selecting follow-up point is exactly to look for controlling forerunner's point in flow graph; When looking for later half paths, selecting follow-up point is exactly to look for controlling follow-up point in flow graph.
4. the path generating method based on contradiction fragment schema according to claim 1, it is characterized in that, in described step D, when occurring there is no the situation of previous point, the starting point that shows this path generation cannot be reached home at all, and the starting point that this path generates is a unreachable point.
5. method contradiction fragment being generated for path, is characterized in that, mainly comprises the steps:
Whether A, judgement present node also have the follow-up point of non-selected mistake; If had, perform step B; Otherwise execution step D;
One of them of B, selection present node be the follow-up point of non-selected mistake also;
C, obtain the path segments that path starting point forms to the follow-up point of current selection, whether unreachable by contradiction fragment schema decision paths fragment; If be judged to be unreachablely, perform step A; Otherwise, judge and select follow-up putting successfully;
D, because all follow-up points of present node all cannot form reachable path, show that the path segments that path starting point forms to present node is unreachable path segments; Current path must point of rollback, and the previous point of current point of take is current point, continues to select follow-up point.
6. the method according to claim 5 contradiction fragment being generated for path, it is characterized in that, steps A further comprises: when certain follow-up some P was selected, show that path segments that path starting point forms to P is judged to be by contradiction fragment schema unreachable, now need to reselect a follow-up point.
7. the method according to claim 5 contradiction fragment being generated for path, is characterized in that, also comprises: need record current descendant node and be selected in step B; After the rollback of path, while reselecting follow-up of current point, the follow-up some access flag arranging before need to emptying.
8. the method according to claim 5 contradiction fragment being generated for path, is characterized in that, step C also comprises: first obtain the path segments that path starting point forms to present node, then with contradiction fragment schema, this path segments is carried out to unreachable judgement; If be judged to be unreachablely, need to select another follow-up point; Otherwise, show successfully to have selected the follow-up point of present node.
9. the path generating method of utilization based on contradiction fragment schema judged the method in unreachable path, it is characterized in that, comprising:
A, judgement path determine whether and comprise target predicate, if not, perform step e; If so, perform step b;
B, further whether judge before target predicate through the concentrated all points of contradiction point, if not, perform step e, if so, perform step c;
C, further judge that path segments, whether through removing the concentrated any point of point, if not, performs step e, otherwise, execution step d;
D, setting return results as unreachable, and finish this flow process;
E, setting return results as uncertain, and finish this flow process.
CN201310693444.3A 2013-12-17 2013-12-17 A kind of path generating method based on contradiction fragment schema Active CN104035864B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310693444.3A CN104035864B (en) 2013-12-17 2013-12-17 A kind of path generating method based on contradiction fragment schema

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310693444.3A CN104035864B (en) 2013-12-17 2013-12-17 A kind of path generating method based on contradiction fragment schema

Publications (2)

Publication Number Publication Date
CN104035864A true CN104035864A (en) 2014-09-10
CN104035864B CN104035864B (en) 2017-10-20

Family

ID=51466637

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310693444.3A Active CN104035864B (en) 2013-12-17 2013-12-17 A kind of path generating method based on contradiction fragment schema

Country Status (1)

Country Link
CN (1) CN104035864B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106155898A (en) * 2015-04-16 2016-11-23 北京搜狗科技发展有限公司 The method for obtaining path of a kind of flow chart and device
CN109495541A (en) * 2018-10-15 2019-03-19 上海交通大学 Based on the cloud service workflow schedule method across data center
CN109558964A (en) * 2017-09-27 2019-04-02 北京京东尚科信息技术有限公司 The method and apparatus for establishing business map

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6591404B1 (en) * 2001-07-27 2003-07-08 Hewlett-Packard Development Company, L.P. Method of automatically finding and fixing min-time violations
CN101216803A (en) * 2008-01-09 2008-07-09 四川大学 Test program control stream path set creation method based on base path
CN101286133A (en) * 2008-06-02 2008-10-15 北京邮电大学 Software test method applying interval operation
CN101436128A (en) * 2007-11-16 2009-05-20 北京邮电大学 Software test case automatic generating method and system
US8108826B2 (en) * 2004-09-29 2012-01-31 Avaya Inc. Code-coverage guided prioritized test generation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6591404B1 (en) * 2001-07-27 2003-07-08 Hewlett-Packard Development Company, L.P. Method of automatically finding and fixing min-time violations
US8108826B2 (en) * 2004-09-29 2012-01-31 Avaya Inc. Code-coverage guided prioritized test generation
CN101436128A (en) * 2007-11-16 2009-05-20 北京邮电大学 Software test case automatic generating method and system
CN101216803A (en) * 2008-01-09 2008-07-09 四川大学 Test program control stream path set creation method based on base path
CN101286133A (en) * 2008-06-02 2008-10-15 北京邮电大学 Software test method applying interval operation

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
崔宝江 等: "基于回溯与引导的关键代码区域覆盖的二进制程序测试技术研究", 《电子与信息学报》 *
王思岚: "单元测试中代码覆盖分析及路径选择技术的研究与应用", 《中国优秀硕士论文全文数据库 信息科技辑》 *
王防修 等: "基于回溯法的Dijkstra算法改进及仿真", 《计算机仿真》 *
邹永林 等: "《数据结构与算法教程》", 30 September 2004, 机械工业出版社 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106155898A (en) * 2015-04-16 2016-11-23 北京搜狗科技发展有限公司 The method for obtaining path of a kind of flow chart and device
CN109558964A (en) * 2017-09-27 2019-04-02 北京京东尚科信息技术有限公司 The method and apparatus for establishing business map
CN109558964B (en) * 2017-09-27 2021-07-30 北京京东尚科信息技术有限公司 Method and device for establishing business map
CN109495541A (en) * 2018-10-15 2019-03-19 上海交通大学 Based on the cloud service workflow schedule method across data center
CN109495541B (en) * 2018-10-15 2021-04-02 上海交通大学 Cross-data-center-based cloud service workflow scheduling method

Also Published As

Publication number Publication date
CN104035864B (en) 2017-10-20

Similar Documents

Publication Publication Date Title
CN108805561B (en) Method and system for executing intelligent contract capable of accessing multiple blockchains
Rubin et al. Combining related products into product lines
CN101339501B (en) WS-BPEL control loop detection method based on directed graph
Tiwari et al. Exploiting UML diagrams for test case generation: a review
CN109902024A (en) A kind of grey box testing method and device of Program path sensitivity
CN111008152B (en) Kernel module compatibility influence domain analysis method, system and medium based on function dependency graph
CN104035864A (en) Path generation method based on contradiction fragment mode
Naeem et al. Scalable mutation testing using predictive analysis of deep learning model
Nakagawa et al. A goal model elaboration for localizing changes in software evolution
Gonzalez-Hernandez New bounds for mixed covering arrays in t-way testing with uniform strength
US20160335175A1 (en) Determining valid inputs for an unknown binary program
CN113609489B (en) Distributed detection method for intelligent contract conflict in industrial block chain
Berlier et al. A constraint satisfaction algorithm for microcontroller selection and pin assignment
Renault et al. Parallel explicit model checking for generalized Büchi automata
Chen et al. Multi-view learning for parallelism discovery of sequential programs
CN112559343B (en) Test path generation method and related equipment
CN114282227B (en) Safety analysis and detection method for intelligent contract of Fabric block chain system
CN106528179B (en) A kind of static recognition methods of java class dependence
CN114791865A (en) Method, system and medium for detecting self-consistency of configuration items based on relational graph
CN109376075B (en) Processing method and device for generating optimal test coverage path of test object
Shchekotykhin et al. Parallel Model-Based Diagnosis
CN115034392B (en) Compiling method and device of Rete network and executing method and device of Rete algorithm
Molinero et al. Combining genetic algorithms and mutation testing to generate test sequences
de Santiago Júnior et al. Many-objective test case generation for graphical user interface applications via search-based and model-based testing
Renault Improving swarming using genetic algorithms

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant