The content of the invention
The technical problems to be solved by the invention are the defects of being directed to background technology, there is provided a kind of evolution accident analysis artwork
Type (Evolution Fault Analysis Graph Model, EFAGM), related forward direction is changed by structural evolution and relied on
Element, backward dependence element and its static state and the dynamic effects factor are asked to analyze the accident analysis as caused by being changed program evolution
Topic.
The present invention uses following technical scheme to solve above-mentioned technical problem:
A kind of software evolution process failure analysis methods, comprise the following steps:
Step 1, use AST analyzers, the intermediate representation evolution accident analysis graph model of structural evolution modification program
EFAGM abstract syntax tree EFAGM_AST;
Wherein, the evolution accident analysis graph model EFAGM is two tuples<CINode,CDEdge>, wherein,
CINode influences set of node for modification, and CDEdge is modification dependence edge collection;
Step 2, based on develop change, in initial EVOLUTION ANALYSIS graph model EFAGM add node by way of, really
Vertical EFAGM crucial modification set of node;The crucial modification nodal informations of EFAGM are then based on, successively before structure modification set of node
Node and path are influenceed to backward;
Step 3, the domain according to calculating EFAGM node of graph, EFAGM static factor of influence and the dynamic effects factor are generated,
Complete evolution accident analysis graph model EFAGM structure;When failure occurs, realized using EFAGM and program evolution modification is drawn
The accident analysis risen.
Further, a kind of software evolution process failure analysis methods of the invention, in step 1, the modification influences section
Point set CINode include common node BlockNode, IfNode, SwitchNode, WhileNode, DoNode, ForNode,
BreakNode, ContinueNode, ReturnNode, InvocationNode, MethodNode, wherein, BlockNode is
Sequential node, IFNode are conditional branching node, and SwitchNode is switch branch node, and WhileNode is While repetends
Point, DoNode are Do cyclic nodes, and ForNode is For cyclic nodes, and BreakNode is Break sentence nodes,
ContinueNode is Continue sentence nodes, and ReturnNode is Return sentence nodes, and InvocationNode is side
Method call statement node, MethodNode are called method node;
The modification dependence edge collection CDEdge=DCDEdge ∪ ICDEdge ∪ DDDEdge ∪ IDDEdge, wherein,
DCDEdge is direct control dependence edge collection, and ICDEdge is indirect control dependence edge collection, and DDDEdge is immediate data dependence edge
Collection, IDDEdge is indirect data dependence edge collection;
The domain of EFAGM node of graph, including:
(1) ID domains:The ID marks on the node or the mark on side influenceed for modification of developing, node or side are unique;
(2) Position domains:The position of corresponding diagram node elements in a program;
(3) ParentNodeLink domains:The father node chain domain of present node, for linking the father node of present node, just
Traveled through in the forward direction of EFAGM figures;If if present node variable uses be present and influenceed by multiple node variable definition or simultaneously by
Influenceed to forward data and control, then ParentNodeLink is linked into multiple father nodes, otherwise only link a father node;When
If variable uses be present and influenceed by multiple node variable definition or influenceed by forward data and control in front nodal point simultaneously,
ParentNodeLink links multiple father nodes, otherwise links a node;
(4) ChildNodeLink domains:The child nodes chain domain of present node, for linking the child nodes of present node,
It is easy to the backward traversal of EFAGM figures;For IfNode, SwitchNode, WhileNode, DoNode, ForNode,
The ChildNodeLink domains of the condition judgment sentence of MethodNode types, if or present node variable-definition or fixed be present
It is worth and influences the use of multiple nodes, then links multiple child nodes;Otherwise a child nodes are only linked;
(5) ChangeNum, AveDistance domain:Influence the number of the modification node of present node, with changing node
Minimum range, make m1,m2...,mnFor n in the present node and program distance for changing node, then AveDistance=(m1+m2
+…+mn)/n;
(6) StaticWeight domains:The probability that the present node that static analysis is drawn breaks down, its calculation formula areWherein m represents to influence ActiveNode ChangeNum domains, i (i
=1,2,3 ..., m) it is influence of the regulation conflict number to weight;When evolution modification causes failure, the failure of present node is general
Rate follows:
A) nearer with modification nodal distance, the probability to break down is higher;
B) the modification interstitial content being affected is more, and the probability to break down is higher;
C) node is changed as the increase of number, its influence power are gradually reduced;
(7) DynamicWeight domains:The probability to be broken down for the present node that dynamic analysis are drawn, it calculates public
Formula is:
Wherein, s is with foretelling afoul test number according to test history information, and k (k=1,2,3 ..., s) is regulation
Influence of the number that conflicts to weight, t are according to the test history information test number consistent with foretelling, j (j=1,2,3 .., t)
It is influence of the consistent number of regulation to weight, γ is regulatory factor;When evolution modification causes failure, the failure of present node is general
Rate follows:
A) more by the failure testing use-case of present node, the probability to break down is higher;
B) more by the successful test case of present node, the probability to break down is smaller;
C) increasing with failure testing use-case number, the probability analysis that failure occurs failure testing use-case influence to get over
It is small;
D) increasing with failure testing use-case number, the probability analysis that failure occurs success test case influence to get over
It is small.
Further, a kind of software evolution process failure analysis methods of the invention, based on modification of developing in step 2, really
Vertical key changes set of node:When initial, only included in EFAGM models n develop modification node cNode1 ...,
cNoden;ID and Position thresholdings are set in EFAGM figures while a node is added, set while a line is created
Put ParentNodeLink and ChildNodeLink thresholdings;When realizing, call method ast.creatAST (replace) is raw
Into source program replace EFAGM_AST code trees, and return to root node.
Further, a kind of software evolution process failure analysis methods of the invention, structure modification successively described in step 2
The forward and backward of set of node influences node and path;Specially:
2.1) judge to develop based on cNode1.getNodeType () method and change node cNode1 node type, construction
CNode1 forward direction control node, forward data node and related dependant side;The modification of present node, which can cause, controls its section
The renewal of point, meanwhile, the variable modification that present node uses can cause the consistency check of variable-definition or definite value node;
2.2) structural evolution modification node cNode1 backward control node, backward back end and related dependant side;When
For front nodal point if control node, its modification can influence the execution of all nodes in control block;If defined in present node or fixed
Be worth variable, then it is all to concentrate the node of variable to be all affected using definition or definite value;
2.3) repeat 2.1)~2.2), creating other modifications node cNode2 to cNoden forward directions influences node and backward
Influence node, and all nodes not being added in EFAGM be added thereto, create DCDEdge, ICDEdge, DDDEdge,
IDDEdge。
Further, a kind of software evolution process failure analysis methods of the invention, step 3 are specially:
3.1) the ChangeNum domains and AveDistance domains of each node in EFAGM figures are updated;The present node is made to be
ActiveNode, ChangeNum value are that ActiveNode is reachable according to ParentNodeLink domains or ChildNodeLink domains
Change node number;AveDistance calculating is in two steps:First, ActiveNode is calculated to each up to modification node i (i
=1,2,3 ..., m) minimum range mini, AveDistance is then calculated, calculation formula is
Wherein, m is ChangeNum values;
3.2) StaticWeight of each node in EFAGM figures is calculated according to ChangeNum domains and AveDistance domains
Value;It is ActiveNode to make present node, then calculation formula is:Wherein m
Influence ActiveNode ChangeNum domains are represented, i (i=1,2,3 ..., m) is represented up to modification node, on EFAGM figures
Show as it is positive or reverse reachable,Representing that the modification node of the influence to ActiveNode is more, then influence power is bigger,
And increase with the modification node of influence, influence power gradually reduces,Represent that AveDistance is bigger, drill
It is smaller on ActiveNode influences to change modification node, and because AveDistance is less than modification to ActiveNode influence powers
The influence power of node number, AveDistance influence power is limited in (0,1] between, i.e.,
According to calculation formula, impacted modification interstitial content is more, then StaticWeight is bigger, impacted modification interstitial content
It is identical, and distance is nearer, StaticWeight is bigger, when evolution modification causes failure, according to StaticWeight size
Order is investigated to failure;
3.3) DynamicWeight is calculated according to test history information, if Test Oracle still have after modification of developing
Effect, the probability of evolution failure is more accurately calculated by whether failing for test run, its calculation formula is:
Wherein, s is with foretelling afoul test number according to test history information, and k (k=1,2,3 ..., s) is regulation
Influence of the number that conflicts to weight, t are according to the test history information test number consistent with foretelling, j (j=1,2,3 .., t)
It is influence of the consistent number of regulation to weight, γ is regulatory factor;Represent k-th of conflict influence of the test number to weight because
Son, with the increase of test number, test the influence to weight and constantly reduce,γ∈ [0,0.5] is regulatory factor, its size by
Test case scale determines, as the larger (s+t of test case>10000) when, we, which give tacit consent to, takes γ=0.5, works as k>10000
When,Its influence to weight is ignored, as the small (s+t of test case<=10000) when, by test to power
The influence of weight, which constantly reduces, ignores, even γ=0, so, all tests are 1 to the factor of influence of weight;
3.4) complete EFAGM structure, when failure occurs, according to EFAGM node elements relation and StaticWeight,
DynamicWeight threshold levels determine the root of failure.
Further, a kind of software evolution process failure analysis methods of the invention, step 2.1) comprise the following steps that:
2.1.1) node cNode1 forerunner control node ParentVertex1 is changed in extraction evolution on EFAGM_AST,
ParentVertex1 node type have IfNode, SwitchNode, WhileNode, DoNode, ForNode,
MethodNode, add in ParentVertex1 to EFAGM figures, update cNode1 ParentNodeLink domains, in order to
EFAGM traversing operation, and create and directly control dependence edge DCDEdge (ParentVertex1, cNode1), cNode1's repaiies
ParentVertex1 modification inspection can be caused by changing;
2.1.2 ParentVertex1 direct precursor control node ParentVertex2) is extracted, is added to EFAGM figures
In, ParentVertex1 ParentNodeLink domains are set, and create indirect control dependence edge ICDEdge
(ParentVertex2, ParentVertex1);If because node cNode1 modification causes the generation of failure, then section
The cNode1 dubieties of point are greater than node ParentVertex1, the ParentVertex1 dubieties of node are greater than node
ParentVertex2;
2.1.3 2.1.2) is repeated), create all indirect controls and rely on nodes and corresponding edge, continuous influence of fluctuations, until
The node elements of correlation are included;
2.1.4 the expression formula in cNode1) is extracted according to cNode1.getExpression () method, and generates expression formula
Variable uses collection v_use, based on EFAGM_AST, add direct precursor definition or the definite value node of all variables in v_use
In Vertex3 to EFAGM, and create data dependence side DDDEdge (Vertex3, cNode1);
2.1.5 expression formula variables set v1 in Vertex3) is generated, based on EFAGM_AST, all variables is straight in addition v1
Connect in predecessor node Vertex4 to EFAGM, and create data dependence side IDDEdge (Vertex4, Vertex3);
2.1.6 2.1.5) is repeated), create all indirect datas and rely on node and corresponding edge, while need continuous logarithm
According to type and data value synchronized update inspection, until the original definition of data type terminates;
2.1.7) if node type is WhileNode, DoNode, ForNode, the direct precursor data of these nodes
Node and control node except the control variable definite value node among the node before natural order, in addition to node control block and
Node is redirected, it is Vertex5 to make controlling variable definite value or redirecting node in WhileBlock, DoBlock, ForBlock, is added
Enter in Vertex5 to EFAGM, and create dependence edge DCDEdge (Vertex5, cNode1);
2.1.8) if node type is MethodNode, its direct precursor node is the language for calling the MethodNode
Literal point, MethodNode modification can cause corresponding CallVertex synchronized update, based on EFAGM_AST, add and adjust
With node CallVertex, and create dependence edge DCDEdge (CallVertex, cNode1).
Further, a kind of software evolution process failure analysis methods of the invention, step 2.2) comprise the following steps that:
2.2.1) if the modification node cNode1 node types that develop be IfNode, SwitchNode, WhileNode,
DoNode, ForNode, MethodNode, the then modification of these nodes can cause whether the sequential node in statement block performs, point
Chuan Jian not condition joint block IFBlock, branch node block SwitchCase, While cyclic node block WhileBlock, Do circulation
Order under joint block DoBlock, For cyclic node block ForBlock, called method joint block MethodBlock statement blocks
Node Vertex1, and create and directly control dependence edge DCDEdge (cNode1, Vertex1);
2.2.2) if Vertex1 node types be IfNode, SwitchNode, WhileNode, DoNode,
ForNode, MethodNode, be respectively created IFBlock, SwitchCase, WhileBlock, DoBlock, ForBlock,
Sentence node Vertex2 under MethodBlock, and create indirect control dependence edge ICDEdge (Vertex1, Vertex2);
2.2.3 2.2.2) is repeated) all indirect controls dependence nodes and dependence edge are created, change and constantly propagate, until
Untill common sentence node BlockNode;
2.2.4 the expression formula in cNode1) is extracted according to cNode1.getExpression () method, and generates expression formula
Variable-definition collection v_def, based on EFAGM_AST, the immediate successor for adding all variables in v_def uses node Vertex3
Into EFAGM, and create data dependence side DDDEdge (cNode1, Vertex3);
2.2.5 expression formula variable-definition collection v_def1 in Vertex3) is generated, based on EFAGM_AST, is added in v_def1
In immediate successor reference node Vertex4 to the EFAGM of all variables, and create data dependence side IDDEdge (Vertex3,
Vertex4);
2.2.6 2.2.5) is repeated), create all indirect datas and rely on node and corresponding edge, until not new variable
Untill definite value and modification;
2.2.7) if node type is ReturnNode, this node control returns to method, travels through EFAGM_AST,
The node Vertex5 of method where adding calling ReturnNode nodes, establishment data dependence side DDDEdge (cNode1,
Vertex5);
2.2.8) if node type is BreakNode, EFAGM_AST is traveled through,
If the sentence node in WhileNode, DoNode, ForNode where cNode1 is Vertex6,
BreakNode modification directly decides whether Vertex6 performs, and creates control dependence edge DCD (cNode1, Vertex6);Together
When, the follow-up sentence of the BreakNode in WhileBlock, DoBlock, ForBlock also directly by BreakNode,
ContinueNode control, EFAGM_AST is traveled through, it is Vertex7 to make follow-up sentence, adds Vertex7 nodes to EFAGM
In, and create (cNode1, Vertex7);
It is next in cNode in BreakNode control statement blocks if the statement block where cNode1 is SwitchCase
Sentence before BreakNode, EFAGM_AST is traveled through, make the follow-up sentence for the cNode1 that Vertex8 is place statement block arrive down
Sentence before one BreakNode, create DCD (cNode1, Vertex8);
2.2.9) if node type is ContinueNode, EFAGM_AST is traveled through, if where cNode1
Sentence node in WhileNode, DoNode, ForNode is Vertex9, then ContinueNode modification directly decides
Vertex9 execution is redirected, creates control dependence edge DCD (cNode1, Vertex9);Meanwhile WhileBlock, DoBlock,
Whether the performing for follow-up sentence of ContinueNode in ForBlock is also controlled by ContinueNode, travels through EFAGM_
AST, it is Vertex10 to make follow-up sentence, adds Vertex10 nodes into EFAGM, and create (cNode1, Vertex10);
2.2.10) if node type is InvocationNode, EFAGM_AST is traveled through, makes the call method node be
Vertex11, add Vertex11 to EFAGM in, and create control dependence edge and data dependence edge DCD (cNode1,
Vertex11);
2.2.11) influence and control to influence node as new analysis node using cNode1 immediate data, create 2.2.7)~
2.2.10 all indirect datas of cNode1) influence and control control influences node, and create side IDDEdge, ICDEdge, directly
Untill not new node and side add.
The present invention uses above technical scheme, compared with prior art, has following technique effect:
The model of the present invention can carry out more effective more accurate point than traditional program graph model to the modification failure that develops
Analysis.It is embodied in:(1), can be with when causing software fault due to the evolutions such as software upgrading, iterative development, defect correction modification
The efficiently analysis model of structure evolution failure relevant portion, and reduce the scale of analysis;(2) by setting weight (to influence
The factor) more efficient analysis is provided for failure relevant portion, even if when evolution modification causes Test oracles to fail, the present invention
In static factor of influence can still provide for efficiently analyzing;(3) evolution fault analysis model EFAGM intuitively gives software event
Hinder the relation between element, be advantageous to being analyzed to identify for fault rootstock.
Embodiment
Technical scheme is further explained in detail below in conjunction with the accompanying drawings, those skilled in the art of the present technique can be with
Understand, unless otherwise defined, all terms (including technical term and scientific terminology) used herein have and the present invention
The general understanding identical meaning of those of ordinary skill in art.It is it should also be understood that fixed in such as general dictionary
Those terms of justice should be understood that there is the meaning consistent with the meaning in the context of prior art, and unless as this
In equally define, will not be explained with the implication of idealization or overly formal.
A kind of intermediate representations of the AST (Abstract Syntax Tree, abstract syntax tree) as program, in program
The numerous areas such as analysis are widely used, and a variety of source program handling implements can be conveniently realized using abstract syntax tree.Take out
As the syntax of the structure independent of original language of syntax tree, that is, context-free grammar used by the syntactic analysis phase,
Syntactic analysis tree is independently constructed, a clearly interface is established for front and back ends.The structure base first of EFAGM models of the present invention
Parsed in AST, generate the EFAGM_AST trees of Evolution Programs;Changed based on developing, establish crucial modification set of node;Then successively
The forward and backward of structure modification set of node influences node and path, and generates static factor of influence and the dynamic effects factor.Such as
Shown in Fig. 1.
First, EFAGM model definitions:
EFAGM is two tuples<CINode,CDEdge>.Wherein, CINode influences set of node for modification, and CDEdge is
Change dependence edge collection.CINode sets of node include common node BlockNode, IfNode, SwitchNode, WhileNode,
DoNode, ForNode, BreakNode, ContinueNode, ReturnNode, InvocationNode, MethodNode etc..
CDEdge=DCDEdge ∪ ICDEdge ∪ DDDEdge ∪ IDDEdge, wherein, DCDEdge is direct control dependence edge collection,
ICDEdge is indirect control dependence edge collection, and DDDEdge is immediate data dependence edge collection, and IDDEdge is indirect data dependence edge
Collection.Node of graph mainly includes<ID>、<Position>、<ParentNodeLink>、<ChildNodeLink>、<ChangeNum
>、<AveDistance>、<StaticWeight>、<DynamicWeight>Deng domain, wherein,
(1) ID domains:The node or the mark on side that modification of developing influences.Node or the ID on side marks are unique.
(2) Position domains:The position of node of graph element in a program.
(3) ParentNodeLink domains:The father node chain domain of present node, links the father node of present node, is easy to
The forward direction traversal of EFAGM figures.If there are variable uses and influenceed or simultaneously by preceding by multiple node variable definition in present node
Influenceed to data and control, ParentNodeLink links multiple father nodes, otherwise links a node.
(4) ChildNodeLink domains:The child nodes chain domain of present node, links the child nodes of present node, is easy to
The backward traversal of EFAGM figures.For IfNode, SwitchNode, WhileNode, DoNode, ForNode, MethodNode etc.
The ChildNodeLink domains of condition judgment sentence link multiple child nodes;If there is variable-definition or definite value simultaneously in present node
The use of multiple nodes is influenceed, ChildNodeLink domains also link multiple child nodes;Otherwise, ChildNodeLink domains chain
Connect a child nodes.
(5) ChangeNum, AveDistance domain:Influence the number of the modification node of present node, with changing node
Minimum range.Make m1,m2...,mnFor n in the present node and program distance for changing node, then AveDistance=(m1+m2
+…+mn)/n。
(6) StaticWeight domains:The probability that the present node that static analysis is drawn breaks down, its calculation formula areWherein m represents to influence ActiveNode ChangeNum domains, i (i
=1,2,3 ..., m) represent up to modification node.When evolution modification causes failure, the probability of malfunction of present node follows:
A) nearer with modification nodal distance, the probability to break down is higher;
B) the modification interstitial content being affected is more, and the probability to break down is higher;
C) node is changed as the increase of number, its influence power are gradually reduced.
(7) DynamicWeight domains:The probability that the present node that dynamic analysis are drawn breaks down, its calculation formula areWherein, s is according to test history information and foretells afoul test number,
K (k=1,2,3 ..., s) is influence of the regulation conflict number to weight, and t is according to the survey consistent with foretelling of test history information
Number is tried, j (j=1,2,3 .., t) is influence of the consistent number of regulation to weight, and γ is regulatory factor.Evolution modification causes event
During barrier, the probability of malfunction of present node follows:
A) more by the failure testing use-case of present node, the probability to break down is higher;
B) more by the successful test case of present node, the probability to break down is smaller;
C) increasing with failure testing use-case number, the probability analysis that failure occurs failure testing use-case influence to get over
It is small;
D) increasing with failure testing use-case number, the probability analysis that failure occurs success test case influence to get over
It is small.2nd, EFAGM model building methods
We combine an instantiation to illustrate EFAGM constitution step, example procedure source west gate subprogram below
Open Source Code replace, its function are that pattern is replaced.
1) using the intermediate representation evolution accident analysis graph model EFAGM of AST analyzers structural evolution modification program
Abstract syntax tree EFAGM_AST.When initial, only included in EFAGM models n develop modification node cNode1 ...,
cNoden.ID and Position thresholdings are set in EFAGM figures while a node is added, set while a line is created
Put ParentNodeLink and ChildNodeLink thresholdings.When realizing, call method ast.creatAST (replace) is raw
Into source program replace EFAGM_AST code trees, and return to root node.For purposes of illustration only, it is following we respectively according to node
Type changes node to set to develop.
2) judge to develop based on cNode1.getNodeType () method and change node cNode1 node type, construction
CNode1 forward direction control node, forward data node and related dependant side.The modification of present node, which can cause, controls its section
The renewal of point, meanwhile, the variable modification that present node uses can cause the consistency check of variable-definition or definite value node.Fig. 2
It is the preceding general construction flow to control node, Fig. 3 is the general construction flow of forward data node.Comprise the following steps that:
A), node cNode1 forerunner control node ParentVertex1 is changed in extraction evolution on EFAGM_AST,
ParentVertex1 node type have IfNode, SwitchNode, WhileNode, DoNode, ForNode,
MethodNode etc., add in ParentVertex1 to EFAGM figures, update cNode1 ParentNodeLink domains, in order to
EFAGM traversal etc. operates, and adds and directly control dependence edge DCDEdge (ParentVertex1, cNode1).To keep one
Cause property, cNode1 modification can cause ParentVertex1 modification inspection.If for example, be modified to sentence 13, that
Grammer for holding program or uniformity semantically are, it is necessary to inspection of being modified to its in-line control statement 11.According to repairing
Change sentence 13, EFAGM can find the related direct precursor control statement 13 of modification.
B), it is same a), extract ParentVertex1 direct precursor control node ParentVertex2, be added to EFAGM
In figure, ParentVertex1 ParentNodeLink domains are set, and create indirect control dependence edge ICDEdge
(ParentVertex2, ParentVertex1).Such as:A) in step, sentence 11 it is direct control predecessor node be 9, for protect
Uniformity is held, the modification of node 13 causes the modification inspection of node 11, and the modification of node 11 checks and causes control node 9
Modification.Here, if because the modification of node 13 causes the generation of failure, then the dubiety of node 13 is greater than node
11.We are formulated to this below.
C), repeat b), to create all indirect controls and rely on node and corresponding edge.As above, node 13 arrives node 11, node 11
To the continuous influence of fluctuations of node 9 ..., EFAGM need to include the node elements of correlation.
D) expression formula in cNode1, is extracted according to cNode1.getExpression () method, and generates expression formula change
Amount based on EFAGM_AST, adds direct precursor definition or the definite value node of all variables in v_use using collection v_use
In Vertex3 to EFAGM, and create data dependence side DDDEdge (Vertex3, cNode1).For example, if modification node is
Sentence 16, then expression formula is using integrating as v_use={ i }, and the direct precursor definite value node to variable i in v_use is sentence 8, language
The modification of sentence 16 may cause the synchronized update of sentence 8, and therefore, EFAGM includes sentence 8 wherein, and establishes side (8,16).
E), same to d) to generate expression formula variables set v1 in Vertex3, based on EFAGM_AST, all variables is straight in addition v1
Connect in predecessor node Vertex4 to EFAGM, and create data dependence side IDDEdge (Vertex4, Vertex3).D) sentence 8 in
Direct precursor be defined as sentence 6, the modification of sentence 8 can cause type definition of the sentence 6 to variable i, and therefore, EFAGM should be wrapped
Sentence 6 is included, and establishes side (6,8).
F), repeat e), to create all indirect datas and rely on node and corresponding edge.In as above example, node statement 16 arrives
Node statement 8, then needed to node statement 6 ... constantly to data type and data value synchronized update inspection, until data
The original definition of type terminates.
G), if node type is WhileNode, DoNode, ForNode, the direct precursor data section of these nodes
Point and control node are except the control variable definite value node among the node before natural order, in addition to node control block and jump
Trochanterion (continue, break, the last item sentence of control block), makes in WhileBlock, DoBlock, ForBlock
It is Vertex5 to control variable definite value or redirect node, is added in Vertex5 to EFAGM, and create dependence edge DCDEdge
(Vertex5, cNode1).If for example, node 23 is modified, then its forward direction node is except the section of natural order
Outside point 21,22, it should also include node 25, side (25,23) are both DDDEdge, and DCDEdge.
If h), node type is MethodNode, its direct precursor node is the sentence for calling the MethodNode
Node, MethodNode modification can generally cause corresponding CallVertex synchronized update.Based on EFAGM_AST, add
Enter to call node CallVertex, and create dependence edge DCDEdge (CallVertex, cNode1).If for example, to node 5
It is modified, then node 24 will be updated accordingly, with being consistent property.
3) cNode1 backward control node, backward back end and related dependant side is constructed.Present node is if control
Node, its modification can influence the execution of all nodes in control block;If definition or definite value variable, own in present node
The node of variable is concentrated all to be affected using definition or definite value.Fig. 4 is the general construction flow of backward control node, figure
5 be the general construction flow of backward back end.Comprise the following steps that:
If a), node type be IfNode, SwitchNode, WhileNode, DoNode, ForNode,
MethodNode, the then modification of these nodes can cause whether the sequential node in statement block performs, condition node are respectively created
Block IFBlock, branch node block SwitchCase, While cyclic node block WhileBlock, Do cyclic node block DoBlock,
Sequential node Vertex1 under For cyclic node blocks ForBlock, called method joint block MethodBlock statement blocks, and
Create and directly control dependence edge DCDEdge (cNode1, Vertex1).For example, the modification to sentence 9, can cause 10,11,14
The change of execution, therefore EFAGM needs to add interdependent node 10,11,14, and create side (9,10), (9,11), (9,14).
If b), same to a) Vertex1 node types be IfNode, SwitchNode, WhileNode, DoNode,
ForNode, MethodNode, be respectively created IFBlock, SwitchCase, WhileBlock, DoBlock, ForBlock,
Sentence node Vertex2 under MethodBlock, and create indirect control dependence edge ICDEdge (Vertex1, Vertex2).
In a), the modification of sentence 9 can influence sentence 11, and sentence 11 is IfNode, influences the sentence node 12,13 under IfBlook,
Therefore addition node 12 is needed, 13, and create side (11,12), (11,13).Instinctively, the original modified of sentence 9 is influenceed to language
The influence of sentence 12,13 weakens.
C), repeat b) to create all indirect controls dependence nodes and dependence edge.By sentence 9 to sentence 11, by 11 to 12,
13, change and constantly propagate, untill common sentence node BlockNode.
D) expression formula in cNode1, is extracted according to cNode1.getExpression () method, and generates expression formula change
Amount definition collection v_def, if the variable in v_def is changed, the subsequently reference to variable can all be affected.It is based on
EFAGM_AST, the immediate successor for adding all variables in v_def is used in node Vertex3 to EFAGM, and creates data
Dependence edge DDDEdge (cNode1, Vertex3).Sentence in example procedure 20, which is modified, can directly influence sentence 22,
Therefore EFAGM adds sentence 22, and creates side (20,22).
E) it is, same to d) to generate expression formula variable-definition collection v_def1 in Vertex3, due to cNode1 modification, in v_def1
The definite values of all variables change.Based on EFAGM_AST, the immediate successor reference node of all variables in v_def1 is added
In Vertex4 to EFAGM, and create data dependence side IDDEdge (Vertex3, Vertex4).D) in, by definite value in sentence 22
Node be result, result value is influenceed by variable line, it is necessary to which the sentence for quoting result nodes is added to
In EFAGM, such as sentence 23, and side (22,23) is created.It should be noted that in this example, the modification of line variables is also right
Formal parameter s has carried out definite value in getline functions, and the creation method on this side is illustrated in j) for we.
F), repeat e), to create all indirect datas and rely on node and corresponding edge.Variable is had influence on from the modification of sentence 20
Line definition, variable line definition and the modification of value have influence on the definite value of result in sentence 22, and result value influences
Circulation to 23 performs ... and so on, untill the definite value of not new variable and modification.
If g), node type is ReturnNode, this node control returns to method, travels through EFAGM_AST, adds
The node Vertex5 of method where calling ReturnNode nodes, establishment data dependence side DDDEdge (cNode1,
Vertex5).For example, if modification element is sentence 4, sentence 4 returns to boolean's offset, and the method where sentence 4 is
Getline, getline method change is called, by traveling through EFAGM_AST, find the sentence 25 for calling getline, language
Return value has been assigned to result by sentence 25, therefore creates data dependence side (4,25).
If h), node type is that BreakNode travels through EFAGM_AST, if WhileNode where cNode1,
Sentence node in DoNode, ForNode is Vertex6, then BreakNode modification directly decides whether Vertex6 holds
OK, control dependence edge DCD (cNode1, Vertex6) is created.Meanwhile in WhileBlock, DoBlock, ForBlock
BreakNode follow-up sentence is also directly controlled by BreakNode, ContinueNode, travels through EFAGM_AST, and order is follow-up
Sentence is Vertex7, adds Vertex7 nodes into EFAGM, and create (cNode1, Vertex7).If where cNode1
Statement block is SwitchCase, then the sentence in BreakNode control statements block in cNode before next BreakNode, time
EFAGM_AST is gone through, makes the language before the follow-up sentence to next BreakNode for the cNode1 that Vertex8 is place statement block
Sentence, create DCD (cNode1, Vertex8).By taking WhileNode as an example, if we increase by one after example procedure sentence 13
Sentence 13 ' is " break;", if then 13 ' gone to, sentence 9 no longer will be performed, therefore 13 ' this increase modification influences
Sentence 9, create DCD (13 ', 9), meanwhile, if 13 ' perform 14~18) sentence directly skips, therefore create DCD (13 ',
14)、DCD(13’,15)、DCD(13’,16)、DCD(13’,17)、DCD(13’,18)。
If i), node type is ContinueNode, it is similar h) in BreakNode, travel through EFAGM_AST, if
Sentence node in WhileNode, DoNode, ForNode where cNode1 is Vertex9, then ContinueNode is repaiied
Change and directly decide the execution for redirecting Vertex9, create control dependence edge DCD (cNode1, Vertex9).Meanwhile
The execution of the follow-up sentence of ContinueNode in WhileBlock, DoBlock, ForBlock whether also by
ContinueNode control, EFAGM_AST is traveled through, it is Vertex10 to make follow-up sentence, adds Vertex10 nodes to EFAGM
In, and create (cNode1, Vertex10).Similar h) example, if increased 13 ' be " continue;", if then 13 ' held
Row arrives, then jumps directly to sentence 9, therefore 13 ' this increase modification have impact on sentence 9, create DCD (13 ', 9), similarly,
If 13 ' perform, 14~18) sentence this circulation no longer will be performed, thus establishment DCD (13 ', 14), DCD (13 ', 15),
DCD(13’,16)、DCD(13’,17)、DCD(13’,18)。
If j), node type is InvocationNode, cNode1 not only controls the method node of calling, simultaneously meeting
Data transfer is carried out to method node.This is that public side is shifted in a data transmission and control.Because not influenceing EVOLUTION ANALYSIS, we
To control side DCDEdge to represent transitive relation.EFAGM_AST is traveled through, it is Vertex11 to make call method node, is added
In Vertex11 to EFAGM, and create control dependence edge and data dependence edge DCD (cNode1, Vertex11).For example, to language
The modification of sentence 25 influences whether that the method getline's of sentence 1 redirects transfer, and has influence on parameter * s and maxsize in sentence 1
Data transfer, add sentence 1 and arrive EFAGM, create control and rely on and the public side of data dependence (25,1).
K), similar to b), d), using cNode1 immediate data influence and influence node is controlled to be created g) as new analysis node
~j) all indirect datas of cNode1 influence and control control influences node, and side IDDEdge, ICDEdge are created, until not having
Untill having new node and side addition.By taking the above-mentioned modification to 25 as an example, 25 modification influences whether sentence node 1, sentence section
Point 1 can control influence 2, and 3,4, continuous Wave transmission (influenceing less and less), untill not new node and side add.
4) repeat 2)~3), create other modifications node cNode2 to cNoden forward direction synchronized update node and it is backward together
Step influences node, and all nodes not being added in EFAGM is added thereto, create DCDEdge, ICDEdge, DDDEdge,
IDDEdge。
5) the ChangeNum domains and AveDistance domains of each node in EFAGM figures are updated.The present node is made to be
ActiveNode, ChangeNum value are that ActiveNode is reachable according to ParentNodeLink domains or ChildNodeLink domains
Change node number.AveDistance calculating is in two steps:First, ActiveNode is calculated to each up to modification node i (i
=1,2,3 ..., m) minimum range mini, because there may be mulitpath reaches modification node;Then calculate
AveDistance, calculation formula areWherein, m is ChangeNum values, and i is regulation conflict number pair
The influence of weight.For example, if modification node is 16 and 24, when prosthomere is 8, according to above-mentioned rule step, path 24 → 5 be present
→ 6 → 8,24 → 5 → 8,8 → 16,8 → 9 → 14 → 16.Because 8 pass through ParentNodeLink domains or ChildNodeLink domains
Up to modification node 16,24, so ChangeNum=2.Two paths, shortest path 24 between present node 8 to 24 be present
→ 5 → 8, minimum range min1=2;Shortest path between node 8 to 16 is 8 → 16, minimum range min2=1,
AveDistance=(2+1)/2=1.5.
6) StaticWeight of each node in EFAGM figures is calculated according to ChangeNum domains and AveDistance domains
Value.It is ActiveNode to make present node, then calculation formula is:Wherein m
Influence ActiveNode ChangeNum domains are represented, i (i=1,2,3 ..., m) is represented up to modification node, on EFAGM figures
Show as positive or reverse reachable.Representing that the modification node of the influence to ActiveNode is more, then influence power is bigger,
And increase with the modification node of influence, influence power gradually reduces,Represent that AveDistance is bigger, drill
It is smaller on ActiveNode influences to change modification node, and because AveDistance is less than modification to ActiveNode influence powers
The influence power of node number, we AveDistance influence power is limited in (0,1] between, i.e.,For example, same step 5), modification node is 16 and 24, when prosthomere is 8, according to the meter of step 5)
Calculate, m=2, AveDistance=1.5, then StaticWeight=1+1/2+1/ (1.5+1)=1.9;If only one is repaiied
Change node 16, present node is still 8, then according to above-mentioned computational methods, m=1, AveDistance=1, StaticWeight=1
+ 1/ (1+1)=1.5;If only one modification node 24, present node is still 8, then StaticWeight=1+1/ (1+2)
≈1.33.Understand, impacted modification interstitial content is more, then StaticWeight is bigger, impacted modification interstitial content
It is identical, and distance is nearer, StaticWeight is bigger, can be according to the big of StaticWeight when evolution modification causes failure
Small order is investigated to failure.
7) DynamicWeight is calculated according to test history information.If Test Oracle still have after modification of developing
Effect, the probability of evolution failure can be more accurately calculated by whether failing for test run.Its calculation formula is:
Wherein, s is with foretelling afoul test number according to test history information, and k (k=1,2,3 ..., s) is regulation
Influence of the number that conflicts to weight, t are according to the test history information test number consistent with foretelling, j (j=1,2,3 .., t)
It is influence of the consistent number of regulation to weight, γ is regulatory factor.Represent k-th of conflict influence of the test number to weight because
Son, with the increase of test number, test the influence to weight and constantly reduce,γ∈ [0,0.5] is regulatory factor, its size by
Test case scale determines, as the larger (s+t of test case>10000) when, we, which give tacit consent to, takes γ=0.5, works as k>10000
When,Its influence to weight is ignored, as the small (s+t of test case<=10000) when, we will survey
Try the constantly reduction of the influence to weight to ignore, even γ=0, so, all tests are 1 to the factor of influence of weight.
For example, do not upgraded in time because the modification of sentence 9 result in sentence 16, so as to cause failure, and Test
Oracle is not destroyed, and has following test information:
Cover history |
Prophesy |
5,6,7,8,9 |
Unanimously |
5,6,7,8,9,10,11,14,17,18 |
Unanimously |
5,6,7,8,9,10,11,12,13,14,17,18 |
Unanimously |
5,6,7,8,9,10,11,14,15,16 |
Conflict |
5,6,7,8,9,10,11,12,13,14,15,16 |
Conflict |
5,6,7,8,9,10,11,12,13,14,15,16 |
Conflict |
Wherein, for convenience of description, we only show the sentence covering letter in the subline methods of test execution history
Breath.Test case number is seldom, makes γ=0, and according to above-mentioned calculation formula, the DynamicWeight values of each sentence are as follows:
Sentence node |
5,6,7,8,9 |
10,11,14 |
12,13 |
15,16 |
17,18 |
DynamicWeight |
0.5 |
0.6 |
0.67 |
1 |
0 |
The DynamicWeight values of sentence 15,16 are maximum, can be faster when failure occurs navigate to sentence 16,
And modification root can be traversed according to EFAGM.
8) EFAGM structure is completed.In order to intuitively represent EFAGM, we provide EFAGM caused by the modification of step 7
Figure, as shown in Figure 6.In figure, we intuitively illustrate modification node in example subline methods by EFAGM figures, influenceed
Node and without artis and DCDEdge, ICDEdge, DDDEdge, IDDEdge, and give based on 6), 7) formula calculates
StaticWeight and DynamicWeight thresholdings.When failure occurs, peopleware can according to StaticWeight and
DynamicWeight threshold levels determine the root of failure.
Those skilled in the art of the present technique it is understood that discussed in the present invention various operations, method, flow
In step, measure, scheme can be replaced, changed, combined or deleted.Further, have in the present invention and discussed
Various operations, method, other steps in flow, measure, scheme can also be replaced, changed, being reset, being decomposed, being combined or
Delete.Further, it is of the prior art have with the step in the various operations disclosed in the present invention, method, flow, arrange
Apply, scheme can also be replaced, changed, reset, decompose, combines or be deleted.
Described above is only some embodiments of the present invention, it is noted that for the ordinary skill people of the art
For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should
It is considered as protection scope of the present invention.