CN101847122A - 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 PDF

Info

Publication number
CN101847122A
CN101847122A CN201010188376A CN201010188376A CN101847122A CN 101847122 A CN101847122 A CN 101847122A CN 201010188376 A CN201010188376 A CN 201010188376A CN 201010188376 A CN201010188376 A CN 201010188376A CN 101847122 A CN101847122 A CN 101847122A
Authority
CN
China
Prior art keywords
fault
control stream
node
execution
run
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
CN201010188376A
Other languages
Chinese (zh)
Other versions
CN101847122B (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 CN2010101883761A priority Critical patent/CN101847122B/en
Publication of CN101847122A publication Critical patent/CN101847122A/en
Application granted granted Critical
Publication of CN101847122B publication Critical patent/CN101847122B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

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

The method for testing software of using abnormal control flow set and system
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 corresponding defect mode, 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.Be subjected to 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 by contrast test, and owing to the degree of approximation difference to 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 has the code above 2/3rds to be used for abnormality processing in some software systems.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 causes on the control stream of expansion, 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 problem to be solved in the present invention 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 may be 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, represents 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, 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;
On step F, the subsequent control stream that obtains in described step e, 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 described step e is adjusted into current control stream, the consequent malfunction that obtains in the described 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, described 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, described step B specifically comprises:
B1, judge whether the node in the current control stream is its last node, then carries out described step C in this way, otherwise execution in step B2;
B2, judge the statement that whether exists in the present node of current control stream 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, replace present node, return step B1 with the next node of node in the current control stream.
Further, described 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 is created and concrete variable correlation behavior machine example for analyzed unit, chooses one as current state machine example from all state machine instance;
C2, on the diverse location of control stream, for the variable in the current state machine example calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine example, 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 example, and if existed with next example as current example, return step C2, otherwise carry out described step D.
Further, described 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, described step F specifically comprises:
F1, initialization fault are concentrated the consequent malfunction when prior fault, and consequent malfunction is set to sky;
F2, be that analyzed unit is created and concrete variable correlation behavior machine example, from all state machine instance, choose one as current state machine example;
F3, on the diverse location of subsequent control stream, for the variable in the current state machine example calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine example, 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 there is no, then this ordered pair are joined in the described consequent malfunction in back;
F5, judge in the state machine instance set whether have untreated example,, return step F 3 if exist then choose a untreated example as current example, otherwise execution in step G.
Further, described 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 may be 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, represents 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 described 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 described subsequent control stream acquisition module is obtained is adjusted into current control stream, the consequent malfunction that described subsequent control stream fault detection module is obtained is adjusted into works as prior fault, and exports to described judge module;
The run-time exception extraction module, be used for described 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 by 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; By 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 by the iterative equation generating run is carried out with the alternately iteration that realizes expansion of control stream and new fault detect.By 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
The invention will be further described below in conjunction with the drawings and specific embodiments, can be implemented so that those skilled in the art can better understand the present invention also, but illustrated embodiment is not as a limitation of the invention.
Static test technology towards the code defective can be described as theoretically to problem D={P, 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 determining 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 calculating the value information of correlated variables X approx, and L is the executing location of P, and X is the variable that P carries out the L place; σ is the abstract context of function, represents approx calling the abstract of function F.Because the introducing of run-time exception may expand to S with the control flow path S that influenced by it 1, and at S 1On may 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
Figure BSA00000143094600061
The problem that algorithm A is found the solution can be converted into A={S ∪ [S like this 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
Figure BSA00000143094600062
Figure BSA00000143094600063
The situation that defective is failed to report appears thus:
Figure BSA00000143094600064
Figure BSA00000143094600065
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) represents 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, extra limit of adding 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 by 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 by 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, and how run-time exception being explained among the M is at first to need the problem that solves, and 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 may 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, enter this state after state machine is created automatically; N EndBe the unique outlet of state machine, enter this state behind the state machine end of run automatically; N Fault={ Exception, Error} are the unique malfunctions of state machine, unusually then are not labeled as Error 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 carrying out state exchange on the abnormal patterns state machine, need to finish in conjunction with the abstract semanteme and the state transition condition C of concrete variable X, 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) is converted to n i={ n j* C | { S, ρ (L, X), σ (F) } }, in conjunction with concrete variable X and at the abstract semanteme at position L place { S, ρ (L, X), σ (F) }, can be by state transition condition C with the current state n of EM (X) jBe converted to state n 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), then all abnormal patterns state machine instance of program P correspondence constitute the abnormal patterns state machine instance matrix of P, and note is done:
( EM ij ) n × m = EM 1 ( X 1 ) EM 1 ( X 2 ) . . . EM 1 ( X m ) EM 2 ( X 1 ) EM 2 ( X 2 ) . . . EM 2 ( X m ) . . . . . . . . . EM n ( X 1 ) EM n ( X 2 ) . . . EM n ( X m ) .
Figure BSA00000143094600082
The expression variable X jWith abnormal patterns EM iIrrelevant, do not need to 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 may 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 binding 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 relevant with types of variables among the f1, need be respectively for the state machine instance that every class 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:
Figure BSA00000143094600101
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, use switch condition EM i.C carry out state exchange.When the N state that breaks down Fault: behind the Exception, record trouble and to control stream expand accordingly.
2. run-time exception control is flowed
Existing method is when construction procedures control stream, comprised the abnormality processing correlative, as the try statement of determining the exception catching scope, determine the catch statement of catching exception type, and can determine the throw statement of unusual throw point and dish out and can determine unusual process.In addition, in order to describe unusual influence to program control flow fully, the content relevant with run-time exception also should join wherein, as 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 defined as follows 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 ExBefore beginning, static test can determine N ErAnd N EfNeed in the static test process, can determine.To the node N that can dish out unusual Ex, N ErAnd N Ef, its output of correspondence of two class limits is 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 summarized 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, by limit E ReBe connected to the N corresponding with its type CatchNode or the N corresponding not with it Excp_exitNode; By 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 may appear on the control stream of expansion, the present invention to controlling the expansion of flowing and flowing these two processes that replace iteration of the new run-time exception of discovery in the control of expansion and represent by abnormal control flow set, specifically describes as follows run-time exception:
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 find new run-time exception on the control stream of expansion, 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 is subjected to 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 to pass through ES iWith REC iBe converted into REC I+1Rule.
Under Regulation G,
Figure BSA00000143094600121
Comprise two parts content, first control stream REC 0In 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 ReBe expressed as at control stream REC 0Go up the ordered pair corresponding with re; It two is not comprise node N ErAnd N EfTraditional abnormal control flow REC 0Upward (that A) asks effectively separates for P, M to problem D.M corresponding states machine example matrix (EM among the D Ij) N * m, at computation process (EM Ij) N * mAmong * the A,
EM 1 ( X 1 ) EM 1 ( X 2 ) . . . EM 1 ( X m ) EM 2 ( X 1 ) EM 2 ( X 2 ) . . . EM 2 ( X m ) . . . . . . . . . EM n ( X 1 ) EM n ( X 2 ) . . . EM n ( X m ) × A ( X 1 ) A ( X 2 ) . . . A ( X m ) = Σ i = 1 n Σ j = 1 m Σ k = 1 m EM i ( X j ) A ( X k )
Work as variable X jWith abnormal patterns EM iWhen irrelevant
Figure BSA00000143094600132
In addition, when j ≠ k
Figure BSA00000143094600133
Expression is to non-NULL example EM i(X j) the application algorithm
Figure BSA00000143094600135
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 jThe L of) →<, 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 example 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 jThe L of) →<, EM i.By to (EM Ij) N * mIn all example calculation, last controlled stream REC kLast the new run-time exception that might dish out
Figure BSA00000143094600138
Under rule T,
Figure BSA00000143094600139
Use ES iThe information {<N of middle record Er, E Re| N Er, E Re∈ REC i, at control stream REC iThe dish out node N of run-time exception of last mark Er, and add corresponding abnormality processing limit E Re, at last it is expanded to REC I+1, SUM (ES i) be ES iMiddle number of members.
Alternately iteration by to unusual create-rule G and control stream translation rule T can realize the generation of abnormal control flow set RS.Iterative equation is expressed as follows, and supposes REC 0Known, iterative process is from t=1, up to Finish.
REC t = RE C 0 , t = 0 , ∪ j = 1 sum ( ES t - 1 ) { REC t - 1 × ES ( t - 1 ) j } , t ≥ 1
Figure BSA00000143094600142
In order to analyze the character of abnormal control flow set RS, it can 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
Figure BSA00000143094600143
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 promptly the abnormal control flow set RS that 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 as follows:
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 by 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 the run-time exception control adfluxion of its correspondence 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 BoAfter, rule T is with REC 0Be converted to the REC of Fig. 4 (b) 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 1Be converted to the REC of Fig. 4 (c) 2At last
Figure BSA00000143094600151
Iteration stops.
From last example as can be seen, owing to used the fault detection method of iteration, make tested object from traditional abnormal control flow REC 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 by 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 correspondence of algorithm do 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
2: I=0;
Figure BSA00000143094600152
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
Figure BSA00000143094600154
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
16 : ES [ I + 1 ] = ES [ I + 1 ] +
{ EM i ( X j ) A ( X j ) | REC [ I + 1 ] } - &Sigma; i = 0 I ES [ i ] ;
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 ES[0] in; All state machine instance of 7~9 row traversal program P are at control stream REC[0] on obtain variable X jAbstract semantic A (X j) information, to determine state machine instance EM i(X j) whether can break down N state Fault: Exception, if then with unusual relevant information<L, EM iJoin ES[0] in, wherein L is the unusual position of dishing out, EM iBe Exception Type; If ES[0] be not empty, then from the 10th iterative process that is advanced into REC.
The 12nd~14 row at first calculates ES[I] to REC[I] change, with ES[I] in the up-to-date run-time exception information of record add REC[I to], promptly at REC[I] in the mark node of dishing out unusually, and adding abnormality processing limit obtains REC[I+l thus]; Ensuing 15~17 row are traversal (EM once more Ij) N * m, at REC[I+1] on obtain variable X jAbstract semantic A (X j) information, to determine state machine instance EM i(X j) whether can break down N state Fault: Exception, if malfunction also needs to judge its up-to-date property, promptly therefrom remove in the past found identical unusual.By the while circulation of 10~19 row, progressively iteration goes out all members among the REC, up to there not being up-to-date unusual appearance, promptly
Figure BSA00000143094600161
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 determining 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 is explained and illustrated, and 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 needs to be respectively for the state machine instance that every class 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:
Figure BSA00000143094600171
This step is to control stream REC[0] and fault ES[0] carry out initialization operation after, initially controlled and flowed REC[0]=CFG (f1) and primary fault
Figure BSA00000143094600172
Step B, the pairing initial control stream of traversal analytic unit, the run-time exception information that the extraction subfunction may be dished out is with first element of expansion fault collection, and execution in step is as follows:
B1, judge current control stream REC[0] in node N whether be its last node, execution in step C then in this way, otherwise execution in step B2;
B2, judge current control stream REC[0] present node N in 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, ordered pair<N that node and Exception Type are formed then, E〉join as prior fault ES[0], execution in step B5 then;
B5, with current control stream REC[0] in the next node of node N replace present node, execution in step B1 then.
Control stream REC[0 in analytic unit f1 correspondence] in, because f1 is in the bottom of call relation, the subfunction that does not have to call for it generates abstracted information, at control stream REC[0] after traversal finishes, all nodes that comprise function call run-time exception of all not dishing out, therefore step B complete after, work as prior fault
Figure BSA00000143094600173
Step C, on current control stream REC[0], use existing static test detection failure, testing result is added to as prior fault ES[0] in, execution in step is as follows:
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 creating and concrete variable correlation behavior machine example analyzed unit, from all state machine instance, choose an EM (X) as current state machine example, execution in step C2 then;
C2, at control stream REC[0] diverse location N on, for the variable X among the current state machine example 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 variable X appears in the back at position N place use mistake, as if this mistake run-time exception E that can dish out, then with ordered pair<N, E〉join as prior fault ES[0] in, execution in step C4 then;
Whether have untreated example in the set of C4, state machine instance, and if existed with next example as current example, execution in step C2 then, otherwise execution in step D.
One by one with state machine instance matrix (EM Ij) 4 * 2In each example EM Npd(p), EM Npd(q), EM Bo(p), EM Wpd(p), EM Wpd(q), EM Mlf(q) as analytic target, at control stream REC[0] each node on the possible value condition of calculated examples correlated variables, 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 as 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, represents that iterative detection finishes execution in step H for empty; If not, execution in step E then;
Owing to obtain as prior fault ES[0 after step C carries out]={<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, correspond to according to dish out position and Exception Type on the node and limit of current control stream, the execution in step of subsequent control stream that obtains current control stream is as follows:
E1, choose fault ES[I] in current ordered pair<N, E 〉, at control stream REC[I] on 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, in this way then at REC[I] go up to add a limit, execution in step E5 then, otherwise execution in step E3 from N to corresponding catch node;
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, at 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;
E5, judge as prior fault ES[I] in whether have the ordered pair<N that did not handle, E 〉, if exist then it be labeled as current ordered pair, execution in step E1 then, otherwise obtain current control stream REC[I] subsequent control stream REC[I+1], execution in step F then.
For working as 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 control stream REC[0] the node n that dishes out unusually 7With abnormality processing node n 8Between add a limit of handling this run-time exception; Choose ordered pair<n then 11, bo 〉, node n LlTherefore be among the exception catching structure try, but abnormality processing structure catch cannot handle the buffer zone overflow exception, at control stream REC[0] the node n that dishes out unusually 11Unusually withdraw from node n 14Between add a limit of handling this run-time exception.Through after the execution of step e, obtain former control stream REC[0] subsequent control stream REC[1], shown in Fig. 4 (b).
Step F: on the subsequent control that the obtains stream, use existing fault detection technique in step e, 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 as follows:
F1, initialization fault concentrate fault ES[I] consequent malfunction ES[I+1], it is set to sky
Figure BSA00000143094600191
Execution in step F2 then;
F2, be that analyzed unit is created and concrete variable correlation behavior machine example, from all state machine instance, choose an EM (X) as current state machine example, execution in step F3 then;
F3, at control stream REC[I+1] diverse location N on, for the variable X among the current state machine example 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;
F4, step F 3 are carried out the back in the use mistake of position N place appearance to variable X, the run-time exception E if this mistake can be dished out, then check ordered pair<N, E〉whether be present in set ES[0], ES[1], ..., ES[I] } in, if there is no, then with ordered pair<N, E〉join fault ES[I+1] in, execution in step F5 then;
Whether there is untreated example in the set of F5, state machine instance, if exist then choose a untreated example as current example EM (X), execution in step F3 then, otherwise execution in step G.
At first initialization
Figure BSA00000143094600201
One by one with state machine instance matrix (EM Ij) 4 * 2In each example EM Npd(p), EM Npd(q), EM Bo(p), EM Wpd(p), EM Wpd(q), EM Mlf(q) as analytic target, at control stream REC[1] each node on the possible value condition of calculated examples correlated variables, and the bonding state switch condition carries out state exchange.Result of calculation is EM Npd(p) at node n 7Pass through EM Npd(T 5: N May* C 3→ N Fault) the derivation malfunction, EM Bo(p) at node n 11Pass through EM Bo(T 4: N Bound* C 2→ N Fault) the derivation malfunction, EM Wpd(q) at node n 12Pass through EM Wpd(T 2: N Start* C 1→ N Fault) the derivation malfunction, EM Mlf(q) at node n 14Pass through EM Mlf(T 4: N Alloc* C 3→ N Fault) the derivation malfunction.EM Npd(p) and EM Bo(p) though the run-time exception of can dishing out, they have appeared at ES[0] in, EM MlfThe run-time exception of can not dishing out, thus step F complete after, obtain as prior fault ES[1]={<n 12, 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 by step e], shown in Fig. 4 (c).After step F is carried out,, therefore have owing to there is not new fault to produce
Figure BSA00000143094600202
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 as follows:
H1, choose and point to control stream REC[I] in withdraw from a limit E of node 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 control stream REC[I] in withdraw from node unusually the limit 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], 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 class 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:
Figure BSA00000143094600211
This step is to control stream REC[0] and fault ES[0] carry out initialization operation after, initially controlled and flowed REC[0]=CFG (f) and primary fault
Figure BSA00000143094600212
At the control of analytic unit f correspondence stream REC[0] in, when f1 analyze kept that it can dish out after finishing unusually in σ (f1), so step B complete after, as prior fault ES[0]={<n 4, wpd 〉,<n 4, bo〉}.
One by one with state machine instance matrix (EM Ij) 4 * 2In each example EM Npd(p), EM Npd(q), EM Bo(q), EM Wpd(p), EM Wpd(q), EM Mlf(p), EM Mlf(q) as analytic target, at control stream REC[0] each node on possible the value condition of calculated examples correlated variables, and the bonding state switch condition carries out state exchange, after step C is complete, obtains working as prior fault ES[0]={<n 4, wpd 〉,<n 4, bo〉}.
Owing to obtain as prior fault ES[0 after step C carries out]={<n 4, wpd 〉,<n 4, bo〉}, iterative detection does not finish, then execution in step E.
For working as 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 control stream REC[0] the node n that dishes out unusually 4With abnormality processing node n 8Between add a limit of handling this run-time exception; Choose ordered pair<n then 4, bo 〉, node n 4Therefore be among the exception catching structure try, but abnormality processing structure catch cannot handle the buffer zone overflow exception, at control stream REC[0] the node n that dishes out unusually 4Unusually withdraw from node n 14Between add a limit of handling this run-time exception.Through after the execution of step e, obtain former control stream REC[0] subsequent control stream REC[1], shown in Fig. 5 (b).
Next initialization
Figure BSA00000143094600221
One by one with state machine instance matrix (EM Ij) 4 * 2In each example as analytic target, at control stream REC[1] each node on the possible value condition of calculated examples correlated variables, and the bonding state switch condition carries out state exchange.Result of calculation is for obtaining as prior fault ES[1]={<n 10, npd>}.Because ES[1]={<n 10, npd〉} be not empty, therefore need once more the process of repeating step D to step G.In this process, obtain REC[2 by step e], shown in Fig. 5 (c).After step F is carried out,, therefore have owing to there is not new fault to produce
Figure BSA00000143094600222
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 based on the software static test system DTS based on the code defective, and contrast using abnormal control flow set front and back are to test process and result's influence.The DTS test structure mainly comprises following content as shown in Figure 6:
Configuration file is used for determining the fault type of needs detection, and it can determine the quantity of abnormal patterns state machine; By analyzing the correlated variables in the source file, determine every kind of abnormal patterns state machine need create the quantity of example; 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 is determined to analyze order by the call relation between function between function, and the function of finishing for analysis is preserved 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 finished, need this example of operation to carry out state exchange.When carrying out interval arithmetic on each node of control stream, 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 using 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.From statistics as can be seen, total iterations of DTS (B) has on average increased by 2.85% than DTS (A), and the detection effect to the resource leakage fault is the average fault detect rate 14.95% that improves thus.
Table 3 test comparison data
Figure BSA00000143094600231
In addition, by 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 may be 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, represents 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 described 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 described subsequent control stream acquisition module is obtained is adjusted into current control stream, the consequent malfunction that described subsequent control stream fault detection module is obtained is adjusted into works as prior fault, and exports to described judge module;
The run-time exception extraction module, be used for described 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 those skilled in the art are 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 (8)

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 may be 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, represents 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, 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;
On step F, the subsequent control stream that obtains in described step e, 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 described step e is adjusted into current control stream, the consequent malfunction that obtains in the described 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.
2. method according to claim 1 is characterized in that, described 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.
3. method according to claim 1 is characterized in that, described step B specifically comprises:
B1, judge whether the node in the current control stream is its last node, then carries out described step C in this way, otherwise execution in step B2;
B2, judge the statement that whether exists in the present node of current control stream 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, replace present node, return step B 1 with the next node of node in the current control stream.
4. method according to claim 1 is characterized in that, described 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 is created and concrete variable correlation behavior machine example for analyzed unit, chooses one as current state machine example from all state machine instance;
C2, on the diverse location of control stream, for the variable in the current state machine example calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine example, 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 example, and if existed with next example as current example, return step C2, otherwise carry out described step D.
5. method according to claim 1 is characterized in that, described 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.
6. method according to claim 1 is characterized in that, described step F specifically comprises:
F1, initialization fault are concentrated the consequent malfunction when prior fault, and consequent malfunction is set to sky;
F2, be that analyzed unit is created and concrete variable correlation behavior machine example, from all state machine instance, choose one as current state machine example;
F3, on the diverse location of subsequent control stream, for the variable in the current state machine example calculates its possible value, and the bonding state switch condition carries out state exchange to current state machine example, 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 there is no, then this ordered pair are joined in the described consequent malfunction in back;
F5, judge in the state machine instance set whether have untreated example,, return step F 3 if exist then choose a untreated example as current example, otherwise execution in step G.
7. method according to claim 1 is characterized in that, described 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.
8. 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 may be 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, represents 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 described 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 described subsequent control stream acquisition module is obtained is adjusted into current control stream, the consequent malfunction that described subsequent control stream fault detection module is obtained is adjusted into works as prior fault, and exports to described judge module;
The run-time exception extraction module, be used for described 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.
CN2010101883761A 2010-06-01 2010-06-01 Method and system for testing software by using abnormal control flow set Expired - Fee Related CN101847122B (en)

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 true CN101847122A (en) 2010-09-29
CN101847122B 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)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103257913A (en) * 2013-04-18 2013-08-21 西安交通大学 System and method for detecting and removing fault of software in operation
CN104461886A (en) * 2014-12-10 2015-03-25 深圳航天东方红海特卫星有限公司 Control flow error detection method
CN107704332A (en) * 2017-09-28 2018-02-16 努比亚技术有限公司 Freeze screen solution method, mobile terminal and computer-readable recording medium
CN109446078A (en) * 2018-10-18 2019-03-08 网易(杭州)网络有限公司 Code test method and device, storage medium, electronic equipment
CN111061644A (en) * 2019-12-25 2020-04-24 南京大学 Method and device for detecting and positioning abnormal throwing processing defects
CN111831532A (en) * 2019-04-15 2020-10-27 富士通株式会社 Method for constructing test scene and information processing equipment
CN111966076A (en) * 2020-08-11 2020-11-20 广东工业大学 Fault positioning method based on finite-state machine and graph neural network
CN112069052A (en) * 2019-06-11 2020-12-11 腾讯科技(深圳)有限公司 Abnormal object detection method, device, equipment and storage medium
CN112527419A (en) * 2020-12-16 2021-03-19 Xc5香港有限公司 Finite state machine analysis method and system based on abstract model

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040078693A1 (en) * 2002-03-22 2004-04-22 Kellett Stephen Richard Software testing
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

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040078693A1 (en) * 2002-03-22 2004-04-22 Kellett Stephen Richard Software testing
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)

* Cited by examiner, † Cited by third party
Title
《计算机工程》 20090430 闫大顺等 一种分析异常传播路径的方法 50~52 1-8 第34卷, 第8期 2 *

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103257913A (en) * 2013-04-18 2013-08-21 西安交通大学 System and method for detecting and removing fault of software in operation
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
CN107704332A (en) * 2017-09-28 2018-02-16 努比亚技术有限公司 Freeze screen solution method, mobile terminal and computer-readable recording medium
CN107704332B (en) * 2017-09-28 2021-06-15 努比亚技术有限公司 Screen freezing solution method, mobile terminal and computer readable storage medium
CN109446078A (en) * 2018-10-18 2019-03-08 网易(杭州)网络有限公司 Code test method and device, storage medium, electronic equipment
CN111831532A (en) * 2019-04-15 2020-10-27 富士通株式会社 Method for constructing test scene and information processing equipment
CN112069052A (en) * 2019-06-11 2020-12-11 腾讯科技(深圳)有限公司 Abnormal object detection method, device, equipment and storage medium
CN112069052B (en) * 2019-06-11 2024-04-12 腾讯科技(深圳)有限公司 Abnormal object detection method, device, equipment and storage medium
CN111061644A (en) * 2019-12-25 2020-04-24 南京大学 Method and device for detecting and positioning abnormal throwing processing defects
CN111966076A (en) * 2020-08-11 2020-11-20 广东工业大学 Fault positioning method based on finite-state machine and graph neural network
CN112527419A (en) * 2020-12-16 2021-03-19 Xc5香港有限公司 Finite state machine analysis method and system based on abstract model
CN112527419B (en) * 2020-12-16 2024-04-19 深圳知释网络技术有限公司 Finite state machine analysis method and system based on abstract model

Also Published As

Publication number Publication date
CN101847122B (en) 2012-05-02

Similar Documents

Publication Publication Date Title
CN101847122B (en) Method and system for testing software by using abnormal control flow set
Iosif Symmetry reduction criteria for software model checking
CN102521117B (en) Java exception propagation static structure extraction method
CN102110048A (en) Regression testing selection method and device for frame-based application program
CN102368226A (en) Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine)
Lin et al. Fib: Squeezing loop invariants by interpolation between forward/backward predicate transformers
Abbas et al. Efficient phase II monitoring methods for linear profiles under the random effect model
Rosner et al. Ranger: Parallel analysis of Alloy models by range partitioning
Szpyrka et al. Formal description of Alvis language with α 0 system layer
Gupta et al. Design pattern mining using state space representation of graph matching
Wu et al. Regression testing on object-oriented programs
Endo et al. Web services composition testing: a strategy based on structural testing of parallel programs
Mahajan et al. Component-based software system test case prioritization with genetic algorithm decoding technique using java platform
CN106095608A (en) Sequential test dynamic adjusting method based on AO* algorithm
CN108768748B (en) Fault diagnosis method and device for power communication service and storage medium
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
Jaghoori et al. Efficient symmetry reduction for an actor-based model
Bernardi et al. Testing aspect oriented programs: an approach based on the coverage of the interactions among advices and methods
Xi et al. An approach of coarse-grained dynamic slice for Java program
Weston et al. Interaction analysis for fault-tolerance in aspect-oriented programming
Miao et al. A formal specification-based integration testing approach
Montenegro et al. A space consumption analysis by abstract interpretation
Kutten et al. Fast and compact distributed verification and self-stabilization of a DFS tree
de Souza Carvalho et al. Coverage criteria for state transition testing and model checker-based test case generation

Legal Events

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

Granted publication date: 20120502

Termination date: 20180601