CN101847122B - Method and system for testing software by using abnormal control flow set - Google Patents
Method and system for testing software by using abnormal control flow set Download PDFInfo
- Publication number
- CN101847122B CN101847122B CN2010101883761A CN201010188376A CN101847122B CN 101847122 B CN101847122 B CN 101847122B CN 2010101883761 A CN2010101883761 A CN 2010101883761A CN 201010188376 A CN201010188376 A CN 201010188376A CN 101847122 B CN101847122 B CN 101847122B
- Authority
- CN
- China
- Prior art keywords
- fault
- node
- control stream
- execution
- current
- 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
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a method and a system for testing software by using an abnormal control flow set. According to the method and the system provided by the invention for treating the software, the method comprises the following steps of: describing a run-time abnormal behavior through an abnormal mode state machine to support expansion of control flow and automatic detection of faults; expanding the traditional abnormal control flow through the run-time abnormal control flow, and adding a throwing run-time abnormal edge into the abnormal control flow to support the detection of a new fault; and generating the run-time abnormal control flow set through an iterative equation by combining the conventional static test technology to realize alternated iterative execution of control flow expansion and new fault detection. The method expands the traditional analysis path and fulfills the purpose of improving the fault report rate.
Description
Technical field
The present invention relates to software testing technology, relate in particular to a kind of method for testing software and system of using abnormal control flow set.
Background technology
Different with traditional method for testing software; Software static test towards the code defective at first will be summed up defective from the code aspect of software; It is abstracted into the corresponding defects pattern; Abstract semanteme to related content in the program carries out approximate treatment then, at last result of calculation is applied to defect mode and detects.Receive the favor of software industry just gradually towards the software static test technology of code defective, become the software testing technology of a kind of main flow of the U.S..Representative code defective static test instrument mainly contains the research project Metal of Stanford university at present; The java applet static test instrument FindBugs of Maryland university research and development; The java applet static test instrument PMD that increases income, the code defect detection tool K8 of U.S. Klocwork company research and development.The result shows through contrast test, because different to the degree of approximation of abstract semanteme, all there is wrong report in various degree in existing testing tool and fails to report situation.
For unforeseen problem in the minimizing program occurs, the software developer can handle abnormal conditions by a large amount of codes of special establishment, even in some software systems, has the code above 2/3rds to be used for abnormality processing.Because the introducing of exception handling, it is more complicated that the control rheology of program is got, so work has brought bigger challenge to static test.Though present many experts and scholars have carried out deep research at this point; But to the expansion of control stream, the new run-time exception that on the control stream of expansion, causes, and both replace iterative relation the influence of static test are not but all related to for run-time exception.All all do not consider this problem towards the software static test technology and the instrument of code defective at present, and the path analysis that brings thus is insufficient to be a major reason that causes the part defective to be failed to report.
Summary of the invention
The technical matters that the present invention will solve provides a kind of method for testing software and system that uses run-time exception control adfluxion; Can handle the alternately iterative relation between the expansion of run-time exception Detection & Controling stream, solve thus in static test because the insufficient problem of path analysis that run-time exception causes.
In order to solve the problems of the technologies described above, the invention provides a kind of method for testing software of using abnormal control flow set, comprising:
The input information of steps A, application present analysis unit, initialization control adfluxion and fault collection;
Step B, the pairing initial control stream of traversal analytic unit are promptly controlled first element in the adfluxion, and all nodes that call subfunction are wherein handled, and extract the run-time exception information that subfunction possibly dished out, first element of expansion fault collection;
Step C, on first element of control adfluxion, use the static test detection failure, and testing result made an addition among first element of fault collection;
Whether comprise detected failure collection in the currentElement of step D, failure judgement collection, if this set, representes that iterative detection finishes execution in step H for empty; If not, execution in step E then;
Step e, with the run-time exception information that is comprised in the prior fault of fault collection, on the node that corresponds to current control stream according to dish out position and Exception Type and the limit, obtain the subsequent control that current control flows and flow;
On step F, the subsequent control stream that in said step e, obtains, the application and trouble detection technique is not present in fault that fault concentrates and adds among the consequent malfunction detected, obtains the next element of fault collection;
The current information of step G, adjustment control adfluxion and fault collection points to, and the subsequent control stream that obtains in the said step e is adjusted into current control stream, the consequent malfunction that obtains in the said step F is adjusted into works as prior fault, returns step D;
Step H, after the iteration processing finishes, analyze current control stream, extract the run-time exception that it can be dished out, and be retained in the designated data structure.
Further, said steps A specifically comprises:
A1, initialization set member sequence number, it is 0 that its current value is set;
First element of A2, initialization fault collection, its currentElement of set of applications member's sequence number is set to sky;
The currentElement that first element of A3, initialization control adfluxion, set of applications member's sequence number controls adfluxion is set to the initial control of present analysis unit and flows.
Further, said step B specifically comprises:
B1, judge whether the node in the current control stream is its last node, then carries out said step C in this way, otherwise execution in step B2;
B2, judge in the present node of current control stream whether have statement to function call, if exist then execution in step B3, otherwise execution in step B5;
B3, according to the function abstracted information discriminant function run-time exception of whether can dishing out that in node, is called, execution in step B4 in this way, otherwise execution in step B5;
B4, the ordered pair that node and Exception Type are formed join and work as prior fault, then execution in step B5;
B5, with the next node replacement present node of node in the current control stream, return step B1.
Further, said step C specifically comprises:
The method of C1, application finite state machine is described fault; Node is wherein represented contingent state; Possible switch condition between Bian representative state for being created by analytic unit and concrete variable correlation behavior machine instance, is chosen one as current state machine instance from all state machine instance;
C2, on the diverse location of control stream; Be that the variable in the current state machine instance calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine instance, in state conversion process if break down state; Execution in step C3 then, otherwise execution in step C4;
C3, the run-time exception composition ordered pair that will go out the position of present condition and dish out join ordered pair in prior fault;
C4, judge in the state machine instance set whether have untreated instance, and if existed with next instance as current instance, return step C2, otherwise carry out said step D.
Further, said step e specifically comprises:
E1, choose the current ordered pair in the fault, on control stream, match the respective nodes of ordered pair, judge whether this node is in the exception catching structure, execution in step E2 in this way, otherwise execution in step E4;
Whether E2, the judgement abnormality processing structure corresponding with the exception catching structure can handle the pairing Exception Type of run-time exception in the ordered pair; Then on current control stream, add the limit from node to corresponding abnormality processing structure node, an execution in step E5 then in this way; As denying execution in step E3;
Whether E3, judgement also exist other exception catching structure except that current exception catching structure, then outer field in this way exception catching structure is set to current structure, returns step e 2, otherwise execution in step E5;
E4, on current control stream, add one from node to the limit of withdrawing from node unusually, as the present analysis unit dished out unusual;
E5, judge in prior fault whether have the ordered pair of not handling,, return step e 1 if exist then it is labeled as current ordered pair; Otherwise obtain the subsequent control stream of current control stream, then execution in step F.
Further, said step F specifically comprises:
F1, initialization fault are concentrated the consequent malfunction when prior fault, and consequent malfunction is set to sky;
F2, be to be created and concrete variable correlation behavior machine instance, from all state machine instance, choose one as current state machine instance by analytic unit;
F3, on the diverse location of subsequent control stream; Be that the variable in the current state machine instance calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine instance, in state conversion process if break down state; Execution in step F4 then, otherwise execution in step F5;
F4, the run-time exception that will occur using wrong position and this mistake to dish out are formed ordered pair, check whether this ordered pair is present in the failure collection, if do not exist, then this ordered pair are joined in the said consequent malfunction in back;
F5, judge in the state machine instance set whether have untreated instance,, return step F 3 if exist then choose a untreated instance as current instance, otherwise execution in step G.
Further, said step H specifically comprises:
H1, choose and point to a limit withdrawing from node in the current control stream unusually, with it as working as the pre-treatment limit;
H2, will work as the pairing Exception Type in front and join among the abstracted information of present analysis unit;
H3, judge to point to the limit of withdrawing from node in the current control stream unusually and whether all finish dealing with, execution in step I then in this way, otherwise select to withdraw from unusually in the current control stream limit of node, it as working as the pre-treatment limit, is returned step H2.
The present invention also provides a kind of software testing system of using abnormal control flow set, comprising:
Initialization module is used to use the input information of present analysis unit, initialization control adfluxion and fault collection;
The plain expansion module of fault element of set; Be used to travel through the pairing initial control stream of analytic unit, promptly control first element in the adfluxion, all nodes that call subfunction are wherein handled; Extract the run-time exception information that subfunction possibly dished out, first element of expansion fault collection;
Fault detection module is used for first element in the control adfluxion, uses the static test detection failure, and testing result is made an addition among first element of fault collection;
Judge module, whether the currentElement that is used for the failure judgement collection comprises detected failure collection, if this set, representes that iterative detection finishes for empty, the result that the output iterative detection finishes; If not, the unclosed result of output iterative detection;
Subsequent control stream acquisition module; Be used in said judge module output iterative detection unclosed as a result the time; The run-time exception information that in prior fault, is comprised with the fault collection; Correspond to according to dish out position and Exception Type on the node and limit of current control stream, obtain the subsequent control stream of current control stream;
Subsequent control stream fault detection module is used at subsequent control stream, and the application and trouble detection technique is not present in fault that fault concentrates and adds among the consequent malfunction detected, obtains the next element of fault collection;
The circulation module; Be used to adjust the current information sensing of control adfluxion and fault collection; The subsequent control stream that said subsequent control stream acquisition module is obtained is adjusted into current control stream; The consequent malfunction that said subsequent control stream fault detection module is obtained is adjusted into works as prior fault, and exports to said judge module;
The run-time exception extraction module, be used for said judge module output iterative detection finish as a result the time, analyze current control stream, extract the run-time exception that it can be dished out, and be retained in the designated data structure.
The run-time exception behavior is described through the abnormal patterns state machine by method for testing software provided by the present invention and system, can support the expansion of control stream and the automatic detection of fault; Through the traditional abnormal control flow of run-time exception control stream expansion, the limit of the run-time exception of dishing out is added wherein, to support detection to new fault; In conjunction with existing static test technology, abnormal control flow set during through the iterative equation generating run is carried out with the alternately iteration that realizes expansion of control stream and new fault detect.Through above method expansion traditional analysis path, reach the purpose that improves the Trouble Report rate.
Description of drawings
Fig. 1 is the schematic flow sheet of the method for testing software of using abnormal control flow set of the present invention;
Fig. 2 is used to describe the state machine that null pointer is quoted abnormal patterns for the present invention;
Fig. 3 is used to describe the state machine of other 3 kinds of abnormal patterns for the present invention;
Fig. 4 is the abnormal control flow set of his-and-hers watches 1 function f l of the present invention;
Fig. 5 is the abnormal control flow set of his-and-hers watches 1 function f of the present invention;
Fig. 6 is the synoptic diagram of experiment porch of the present invention;
Fig. 7 is the formation block scheme of the software testing system of using abnormal control flow set of the present invention.
Embodiment
Below in conjunction with accompanying drawing and specific embodiment the present invention is described further so that those skilled in the art can better understand the present invention and implementing, but the embodiment that lifts not conduct to qualification of the present invention.
Static test technology towards the code defective can be described as problem D={P theoretically, M, and A} finds the solution, and P represents tested program here; M is the code defect mode set corresponding with P; A is the algorithm that obtains the abstract semanteme of related content among the P, is used for confirming whether P exists defect mode M.Algorithm A is described as A={S among the D, and ρ (L, X), σ (F) }, wherein S is the path among the program P; ρ is for calculate the value information of correlated variables X approx, and L is the executing location of P, and X is the variable that P implements the L place; σ is the abstract context of function, representes approx calling the abstract of function F.Because the introducing of run-time exception possibly expand to S with the control flow path S that influenced by it
1, and at S
1On possibly find new run-time exception again, through so alternately obtaining [S after the iterative process
1..., S
n], S wherein
iAt S
I-1The basis on produce, and
The problem of like this algorithm A being found the solution can be converted into A={S ∪ [S
1..., S
n], ρ (L, X), σ (F) }.
In the static test process,, promptly in algorithm A, omitted analysis path [S if ignored processing to run-time exception
1..., S
n], then have
The situation that defective is failed to report appears thus:
Wherein D (M | x) expression is because the value x of variable X causes fault M; The value x of
expression variable X can not cause fault M, and False Negative (X) representes failing to report variable X.This shows that because the existence of run-time exception, it can produce alternately iterative relation in program operation process and between control stream, this specific character can influence static test process and result.
Use run-time exception in order to be implemented in the software static test process; The present invention proposes a kind of static test of using run-time exception; Realization fault detect and control stream are expanded alternately iteration execution: fault detect causes controlling stream and goes up the limit that run-time exception is represented in interpolation; The limit of extra interpolation causes detecting more fault again, and this process repeats to control and flows till the no longer expansion.Use the abnormal patterns state machine and describe the characteristic of run-time exception, find run-time exception through its malfunction.Use the running environment of run-time exception control stream, on tradition control stream, increase the limit of handling run-time exception as fault detect.In conjunction with existing static test technology, abnormal control flow set during through the iterative equation generating run is to realize the process that iterates of expansion of control stream and new fault detect.Below respectively the alternately iterative relation between run-time exception description, run-time exception testing environment, the expansion of run-time exception Detection & Controling stream is elaborated.
1. run-time exception is described
Problem D={P, M, the defect mode M among the A} is the basis of finding the solution D, is the problem that at first need solve among how run-time exception being explained M, the present invention adopts the abnormal patterns state machine that it is unified to be described below:
The abnormal patterns state machine is defined as a tlv triple EM=< N, T, C >, corresponding one type of each abnormal patterns state machine unusual.N is a state set, comprise in the abnormal patterns the state that might reach.T={<n
i, n
j>| n
i, n
j∈ N} is the state exchange set, and state machine maybe be from state n
iBe transformed into state n
jC is a state transition condition, T:N * C → N.
N
StartBe the unique inlet of state machine, get into this state after state machine is created automatically; N
EndBe the unique outlet of state machine, get into this state behind the state machine end of run automatically; N
Fault={ Exception, Error} are the unique malfunctions of state machine, then are not labeled as Error unusually as not dishing out when prior fault, otherwise are labeled as Exception.N={N
Start, N
Fault, N
End∪ N
Other, N
OtherExpression other state except that above three state, it is different with the difference of defect type.
When on the abnormal patterns state machine, carrying out state exchange, need to combine the abstract semanteme and the state transition condition C of concrete variable X to accomplish, the abnormal patterns state machine EM of corresponding variable X is called the abnormal patterns state machine instance EM (X) of X.
Virtual condition on the EM (X) converts n into
i={ n
j* C | { S, ρ (L, X), σ (F) }, in conjunction with concrete variable X and in the position the abstract semanteme { S, ρ (L, X), σ (F) } at L place, can be through state transition condition C with the current state n of EM (X)
jConvert state n into
i
Suppose program P comprises the run-time exception pattern { EM that the n kind is set
1, EM
2..., EM
n, influenced by the correlated variables X among the P, every kind of abnormal patterns EM
iMaximum corresponding m kind abnormal patterns state machine instance { EM
i(X
1), EM
i(X
2) ..., EM
i(X
m), all abnormal patterns state machine instance that then program P is corresponding constitute the abnormal patterns state machine instance matrix of P, and note is done:
The expression variable X
jWith abnormal patterns EM
iIrrelevant, need not be X
jCreate such state machine instance.For (EM
Ij)
N * mIn all non-NULL state machine instance
Expression need be the variable X among the program P
jCreate the abnormal patterns state machine instance.In the state machine instance of all non-NULLs, identical part is three state { N
Start, N
Fault, N
End, as for other N state
OtherWith state transition condition C with EM
iDifference and different.Malfunction N
Fault: Error only provides error message, N
Fault: Exception also will be used to control the expansion of stream in the back except that error message is provided.
Among Fig. 2 a state machine description of quoting abnormal patterns about null pointer, the run-time exception because this type of fault can be dished out, so malfunction is labeled as Exception.Except the total N state of each abnormal patterns state machine
Start, N
EndAnd N
FaultOutward, this state machine has the non-NULL N state
NotWith possibility dummy status N
MayState transition condition C comprise in have: C
1(judging that pointer maybe be empty), C
2(judging the pointer non-NULL), C
3(reference pointer content), C
4(exceeding the pointer action scope), C
5(conversion automatically), C
6(other).State exchange set comprise in have: T
1: N
Start* C
6→ N
Start, T
2: N
Start* C
1→ N
May, T
3: N
Start* C
2→ N
Not, T
4: N
May* C
6→ N
May, T
5: N
May* C
3→ N
Fault, T
6: N
May* C
4→ N
End, T
7: N
May* C
2→ N
Not, T
8: N
Not* C
6→ N
Not, T
9: N
Not* C
4→ N
End, T
10: N
Not* C
1→ N
May, T
11: N
Error* C
5→ N
End
Be that a state machine about buffer zone overflow exception pattern is described among Fig. 3 (a), the run-time exception because this type of fault can be dished out, so malfunction is labeled as Exception.Except the total N state of each abnormal patterns state machine
Start, N
EndAnd N
FaultOutward, this state machine has binding state N
BoundState transition condition C comprise in have: C
1(for buffer zone is bound the space), C
2(usage space surpasses the binding space), C
3(exceeding the buffer zone action scope), C
4(conversion automatically), C
5(other).State exchange set comprise in have: T
1: N
Start* C
1→ N
Bound, T
2: N
Start* C
5→ N
Start, T
3: N
Bound* C
5→ N
Bound, T
4: N
Bound* C
2→ N
Fault, T
5: N
Bound* C
3→ N
End, T
6: N
Fault *C
4→ N
End
Among Fig. 3 (b) a state machine description of quoting abnormal patterns about wrong indicator, the run-time exception because this type of fault can be dished out, so malfunction is labeled as Exception.Except the total N state of each abnormal patterns state machine
Start, N
EndAnd N
FaultOutward, this state machine has distribution state N
AllocWith release conditions N
FreeState transition condition C comprise in have: C
1(reference pointer), C
2(allocation space), C
3(Free up Memory), C
4(exceeding the pointer action scope), C
5(conversion automatically), C
6(other).State exchange set comprise in have: T
1: N
Start* C
6→ N
Start, T
2: N
Start* C
1→ N
Fault, T
3: N
Start* C
2→ N
Alloc, T
4: N
Alloc* C
4→ N
Free, T
5: N
Alloc* C
4→ N
End, T
6: N
Alloc* C
6→ N
Alloc, T
7: N
Free* C
2→ N
Alloc, T
8: N
Free* C
1→ N
Fault, T
9: N
Free* C
6→ N
Free, T
10: N
Free* C
4→ N
End, T
11: N
Fault* C
5→ N
End
Be that a state machine about the memory leak faults pattern is described among Fig. 3 (c), the run-time exception because this type of fault can not dished out, so malfunction is labeled as Error.Except the total N state of each abnormal patterns state machine
Start, N
EndAnd N
FaultOutward, this state machine has distribution state N
AllocWith release conditions N
FreeState transition condition C comprise in have: C
1(storage allocation), C
2(releasing memory), C
3(exceeding the pointer action scope), C
4(conversion automatically), C
5(other).State exchange set comprise in have: T
1: N
Start* C
5→ N
Start, T
2: N
Start* C
1→ N
Alloc, T
3: N
Alloc* C
2→ N
Free, T
4: N
Alloc* C
3→ N
Fault, T
5: N
Alloc* C
5→ N
Alloc, T
6: N
Free* C
1→ N
Alloc, T
7: N
Free* C
3→ N
End, T
8: N
Free* C
5→ N
Free, T
9: N
Fault* C
4→ N
End
Table 1: tested program fragment
1:void?fl(char*p){
2: char*q;
3: if(!p){print(″null″);}
4: try{
5: *p=′a′;//NullPointerDereference
6: if(!q=malloc[p.len+1])throw?E
1;
7: strcpy(p,q);//BufferOverflow
8: }
9: catch(NullPointerException?e){
10: }
11: free(q);//WrongPointerDereference
12: }
13: void?f(int?len){
14: try{
15: char*p=malloc(len);
16: fl(p);
17: free(p);
18: }
19: catch(Excep?E
1){free(p);}
20: catch(Excep?E
wpd){
21: char*q=malloc(len);
22: strcpy(q,p);
23: free(q);}
24:}
Suppose that the run-time exception state machine that the function f 1 in the his-and-hers watches 1 is set has three types: EM
Npd(null pointer is quoted unusually), EM
Bo(buffer zone overflow exception), EM
Wpd(the mistake reference pointer is unusual), then with f1 in types of variables relevant, need be respectively for the state machine instance that every type of defective is created: EM
Npd(p), EM
Npd(q), EM
Bo(p), EM
Wpd(p), EM
Wpd(q), they constitute the state machine instance matrix of f1 jointly:
After the above method that run-time exception has been described has been arranged, can in the program with specific exceptions pattern EM
iRelevant variable X
jCreate abnormal patterns state machine instance EM
i(X
j), in conjunction with variable X
jAbstract semanteme, applied transformation condition EM
i.C carry out state exchange.When the N state that breaks down
Fault: behind the Exception, record trouble is also expanded control stream accordingly.
2. run-time exception control is flowed
Existing method is when construction procedures control stream; Comprised the abnormality processing correlative; Like the try statement of confirming the exception catching scope, confirm the catch statement of catching exception type, and can confirm that the throw statement of unusual throw point can confirm unusual process with dishing out.In addition, in order to describe unusual influence to program control flow fully, the content relevant with run-time exception also should join wherein, like the statement of the run-time exception of can dishing out and the function of run-time exception or the like of can dishing out.The present invention is following to the definition of run-time exception control stream:
Run-time exception control stream is to describe the program digraph that comprises that run-time exception is handled, and it has increased the point set and the Bian Ji that describe the run-time exception Processing Structure on the basis of the former control stream of program, be expressed as tuple REC=<n, E, N
Ex, N
Er, N
Ef, E
Re>Wherein N is a set of node, and each program statement is a node in the corresponding diagram all.N
ExBe the node explicit and that implicit expression is unusual of can dishing out, N
ErBe the node that comprises the run-time exception statement of can dishing out, N
EfIt is the node that comprises the run-time exception function of to dish out.Limit collection E={<n
i, n
j>| n
i, n
j∈ N}, expression node n
iAfter corresponding statement is carried out, XM n immediately
jCorresponding statement.E
ReBe N
ErAnd N
EfThe output limit of node is used to handle the run-time exception of being dished out.
N
Ex, static test can confirm N before beginning
ErAnd N
EfNeed in the static test process, can confirm.To the node N that can dish out unusual
Ex, N
ErAnd N
Ef, two types of limits its outputs of correspondence are arranged, be labeled as E
NoThe limit correspondence be not triggered unusually, be labeled as { E
Re| E
Er={ E
Npd, E
Bo, E
Wpd... } and the corresponding E in limit
ReBeing triggered unusually of type, E
ReIn unusual type and quantity relevant with concrete syntax.Captive run-time exception passes through E
ReBe connected to corresponding catch node, run-time exception at large passes through E
ReWhat be connected to control stream withdraws from node unusually.N
EntryBe the unique inlet of control stream, N
ExitIt is the unique outlet of control stream.N={N
Entry, N
ExitN
Ex, N
Er, N
Ef∪ N
Other, N
OtherExpression other node except that above 5 kinds of nodes, E={E
No, E
Re∪ E
Other, E
OtherExpression other limit except that above 2 kinds of limits.
Based on above description, run-time exception control stream is summed up as follows with the difference of tradition control stream:
Unusual during 1, for the ease of positioning trip, each statement is as a control stream node, rather than a statement block;
2, corresponding each try statement has a N
TryNode, corresponding each catch statement has a N
CatchNode;
3, each unusual function of can dishing out all has a N
Excp_exitNode obtains unusual descendant node as at large in all functions.In order to guarantee to control the uniqueness of stream middle outlet, each function increases a N
Norm_exitNode, it and N
Excp_exitDescendant node be N
Exit
4, the node N of corresponding each run-time exception of can dishing out
ErOr N
Ef, through limit E
ReBe connected to the N corresponding with its type
CatchNode or the N corresponding not with it
Excp_exitNode; Through limit E
NoLink N
EfOr N
ErThe non-abnormality processing node of first of node back.
3. abnormal control flow set
After being dished out, run-time exception can extender control flow; And new run-time exception possibly appear on the control stream of expansion; The present invention with run-time exception to the expansion of control stream and on the control stream of expansion, find these two of new run-time exceptions alternately the processes of iteration represent through abnormal control flow set, specifically describe as follows:
Relation between the control of run-time exception behavior of abnormal control flow set representations and the expansion stream comprises run-time exception to the expansion of control stream with on the control stream of expansion, find new run-time exception, and process of iteration like this; Be expressed as a four-tuple < RS; ES, G, T >.RS is a control stream ordered set { REC
0, REC
1..., REC
n, expression receives the influence of run-time exception, and control stream is from REC
0Beginning progressively expands to REC
nProcess; ES is a set corresponding with RS, constitutes ES={{ES by some order subsets
0| REC
0, { ES
1| REC
1..., { ES
n| REC
n, be illustrated in corresponding control stream and go up findable new run-time exception set, ordered pair<n, E>∈ ES
i, N, E ∈ REC
iRepresent newfound run-time exception; G:REC
i* D (P, M, A) → ES
iBe from REC
iLast generation ES
iRule, T:REC
i* ES
i→ REC
I+1Be through ES
iWith REC
iBe converted into REC
I+1Rule.
Under Regulation G,
<img file="BSA00000143094600121.GIF" he="57" img-content="drawing" img-format="GIF" inline="yes" orientation="portrait" wi="700" />Comprise two parts content, first control stream REC<sub >0</sub>In all comprise the run-time exception that the node of function call is dished out, comprise the run-time exception of re type in the abstract context of re ∈ σ (F) expression F,<n, E<sub >Re</sub>>Be expressed as at control stream REC<sub >0</sub>Go up the ordered pair corresponding with re; It two is not comprise node N<sub >Er</sub>And N<sub >Ef</sub>Traditional abnormal control flow REC<sub >0</sub>Upward (that A) asks effectively separates for P, M to problem D.M corresponding states machine instance matrix (EM among the D<sub >Ij</sub>)<sub >N * m</sub>, at computation process (EM<sub >Ij</sub>)<sub >N * m</sub>Among * the A,
Work as variable X
jWith abnormal patterns EM
iWhen irrelevant
In addition, when j ≠ k
Expression is to non-NULL instance EM
i(X
j) the application algorithm
Different executing location L on the S of path are to X
jAbstract semanteme calculate, to realize to EM
i(X
j) state exchange.When obtaining EM at the L place
i(X
j) malfunction N
Fault: during Exception, expression is tried to achieve and is separated EM
i(X
j) A (X
j) →<l, EM
i>, wherein L can correspond to REC
0In the node N that dishes out unusually
Er, EM
iCan correspond to REC
0In an abnormality processing limit E
Re
Under Regulation G, E
k=D (P, M, A) | REC
kBe at run-time exception control stream REC
kUpward (that A) asks newly effectively separates for P, M to problem D.M is state machine instance matrix (EM
Ij)
N * m, to the arbitrary instance EM among the M
i(X
j) pairing variable X
j, algorithm
In the path
On different executing location L to X
jIts abstract semanteme calculate, and try to achieve EM
i(X
j) A (X
j) →<l, EM
i>Through to (EM
Ij)
N * mIn all example calculation, last controlled stream REC
kLast the new run-time exception that might dish out
Under rule T,<img file="BSA00000143094600139.GIF" he="153" img-content="drawing" img-format="GIF" inline="yes" orientation="portrait" wi="700" />Use ES<sub >i</sub>Middle information recorded<n<sub >Er</sub>, E<sub >Re</sub>>| N<sub >Er</sub>, E<sub >Re</sub>∈ REC<sub >i</sub>, at control stream REC<sub >i</sub>The dish out node N of run-time exception of marked<sub >Er</sub>, and add corresponding abnormality processing limit E<sub >Re</sub>, at last it is expanded to REC<sub >I+1</sub>, SUM (ES<sub >i</sub>) be ES<sub >i</sub>Middle number of members.
Through to the alternately iteration of unusual create-rule G, can realize the generation of abnormal control flow set RS with control stream translation rule T.Iterative equation is represented to suppose REC as follows
0Known, iterative process begins from t=1, up to
Finish.
In order to analyze the character of abnormal control flow set RS, can it be mapped to function R S={y|y=f (x) }, for any 2 x in f (x) the field of definition x ∈ [0, m]
1And x
2, perseverance has
Therefore function f (x) is dull increasing on interval x ∈ [0, m].In addition, because type, statement and the function of the run-time exception of can dishing out among the program P all are limited, therefore total iterations also is limited, and promptly the field of definition of f (x) is a bounded.For the function f (x) of dull bounded, it must have the limit, and the abnormal control flow set RS that promptly f (x) is corresponding has the limit.
Based on above description, the difference between run-time exception control stream and traditional abnormal control flow is following:
1, in traditional abnormal control flow node with unusual relevant the node explicit unusual and unusual node N of implicit expression that only dishes out
Ex, and remove N in the run-time exception control stream
ExOutside the node, also comprise the N of the run-time exception of dishing out
ErAnd N
EfNode, and the limit E that handles run-time exception
Re
2, at traditional abnormal control flow REC
0On when carrying out static test, can only report the run-time exception information E of current discovery
0, and consequent fault; And the run-time exception of the fault detection method of using iterative control stream is from traditional abnormal control flow REC
0Beginning expands to { REC through iterative equation with it
0, REC
1..., REC
n, can find more run-time exception { E
1..., E
n, and other failure message that brings thus.
With usability of program fragments fl in the table 1 is example, and its corresponding run-time exception control adfluxion is as shown in Figure 4.Wherein Fig. 4 (a) is traditional abnormal control flow REC
0, limit E
1Be node n
9In (6 row) condition be true time dish out unusual.If do not consider the influence of run-time exception, analysis node n all sidedly in test process then
8(9 row) and node n
14It is unusual that (12 row) catches.And the fault detection method of using iterative, Regulation G is at REC
0Unusual and the buffer zone overflow exception ES of last discovery null pointer
0=<n
7, E
Npd>,<n
11, E
Bo>After, rule T is with REC
0Convert the REC of Fig. 4 (b) into
1, limit E wherein
NpdBe node n
7In (5 row) because variable p is empty dish out unusual, limit E
BoBe node n
11In (7 row) because buffer zone overflows dish out unusual; When variable p was sky, Regulation G can be at REC
1The last discovery used unusual ES to the pointer q of no initializtion
1=<n
12, E
Wpd>, rule T can be with REC
1Convert the REC of Fig. 4 (c) into
2 iteration stops at last.
Can find out from last example,, make tested object from traditional abnormal control flow REC owing to used the fault detection method of iteration
0Expand to REC
1And REC
2, comprised node n
8With node n
14Catch behind the run-time exception the influence of test result, these contents are that other method of testing based on traditional abnormal control flow is not available.
The related content of run-time exception and run-time exception control stream has been introduced in the front, and generates abnormal control flow set through iterative equation, realizes the expansion to the traditional static method of testing.Provide the generating algorithm of abnormal control flow set below, as shown in table 2.The program that the is input as P of algorithm is corresponding does not comprise node N
ErAnd N
EfTraditional abnormal control flow CFG (P), and abnormal patterns state machine instance matrix (EM
Ij)
N * m, be output as abnormal control flow set RS and corresponding failure message collection ES.
Table 2 abnormal control flow set generating algorithm is described
1:begin
3: REC[I]=CFG(P);
4: for?each?N?in?REC[I]?do
5: if?F∈N^re∈σ(F)then?ES[I]=ES[I]∪<N,re>;
6: end?for
7: for?each?EM
i(X
j)in(EM
ij)
n×m?do
8: ES[I]=ES[I]+{EM
i(X
j)A(X
j)|REC[I]};
9: end?for
12: for?each<N,E>in?ES[I]?do
13: REC[I+l]=REC[I]+<N,E>;
14: end?for
15: for?each?EM
i(X
j)in(EM
ij)
n×m?do
17: end?for
18: I++;
19: end while
20: for?each?E
re?in?REC[I].N
excp_exit?do
21: add(σ(P),E
re);
22: end?for
23:end
Algorithm the 4th~6 row is at first added up the abstract context of the function F that is called among the P, checks its run-time exception of whether dishing out, if exist, then these unusual relevant informations is joined among the ES [0]; All state machine instance of 7~9 row traversal program P are obtained variable X on control stream REC [0]
jAbstract semantic A (X
j) information, to confirm state machine instance EM
i(X
j) whether can break down N state
Fault: Exception, if then with unusual relevant information<l, EM
i>Join among the ES [0], wherein L is the unusual position of dishing out, EM
iBe Exception Type; If ES [0] is not empty, then from the 10th iterative process that is advanced into REC.
The 12nd~14 row at first calculates the change of ES [I] to REC [I], adds the up-to-date run-time exception information of record among the ES [I] to REC [I], i.e. the mark node of dishing out unusually among REC [I], and adding abnormality processing limit obtains REC [I+l] thus; Ensuing 15~17 row are traversal (EM once more
Ij)
N * m, on REC [I+1], obtain variable X
jAbstract semantic A (X
j) information, to confirm state machine instance EM
i(X
j) whether can break down N state
Fault: Exception, if malfunction also need be judged its up-to-date property, promptly therefrom remove in the past found identical unusual.While circulation through 10~19 row; Progressively iteration goes out all members among the REC; Up to there not being up-to-date unusual appearance, i.e.
Algorithm is last, is used by other function in order to make the run-time exception of dishing out in the current function, the function of the run-time exception of promptly confirming to dish out, and 20~22 are about in the current control stream that all are connected to N
Excp_exitThe limit of node, what be about to not be captured among the program P joins among its abstract context σ (P) unusually, for the caller use of P.
Below in conjunction with accompanying drawing, be example with the tested function f l in the table 1, the application of abnormal control flow set in software test that the present invention is proposed makes an explanation and explains that Fig. 1 is the application flow synoptic diagram of abnormal control flow set of the present invention in software test.As shown in Figure 1, this method may further comprise the steps:
The input information of steps A, application present analysis unit, initialization control adfluxion and fault collection;
The present analysis unit is for being the function f 1 in the table 1, and its input information comprises the initial control flow graph CFG (f1) of f1, shown in Fig. 4 (a).Suppose that the run-time exception state machine that f1 is set has four types: EM
Npd(null pointer is quoted unusually), EM
Bo(buffer zone overflow exception), EM
Wpd(the mistake reference pointer is unusual) and EM
Mlf(memory overflow) then need be respectively for the state machine instance that every type of fault is created: EM
Npd(p), EM
Npd(q), EM
Bo(p), EM
Wpd(p), EM
Wpd(q), EM
Mlf(q), they constitute the state machine instance matrix of f1 jointly:
This step is initially controlled and is flowed REC [0]=CFG (f1) and primary fault
after control stream REC [0] and fault ES [0] are carried out initialization operation
Step B, the pairing initial control stream of traversal analytic unit, the run-time exception information that the extraction subfunction possibly dished out is with first element of expansion fault collection, and execution in step is following:
B1, judge whether the node N among the current control stream REC [0] is its last node, execution in step C then in this way, otherwise execution in step B2;
B2, judge among the present node N of current control stream REC [0] whether have statement to function call, if exist then execution in step B3, otherwise execution in step B5;
B3, suppose that function F is called in node N, then according to its abstracted information σ (F) discriminant function F run-time exception of whether can dishing out, execution in step B4 in this way, otherwise execution in step B5;
B4, suppose that the run-time exception type that function F that node N calls is dished out is E, the ordered pair of then node and Exception Type being formed < N, E>joins as prior fault ES [0], execution in step B5 then;
B5, with next node replacement present node, the execution in step B1 then of node N among the current control stream REC [0].
In the corresponding control stream REC [0] of analytic unit f1; Because f1 is in the bottom of call relation; The subfunction that does not have to call for it generates abstracted information; After control stream REC [0] traversal is accomplished; All nodes that comprise function call run-time exception of all not dishing out, thus step B complete after, as prior fault
Step C, on current control stream REC [0], use existing static test detection failure, testing result is added in prior fault ES [0], execution in step is following:
The method of C1, application finite state machine is described fault; Node is wherein represented contingent state; Possible switch condition between Bian representative state; For being created by analytic unit and concrete variable correlation behavior machine instance, from all state machine instance, choose an EM (X) as current state machine instance, execution in step C2 then;
C2, on the diverse location N of control stream REC [0], be that the variable X among the current state machine instance EM (X) is calculated its possible value, and the bonding state switch condition carries out state exchange to EM (X).In state conversion process if the state that breaks down, execution in step C3 then, otherwise execution in step C4;
C3, step C2 carry out the back use mistake of variable X appear in N place in the position, as if this mistake run-time exception E that can dish out, then ordered pair < N, E>are joined in prior fault ES [0], then execution in step C4;
Whether have untreated instance in the set of C4, state machine instance, and if existed with next instance as current instance, execution in step C2 then, otherwise execution in step D.
One by one with state machine instance matrix (EM
Ij)
4 * 2In each instance EM
Npd(p), EM
Npd(q), EM
Bo(p), EM
Wpd(p), EM
Wpd(q), EM
Mlf(q) as analytic target, the possible value condition of calculated examples correlated variables on each node of control stream REC [0], and the bonding state switch condition carries out state exchange.Result of calculation is EM
Npd(p) at node n
7Pass through T
5: N
May* C
3→ N
FaultDerive malfunction, EM
Bo(p) at node n
11Pass through T
4: N
Bound* C
2→ N
FaultDerive malfunction.Because EM
Npd(p) and EM
Bo(p) run-time exception of can dishing out, thus step C complete after, obtain when prior fault ES [0]=<n
7, npd>,<n
11, bo>}.
Whether comprise detected failure collection in the currentElement of step D, failure judgement collection, if this set, representes that iterative detection finishes execution in step H for empty; If not, execution in step E then;
Since obtain after step C carries out when prior fault ES [0]=<n
7, npd>,<n
11, bo>, iterative detection does not finish, then execution in step E.
Step e, with the run-time exception information that is comprised in the prior fault of fault collection, on the node that corresponds to current control stream according to dish out position and Exception Type and the limit, it is following to obtain the execution in step that subsequent control that current control flows flows:
E1, choose the current ordered pair < N, E>among the fault ES [I], on control stream REC [I], match node N, whether decision node N is among the exception catching structure try, execution in step E2 in this way, otherwise execution in step E4;
Whether E2, the judgement abnormality processing structure catch corresponding with exception catching structure try can handle the pairing Exception Type of E, then go up to add the limit from N to corresponding catch node at REC [I] in this way, execution in step E5 then, otherwise execution in step E3;
Whether E3, current exception catching structure try also exist the try structure outward, and then outer field in this way try structure is set to current structure, execution in step E2 then, otherwise execution in step E5;
E4, REC [I] go up to add one from node N to the limit of withdrawing from node unusually, as the present analysis unit dished out unusual, execution in step E5 then;
Whether E5, judgement exist the ordered pair < N that did not handle in prior fault ES [I]; E >, if exist then it be labeled as current ordered pair, execution in step E1 then; Otherwise obtain subsequent control stream REC [I+1], the execution in step F then of current control stream REC [I].
For when prior fault ES [0]=<n
7, npd>,<n
11, bo>, at first therefrom choose ordered pair<n
7, npd>, node n
7Be among the exception catching structure try, and abnormality processing structure catch can handle null pointer and quote unusually, therefore at the node n that dishes out unusually at control stream REC [0]
7With abnormality processing node n
8Between add a limit of handling this run-time exception; Choose ordered pair then<n
11, bo>, node n
LlBe among the exception catching structure try, but abnormality processing structure catch cannot handle the buffer zone overflow exception, therefore at the node n that dishes out unusually at control stream REC [0]
11Unusually withdraw from node n
14Between add a limit of handling this run-time exception.Through after the execution of step e, obtain the subsequent control stream REC [1] of former control stream REC [0], shown in Fig. 4 (b).
Step F: on the subsequent control that in step e, the obtains stream, use existing fault detection technique, be not present in fault that fault concentrates and add among the consequent malfunction detected, obtain the next element of fault collection, execution in step is following:
F1, initialization fault are concentrated the consequent malfunction ES [I+1] of fault ES [I], and it is set to sky
execution in step F2 then;
F2, be to be created and concrete variable correlation behavior machine instance, from all state machine instance, choose an EM (X) as current state machine instance, execution in step F3 then by analytic unit;
F3, on the diverse location N of control stream REC [I+1], be that the variable X among the current state machine instance EM (X) is calculated its possible value, and the bonding state switch condition carries out state exchange to EM (X).In state conversion process if the state that breaks down, execution in step F4 then, otherwise execution in step F5;
The use mistake to variable X appearred in the N place in the position after F4, step F 3 were carried out, and the run-time exception E if this mistake can be dished out then checks ordered pair < N; E>whether be present in set ES [0], and ES [1] ...; ES [I] } in, if do not exist, then with ordered pair < N; E>join among the fault ES [I+1] execution in step F5 then;
Whether there is untreated instance in the set of F5, state machine instance, if exist then choose a untreated instance as current instance EM (X), execution in step F3 then, otherwise execution in step G.
At first initialization<img file="BSA00000143094600201.GIF" he="73" img-content="drawing" img-format="GIF" inline="yes" orientation="portrait" wi="272" />One by one with state machine instance matrix (EM<sub >Ij</sub>)<sub >4 * 2</sub>In each instance EM<sub >Npd</sub>(p), EM<sub >Npd</sub>(q), EM<sub >Bo</sub>(p), EM<sub >Wpd</sub>(p), EM<sub >Wpd</sub>(q), EM<sub >Mlf</sub>(q) as analytic target, the possible value condition of calculated examples correlated variables on each node of control stream REC [1], and the bonding state switch condition carries out state exchange.Result of calculation is EM<sub >Npd</sub>(p) at node n<sub >7</sub>Pass through EM<sub >Npd</sub>(T<sub >5</sub>: N<sub >May</sub>* C<sub >3</sub>→ N<sub >Fault</sub>) the derivation malfunction, EM<sub >Bo</sub>(p) at node n<sub >11</sub>Pass through EM<sub >Bo</sub>(T<sub >4</sub>: N<sub >Bound</sub>* C<sub >2</sub>→ N<sub >Fault</sub>) the derivation malfunction, EM<sub >Wpd</sub>(q) at node n<sub >12</sub>Pass through EM<sub >Wpd</sub>(T<sub >2</sub>: N<sub >Start</sub>* C<sub >1</sub>→ N<sub >Fault</sub>) the derivation malfunction, EM<sub >Mlf</sub>(q) at node n<sub >14</sub>Pass through EM<sub >Mlf</sub>(T<sub >4</sub>: N<sub >Alloc</sub>* C<sub >3</sub>→ N<sub >Fault</sub>) the derivation malfunction.EM<sub >Npd</sub>(p) and EM<sub >Bo</sub>(p) though the run-time exception of can dishing out, they have appeared among the ES [0], EM<sub >Mlf</sub>The run-time exception of can not dishing out, thus step F complete after, obtain when prior fault ES [1]=<n<sub >12</sub>, wpd>}.
The current information of step G, adjustment control adfluxion and fault collection points to, and the subsequent control stream that obtains in the step e is adjusted into current control stream, the consequent malfunction that obtains in the step F is adjusted into works as prior fault, then execution in step D;
In step D because ES [1}={<n
12, wpd>Be not empty, therefore need once more the process of repeating step D to step G.In this process, obtain REC [2] through step e, shown in Fig. 4 (c).After step F is carried out; Owing to there is not new fault generating; Therefore
arranged and when execution in step D once more, withdraw from cyclic process, execution in step H.
Step H, after the iteration processing finishes, analyze current control stream, extract the run-time exception that it can be dished out, and be retained in the designated data structure, be used for calling of other analytic unit step B, implementation step is following:
H1, choose and point to a limit E who withdraws from node among the control stream REC [I] unusually, with it as working as pre-treatment limit, execution in step H2 then;
H2, will work as among the abstracted information σ (F) that E pairing Exception Type in front joins the present analysis unit F, then execution in step H3;
H3, judge to point to the limit of withdrawing from node among the control stream REC [I] unusually and whether all finish dealing with, execution in step I then in this way, otherwise execution in step H2.
When carrying out this step, current control stream is REC [2], and what be connected to it withdraws from node n unusually
14The limit have three: from node n
12The mistake that spreads out of is used the unusual limit E of pointer
Wpd, from node n
11The buffer zone overflow exception limit E that spreads out of
Bo, from node n
10The self-defined unusual limit E that spreads out of
1After step H is complete, in the pairing abstracted information σ (f1) that joins function f 1 unusually in these three limits, call for the step B of analytic function f.
Next be the analytic process of function f in the his-and-hers watches 1, its input information comprises the initial control flow graph CFG (f) of f, shown in Fig. 5 (a).The run-time exception state machine of corresponding f also has four types: EM
Npd, EM
Bo, EM
WpdAnd EM
Mlf, need be respectively for the state machine instance that every type of fault is created: EM
Npd(p), EM
Npd(q), EM
Bo(q), EM
Wpd(p), EM
Wpd(q), EM
Mlf(p), EM
Mlf(q), they constitute the state machine instance matrix of f jointly:
This step is initially controlled and is flowed REC [0]=CFG (f) and primary fault
after control stream REC [0] and fault ES [0] are carried out initialization operation
In the corresponding control stream REC [0] of analytic unit f, when f1 analyze kept that it can dish out after accomplishing unusually in σ (f1), so step B complete after, when prior fault ES [0]=<n
4, wpd>,<n
4, bo>.
One by one with state machine instance matrix (EM
Ij)
4 * 2In each instance EM
Npd(p), EM
Npd(q), EM
Bo(q), EM
Wpd(p), EM
Wpd(q), EM
Mlf(p), EM
Mlf(q) as analytic target, possible the value condition of calculated examples correlated variables on each node of control stream REC [0], and the bonding state switch condition carries out state exchange, after step C is complete, obtain working as prior fault ES [0]=<n
4, wpd>,<n
4, bo>.
Since obtain after step C carries out when prior fault ES [0]=<n
4, wpd>,<n
4, bo>, iterative detection does not finish, then execution in step E.
For when prior fault ES [0]=<n
4, wpd>,<n
4, bo>, at first therefrom choose ordered pair<n
4, wpd>, node n
4Be among the exception catching structure try, and abnormality processing structure catch can to handle wrong reference pointer unusual, therefore at the node n that dishes out unusually at control stream REC [0]
4With abnormality processing node n
8Between add a limit of handling this run-time exception; Choose ordered pair then<n
4, bo>, node n
4Be among the exception catching structure try, but abnormality processing structure catch cannot handle the buffer zone overflow exception, therefore at the node n that dishes out unusually at control stream REC [0]
4Unusually withdraw from node n
14Between add a limit of handling this run-time exception.Through after the execution of step e, obtain the subsequent control stream REC [1] of former control stream REC [0], shown in Fig. 5 (b).
Next initialization<img file="BSA00000143094600221.GIF" he="73" img-content="drawing" img-format="GIF" inline="yes" orientation="portrait" wi="265" />One by one with state machine instance matrix (EM<sub >Ij</sub>)<sub >4 * 2</sub>In each instance as analytic target, the possible value condition of calculated examples correlated variables on each node of control stream REC [1], and the bonding state switch condition carries out state exchange.Result of calculation for obtain when prior fault ES [1]=<n<sub >10</sub>, npd>}.Because ES [1]=<n<sub >10</sub>, npd>Be not empty, therefore need once more the process of repeating step D to step G.In this process, obtain REC [2] through step e, shown in Fig. 5 (c).After step F is carried out; Owing to there is not new fault generating; Therefore <img file=" BSA00000143094600222.GIF " he=" 73 " img-content=" drawing " img-format=" tif " inline=" yes " orientation=" portrait " wi=" 265 " /> arranged and when execution in step D once more, withdraw from cyclic process, execution in step H.
Below in conjunction with concrete experiment the effect of the method for testing software of using abnormal control flow set to fault detect is described.Experiment is the basis with the software static test system DTS based on the code defective, and contrast Application abnormal control flow set front and back are to test process and result's influence.The DTS test structure is as shown in Figure 6, mainly comprises following content:
Configuration file is used for confirming the fault type of needs detection, and it can determine the quantity of abnormal patterns state machine; Through analyzing the correlated variables in the source file, determine every kind of abnormal patterns state machine need create the quantity of instance; Abstract syntax tree is that create on the basis with the source file, and it is to the abstract semantic basis of calculating of program; Deposit the control stream information of each analytic unit in the control flow graph, it is the basis that fault detects; Deposit information such as action scope, notation declarations and use, type expression derivation in the symbol table, it obtains from the abstract syntax tree construction; Analytic process one side acquisition of information from abstract syntax tree and symbol table confirms to analyze order through the call relation between function between function, for analyzing the function of accomplishing, preserves its abstract context to be used for other analytic process on the other hand; Interval arithmetic is carried out approximate treatment to the abstract value of correlated variables in the program, and it depends on data structures such as abstract syntax tree, control flow graph and symbol table; After the state machine instance of present analysis unit is created and accomplished, need this instance of operation to carry out state exchange.When on each node of control stream, carrying out interval arithmetic, the bonding state switch condition is realized the state conversion process of state machine, and malfunction is used to control the expansion of stream.
On the test structure of existing DTS, this patent is an example with 9 java programs of increasing income, test process and result data before and after the contrast Application abnormal control flow set.Set not using abnormal control flow set of DTS (A), DTS (B) using abnormal control flow set.Consider cost of development and operational efficiency, experiment is only studied null pointer and is quoted run-time exception to the test process of resource leakage class fault and result's influence.
Experimental data is as shown in table 3.The instance number of the 4th row only comprises each engineering is quoted abnormal patterns foundation to null pointer state machine instance quantity in the table; Member's sum that total iteration situation of the 5th row is an abnormal control flow set, i.e. while round-robin cycle index in table 2 algorithm.Can find out that from statistics total iterations of DTS (B) has on average increased by 2.85% than DTS (A), the detection effect to the resource leakage fault is the average fault detect rate 14.95% that improves thus.
Table 3 test comparison data
In addition, through with the contrast of the similar testing tool with other of above test result, although we find that every kind of instrument all has failing to report in various degree, 29 resource leakage faults that increase newspaper for DTS (B) did not occur in the report of other instrument.
As shown in Figure 7, the software testing system of using abnormal control flow set of the present invention comprises:
Initialization module is used to use the input information of present analysis unit, initialization control adfluxion and fault collection;
The plain expansion module of fault element of set; Be used to travel through the pairing initial control stream of analytic unit, promptly control first element in the adfluxion, all nodes that call subfunction are wherein handled; Extract the run-time exception information that subfunction possibly dished out, first element of expansion fault collection;
Fault detection module is used for first element in the control adfluxion, uses the static test detection failure, and testing result is made an addition among first element of fault collection;
Judge module, whether the currentElement that is used for the failure judgement collection comprises detected failure collection, if this set, representes that iterative detection finishes for empty, the result that the output iterative detection finishes; If not, the unclosed result of output iterative detection;
Subsequent control stream acquisition module; Be used in said judge module output iterative detection unclosed as a result the time; The run-time exception information that in prior fault, is comprised with the fault collection; Correspond to according to dish out position and Exception Type on the node and limit of current control stream, obtain the subsequent control stream of current control stream;
Subsequent control stream fault detection module is used at subsequent control stream, and the application and trouble detection technique is not present in fault that fault concentrates and adds among the consequent malfunction detected, obtains the next element of fault collection;
The circulation module; Be used to adjust the current information sensing of control adfluxion and fault collection; The subsequent control stream that said subsequent control stream acquisition module is obtained is adjusted into current control stream; The consequent malfunction that said subsequent control stream fault detection module is obtained is adjusted into works as prior fault, and exports to said judge module;
The run-time exception extraction module, be used for said judge module output iterative detection finish as a result the time, analyze current control stream, extract the run-time exception that it can be dished out, and be retained in the designated data structure.
The above embodiment is the preferred embodiment that proves absolutely that the present invention lifts, and protection scope of the present invention is not limited thereto.Being equal to that the technician in present technique field is done on basis of the present invention substitutes or conversion, all within protection scope of the present invention.Protection scope of the present invention is as the criterion with claims.
Claims (2)
1. the method for testing software of a using abnormal control flow set is characterized in that, comprising:
The input information of steps A, application present analysis unit, initialization control adfluxion and fault collection;
Step B, the pairing initial control stream of traversal analytic unit are promptly controlled first element in the adfluxion, and all nodes that call subfunction are wherein handled, and extract the run-time exception information that subfunction possibly dished out, first element of expansion fault collection;
Step C, on first element of control adfluxion, use the static test detection failure, and testing result made an addition among first element of fault collection;
Whether comprise detected failure collection in the currentElement of step D, failure judgement collection, if this set, representes that iterative detection finishes execution in step H for empty; If not, execution in step E then;
Step e, with the run-time exception information that is comprised in the prior fault of fault collection, on the node that corresponds to current control stream according to dish out position and Exception Type and the limit, obtain the subsequent control that current control flows and flow;
On step F, the subsequent control stream that in said step e, obtains, the application and trouble detection technique is not present in fault that fault concentrates and adds among the consequent malfunction detected, obtains the next element of fault collection;
The current information of step G, adjustment control adfluxion and fault collection points to, and the subsequent control stream that obtains in the said step e is adjusted into current control stream, the consequent malfunction that obtains in the said step F is adjusted into works as prior fault, returns step D;
Step H, after the iteration processing finishes, analyze current control stream, extract the run-time exception that it can be dished out, and be retained in the designated data structure;
Wherein, said steps A specifically comprises:
A1, initialization set member sequence number, it is 0 that its current value is set;
First element of A2, initialization fault collection, its currentElement of set of applications member's sequence number is set to sky;
The currentElement that first element of A3, initialization control adfluxion, set of applications member's sequence number controls adfluxion is set to the initial control of present analysis unit and flows;
Wherein, said step B specifically comprises:
B1, judge whether the node in the current control stream is its last node, then carries out said step C in this way, otherwise execution in step B2;
B2, judge in the present node of current control stream whether have statement to function call, if exist then execution in step B3, otherwise execution in step B5;
B3, according to the function abstracted information discriminant function run-time exception of whether can dishing out that in node, is called, execution in step B4 in this way, otherwise execution in step B5;
B4, the ordered pair that node and Exception Type are formed join and work as prior fault, then execution in step B5;
B5, with the next node replacement present node of node in the current control stream, return step B1;
Wherein, said step C specifically comprises:
The method of C1, application finite state machine is described fault; Node is wherein represented contingent state; Possible switch condition between Bian representative state for being created by analytic unit and concrete variable correlation behavior machine instance, is chosen one as current state machine instance from all state machine instance;
C2, on the diverse location of control stream; Be that the variable in the current state machine instance calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine instance, in state conversion process if break down state; Execution in step C3 then, otherwise execution in step C4;
C3, the run-time exception composition ordered pair that will go out the position of present condition and dish out join ordered pair in prior fault;
C4, judge in the state machine instance set whether have untreated instance, and if existed with next instance as current instance, return step C2, otherwise carry out said step D;
Wherein, said step e specifically comprises:
E1, choose the current ordered pair in the fault, on control stream, match the respective nodes of ordered pair, judge whether this node is in the exception catching structure, execution in step E2 in this way, otherwise execution in step E4;
Whether E2, the judgement abnormality processing structure corresponding with the exception catching structure can handle the pairing Exception Type of run-time exception in the ordered pair; Then on current control stream, add the limit from node to corresponding abnormality processing structure node, an execution in step E5 then in this way; As denying execution in step E3;
Whether E3, judgement also exist other exception catching structure except that current exception catching structure, then outer field in this way exception catching structure is set to current structure, returns step e 2, otherwise execution in step E5;
E4, on current control stream, add one from node to the limit of withdrawing from node unusually, as the present analysis unit dished out unusual;
E5, judge in prior fault whether have the ordered pair of not handling,, return step e 1 if exist then it is labeled as current ordered pair; Otherwise obtain the subsequent control stream of current control stream, then execution in step F;
Wherein, said step F specifically comprises:
F1, initialization fault are concentrated the consequent malfunction when prior fault, and consequent malfunction is set to sky;
F2, be to be created and concrete variable correlation behavior machine instance, from all state machine instance, choose one as current state machine instance by analytic unit;
F3, on the diverse location of subsequent control stream; Be that the variable in the current state machine instance calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine instance, in state conversion process if break down state; Execution in step F4 then, otherwise execution in step F5;
F4, the run-time exception that will occur using wrong position and this mistake to dish out are formed ordered pair, check whether this ordered pair is present in the failure collection, if do not exist, then this ordered pair are joined in the said consequent malfunction in back;
F5, judge in the state machine instance set whether have untreated instance,, return step F 3 if exist then choose a untreated instance as current instance, otherwise execution in step G;
Wherein, said step H specifically comprises:
H1, choose and point to a limit withdrawing from node in the current control stream unusually, with it as working as the pre-treatment limit;
H2, will work as the pairing Exception Type in front and join among the abstracted information of present analysis unit;
H3, judge to point to the limit of withdrawing from node in the current control stream unusually and whether all finish dealing with, execution in step I then in this way, otherwise select to withdraw from unusually in the current control stream limit of node, it as working as the pre-treatment limit, is returned step H2.
2. the software testing system of a using abnormal control flow set is characterized in that, comprising:
Initialization module is used to use the input information of present analysis unit, initialization control adfluxion and fault collection;
The plain expansion module of fault element of set; Be used to travel through the pairing initial control stream of analytic unit, promptly control first element in the adfluxion, all nodes that call subfunction are wherein handled; Extract the run-time exception information that subfunction possibly dished out, first element of expansion fault collection;
Fault detection module is used for first element in the control adfluxion, uses the static test detection failure, and testing result is made an addition among first element of fault collection;
Judge module, whether the currentElement that is used for the failure judgement collection comprises detected failure collection, if this set, representes that iterative detection finishes for empty, the result that the output iterative detection finishes; If not, the unclosed result of output iterative detection;
Subsequent control stream acquisition module; Be used in said judge module output iterative detection unclosed as a result the time; The run-time exception information that in prior fault, is comprised with the fault collection; Correspond to according to dish out position and Exception Type on the node and limit of current control stream, obtain the subsequent control stream of current control stream;
Subsequent control stream fault detection module is used at subsequent control stream, and the application and trouble detection technique is not present in fault that fault concentrates and adds among the consequent malfunction detected, obtains the next element of fault collection;
The circulation module; Be used to adjust the current information sensing of control adfluxion and fault collection; The subsequent control stream that said subsequent control stream acquisition module is obtained is adjusted into current control stream; The consequent malfunction that said subsequent control stream fault detection module is obtained is adjusted into works as prior fault, and exports to said judge module;
The run-time exception extraction module, be used for said judge module output iterative detection finish as a result the time, analyze current control stream, extract the run-time exception that it can be dished out, and be retained in the designated data structure;
Wherein, the performed operation of said initialization module specifically comprises:
A1, initialization set member sequence number, it is 0 that its current value is set;
First element of A2, initialization fault collection, its currentElement of set of applications member's sequence number is set to sky;
The currentElement that first element of A3, initialization control adfluxion, set of applications member's sequence number controls adfluxion is set to the initial control of present analysis unit and flows;
Wherein, the performed operation of the plain expansion module of said fault element of set specifically comprises:
B1, judge whether the node in the current control stream is its last node, is then further operated by said fault detection module in this way, otherwise execution in step B2;
B2, judge in the present node of current control stream whether have statement to function call, if exist then execution in step B3, otherwise execution in step B5;
B3, according to the function abstracted information discriminant function run-time exception of whether can dishing out that in node, is called, execution in step B4 in this way, otherwise execution in step B5;
B4, the ordered pair that node and Exception Type are formed join and work as prior fault, then execution in step B5;
B5, with the next node replacement present node of node in the current control stream, return step B1;
Wherein, the performed operation of said fault detection module specifically comprises:
The method of C1, application finite state machine is described fault; Node is wherein represented contingent state; Possible switch condition between Bian representative state for being created by analytic unit and concrete variable correlation behavior machine instance, is chosen one as current state machine instance from all state machine instance;
C2, on the diverse location of control stream; Be that the variable in the current state machine instance calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine instance, in state conversion process if break down state; Execution in step C3 then, otherwise execution in step C4;
C3, the run-time exception composition ordered pair that will go out the position of present condition and dish out join ordered pair in prior fault;
C4, judge in the state machine instance set whether have untreated instance, and if existed with next instance as current instance, return step C2, otherwise carry out corresponding operating by said judge module;
Wherein, the performed operation of said subsequent control stream acquisition module specifically comprises:
E1, choose the current ordered pair in the fault, on control stream, match the respective nodes of ordered pair, judge whether this node is in the exception catching structure, execution in step E2 in this way, otherwise execution in step E4;
Whether E2, the judgement abnormality processing structure corresponding with the exception catching structure can handle the pairing Exception Type of run-time exception in the ordered pair; Then on current control stream, add the limit from node to corresponding abnormality processing structure node, an execution in step E5 then in this way; As denying execution in step E3;
Whether E3, judgement also exist other exception catching structure except that current exception catching structure, then outer field in this way exception catching structure is set to current structure, returns step e 2, otherwise execution in step E5;
E4, on current control stream, add one from node to the limit of withdrawing from node unusually, as the present analysis unit dished out unusual;
E5, judge in prior fault whether have the ordered pair of not handling,, return step e 1 if exist then it is labeled as current ordered pair; Otherwise obtain the subsequent control stream of current control stream, carry out corresponding operating by said subsequent control stream fault detection module then;
Wherein, the performed operation of said subsequent control stream fault detection module specifically comprises:
F1, initialization fault are concentrated the consequent malfunction when prior fault, and consequent malfunction is set to sky;
F2, be to be created and concrete variable correlation behavior machine instance, from all state machine instance, choose one as current state machine instance by analytic unit;
F3, on the diverse location of subsequent control stream; Be that the variable in the current state machine instance calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine instance, in state conversion process if break down state; Execution in step F4 then, otherwise execution in step F5;
F4, the run-time exception that will occur using wrong position and this mistake to dish out are formed ordered pair, check whether this ordered pair is present in the failure collection, if do not exist, then this ordered pair are joined in the said consequent malfunction in back;
F5, judge in the state machine instance set whether have untreated instance,, return step F 3, otherwise carry out corresponding operating by said circulation module if exist then choose a untreated instance as current instance;
Wherein, the performed operation of said run-time exception extraction module specifically comprises:
H1, choose and point to a limit withdrawing from node in the current control stream unusually, with it as working as the pre-treatment limit;
H2, will work as the pairing Exception Type in front and join among the abstracted information of present analysis unit;
H3, judge to point to the limit of withdrawing from node in the current control stream unusually and whether all finish dealing with, execution in step I then in this way, otherwise select to withdraw from unusually in the current control stream limit of node, it as working as the pre-treatment limit, is returned step H2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2010101883761A CN101847122B (en) | 2010-06-01 | 2010-06-01 | Method and system for testing software by using abnormal control flow set |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2010101883761A CN101847122B (en) | 2010-06-01 | 2010-06-01 | Method and system for testing software by using abnormal control flow set |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101847122A CN101847122A (en) | 2010-09-29 |
CN101847122B true CN101847122B (en) | 2012-05-02 |
Family
ID=42771747
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2010101883761A Expired - Fee Related CN101847122B (en) | 2010-06-01 | 2010-06-01 | Method and system for testing software by using abnormal control flow set |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101847122B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103257913B (en) * | 2013-04-18 | 2015-10-28 | 西安交通大学 | Software fault detection removal system and method during a kind of operation |
CN104461886A (en) * | 2014-12-10 | 2015-03-25 | 深圳航天东方红海特卫星有限公司 | Control flow error detection method |
CN107704332B (en) * | 2017-09-28 | 2021-06-15 | 努比亚技术有限公司 | Screen freezing solution method, mobile terminal and computer readable storage medium |
CN109446078B (en) * | 2018-10-18 | 2022-02-18 | 网易(杭州)网络有限公司 | Code testing method and device, storage medium and electronic equipment |
CN111831532A (en) * | 2019-04-15 | 2020-10-27 | 富士通株式会社 | Method for constructing test scene and information processing equipment |
CN112069052B (en) * | 2019-06-11 | 2024-04-12 | 腾讯科技(深圳)有限公司 | Abnormal object detection method, device, equipment and storage medium |
CN111061644B (en) * | 2019-12-25 | 2021-04-30 | 南京大学 | Method and device for detecting and positioning abnormal throwing processing defects |
CN111966076B (en) * | 2020-08-11 | 2023-06-09 | 广东工业大学 | Fault positioning method based on finite state machine and graph neural network |
CN112527419B (en) * | 2020-12-16 | 2024-04-19 | 深圳知释网络技术有限公司 | Finite state machine analysis method and system based on abstract model |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101251820A (en) * | 2008-04-09 | 2008-08-27 | 无敌科技(西安)有限公司 | Software test method based on program operating field |
CN101286132A (en) * | 2008-06-02 | 2008-10-15 | 北京邮电大学 | Test method and system based on software defect mode |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB0206761D0 (en) * | 2002-03-22 | 2002-05-01 | Object Media Ltd | Software testing |
-
2010
- 2010-06-01 CN CN2010101883761A patent/CN101847122B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101251820A (en) * | 2008-04-09 | 2008-08-27 | 无敌科技(西安)有限公司 | Software test method based on program operating field |
CN101286132A (en) * | 2008-06-02 | 2008-10-15 | 北京邮电大学 | Test method and system based on software defect mode |
Non-Patent Citations (1)
Title |
---|
闫大顺等.一种分析异常传播路径的方法.《计算机工程》.2009,第34卷(第8期),50~52. * |
Also Published As
Publication number | Publication date |
---|---|
CN101847122A (en) | 2010-09-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101847122B (en) | Method and system for testing software by using abnormal control flow set | |
US7971193B2 (en) | Methods for performining cross module context-sensitive security analysis | |
CN102736979B (en) | Symbolic-execution-based method for generating test cases with feedback | |
CN102521117B (en) | Java exception propagation static structure extraction method | |
CN102368226A (en) | Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine) | |
Ghandehari et al. | BEN: A combinatorial testing-based fault localization tool | |
CN110059010B (en) | Buffer overflow detection method based on dynamic symbol execution and fuzzy test | |
Jacob | Implementation of randomized test pattern generation strategy | |
US20090249285A1 (en) | Automatic Generation of Run-Time Instrumenter | |
CN102768643A (en) | Method for testing correctness of JavaScript function by using multiple function contracts | |
Ye et al. | A general algorithm for pattern diagnosability of distributed discrete event systems | |
Wu et al. | Regression testing on object-oriented programs | |
Gupta et al. | Design pattern mining using state space representation of graph matching | |
Wang et al. | Risk analysis on multi-granular flow network for software integration testing | |
Zaidman et al. | How webmining and coupling metrics improve early program comprehension | |
Bernardi et al. | Testing aspect oriented programs: an approach based on the coverage of the interactions among advices and methods | |
Weston et al. | Interaction analysis for fault-tolerance in aspect-oriented programming | |
Xi et al. | An approach of coarse-grained dynamic slice for Java program | |
Miao et al. | A formal specification-based integration testing approach | |
Montenegro et al. | A space consumption analysis by abstract interpretation | |
Bernardi | Reverse engineering of aspect oriented systems to support their comprehension, evolution, testing and assessment | |
Chopra et al. | Reusing black box test paths for white box testing of websites | |
Ball et al. | Threshold reliability of networks with small failure sets | |
Dam et al. | Compiler generation from relational semantics | |
Pan et al. | Slicing component-based systems |
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 |
Granted publication date: 20120502 Termination date: 20180601 |
|
CF01 | Termination of patent right due to non-payment of annual fee |