CN110515857A - A kind of method for generating test case executed based on dynamic symbol - Google Patents

A kind of method for generating test case executed based on dynamic symbol Download PDF

Info

Publication number
CN110515857A
CN110515857A CN201910824781.9A CN201910824781A CN110515857A CN 110515857 A CN110515857 A CN 110515857A CN 201910824781 A CN201910824781 A CN 201910824781A CN 110515857 A CN110515857 A CN 110515857A
Authority
CN
China
Prior art keywords
test case
path
path candidate
controlling stream
constraint
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.)
Pending
Application number
CN201910824781.9A
Other languages
Chinese (zh)
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.)
Shanghai Fenglei Information Technology Co Ltd
East China Normal University
Original Assignee
Shanghai Fenglei Information Technology Co Ltd
East China Normal University
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 Shanghai Fenglei Information Technology Co Ltd, East China Normal University filed Critical Shanghai Fenglei Information Technology Co Ltd
Priority to CN201910824781.9A priority Critical patent/CN110515857A/en
Publication of CN110515857A publication Critical patent/CN110515857A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

This application discloses the method for generating test case that a kind of dynamic symbol executes, comprising: generates controlling stream graph according to the structured text ST source program of input;Variable's attribute and canonical function are modeled according to controlling stream graph, generate initial test case, substitutes into execute in controlling stream graph and obtains overlay path, obtains constraint set, according to constraint set determine path candidate pond select one as execution route;It according to standard feature block, canonical function, variable's attribute and the transformation rule after modeling, is solved after being converted to the constraint set on execution route, obtains new test case;All test cases that an input source program obtains are saved, coverage rate information is determined according to overlay path, exports test case and coverage rate information.Can be simple by using dynamic symbol execution, test case is quickly generated, adverse effect caused by human factor is reduced;Test case and correct coverage rate information, high degree of automation, the cost of labor that can obtain high quality are low.

Description

A kind of method for generating test case executed based on dynamic symbol
Technical field
This application involves software test field more particularly to a kind of Test cases technology sides executed based on dynamic symbol Method.
Background technique
Programmable logic controller (PLC) (Programmable Logic Controller, PLC) is as industrial control system Core equipment has been widely used in various automation control areas.As the scale of PLC software is more and more huger, PLC is set It is standby more and more various, many problems have been broken out in practical application, it is heavy then will affect personal safety gently it will cause economic loss. 61508 standard of IEC explicitly points out, and PLC software must be surveyed comprehensively before publication in terms of function, structure Examination.The top priority of software test be exactly be software under testing design test case.Using circulation execution pattern, this to compile PLC It is especially challenging to write detailed test case.However, survey of the test method of existing PLC tool substantially to be manually entered Based on example on probation, the demand of major concern user.This method usually requires tester and understands requirement profile and program structure, non- It is often time-consuming, the degree of automation is low, high labor cost, be easy to appear adverse effect caused by human factor, and can not test At rear information of the offer in relation to code coverage.
In summary, it is desirable to provide it is a kind of for the simple, quick of PLC, high degree of automation, cost of labor it is low, can Adverse effect caused by human factor is reduced, and the Test cases technology side of coverage rate information can be provided after the completion of test Method.
Summary of the invention
In order to solve the above problem, present applicant proposes a kind of method for generating test case executed based on dynamic symbol, lead to It crosses and controlling stream graph is generated according to structured text (Structured Text) source program of input, execute root using dynamic symbol According to controlling stream graph, test case is generated, substitutes into controlling stream graph and executes, obtain test case and coverage rate information.
Specifically, the invention proposes a kind of method for generating test case executed based on dynamic symbol, comprising:
Analyzing step models the standard feature block in the structured text ST source program of input, obtains equivalent ST Program parses equivalent ST program using compiler, obtains abstract syntax tree;
Controlling stream graph generation step, ergodic abstract syntax tree generate controlling stream graph in conjunction with the characteristic of ST language;
Dynamic symbol executes step and is modeled according to controlling stream graph to variable's attribute and canonical function, generates initial survey Example on probation, substitutes into controlling stream graph and executes, and obtains overlay path, obtains constraint set, determines path candidate pond according to constraint set, Selected from path candidate pond one as execution route;
Constraint solving step is right according to standard feature block, canonical function, variable's attribute and the transformation rule after modeling Constraint set on execution route solves after being converted, and obtains new test case;
Statistics and output step, save all test cases that an input source program obtains, true according to overlay path Determine coverage rate information, exports all test cases and coverage rate information.
Preferably, the generation initial test case is substituted into controlling stream graph and is executed, and constraint set is obtained, according to constraint set Determine path candidate pond, selected from path candidate pond one as execution route, comprising:
Initial test case is generated using the variable initial value in controlling stream graph;
Initial test case is substituted into controlling stream graph and is executed, overlay path is obtained;
The constraint set on overlay path is obtained, each constraint of constraint set is negated, path candidate pond is obtained;
According to route searching strategy, select a path candidate as execution route from path candidate pond.
Preferably, path candidate pond is determined according to constraint set described, selected from path candidate pond one as execute After path, further includes:
Update the path candidate and coverage information in path candidate pond;
From updated path candidate pond, select a path candidate as new execution route.
Preferably, it is solved after the constraint set on execution route is converted, after obtaining new test case, Further include:
If there is new execution route in path candidate pond, new test case is substituted into controlling stream graph and is executed;
If without new execution route, loop termination in the controlling stream graph of path candidate pond.
Preferably, the path candidate pond includes: one or more path candidate.
Preferably, the controlling stream graph includes: variable initial value, constraint EQ, executes constraint and secondary order constrained.
Preferably, the constraint set includes: constraint EQ, executes constraint and secondary order constrained.
Preferably, the solution, comprising: the constraint set after conversion is solved using satisfiability theory of modules SMT solver.
Preferably, the transformation rule is set as needed.
Preferably, the route searching strategy includes: depth-first search and breadth first search.
The advantages of the application, is: controlling stream graph is generated by using the structured text ST source program of input, using dynamic State semiology analysis generates test case according to controlling stream graph, substitutes into controlling stream graph and executes, and obtains overlay path, obtains about Constriction determines path candidate pond according to constraint set, and one is selected from path candidate pond as execution route, on execution route Constraint set converted after solve, obtain new test case, can be simple, quickly generate test case, and reduce people For adverse effect caused by factor;All test cases that an input source program obtains are saved, are determined according to overlay path Coverage rate information exports all test cases and coverage rate information, can obtain all test case and coverage rate information, from Dynamicization degree is high, and cost of labor is low.
Detailed description of the invention
By reading the following detailed description of the preferred embodiment, various other advantages and benefits are common for this field Technical staff will become clear.Attached drawing is only used for showing the purpose of preferred implementations, and is not considered as to the application Limitation.And throughout the drawings, identical component is indicated with same reference symbol.In the accompanying drawings:
Fig. 1 is a kind of step schematic diagram of method for generating test case executed based on dynamic symbol provided by the present application;
Fig. 2 is a kind of utilization controlling stream graph of method for generating test case executed based on dynamic symbol provided by the present application ST_CFG generates the generating algorithm schematic diagram of the test use cases covered based on branch;
Fig. 3 is a kind of example procedure figure of method for generating test case executed based on dynamic symbol provided by the present application;
Fig. 4 is a kind of control of the example procedure of method for generating test case executed based on dynamic symbol provided by the present application Flow graph processed;
Fig. 5 is a kind of schematic diagram of Test cases technology system executed based on dynamic symbol provided by the present application;
Fig. 6 is a kind of structural schematic diagram of Test cases technology system executed based on dynamic symbol provided by the present application.
Specific embodiment
The illustrative embodiments of the disclosure are more fully described below with reference to accompanying drawings.Although showing this public affairs in attached drawing The illustrative embodiments opened, it being understood, however, that may be realized in various forms the disclosure without the reality that should be illustrated here The mode of applying is limited.It is to be able to thoroughly understand the disclosure on the contrary, providing these embodiments, and can be by this public affairs The range opened is fully disclosed to those skilled in the art.
According to presently filed embodiment, a kind of method for generating test case executed based on dynamic symbol, such as Fig. 1 are proposed It is shown, comprising:
S1, analyzing step model the standard feature block in the structured text ST source program of input, obtain equivalent ST program parses equivalent ST program using compiler, obtains abstract syntax tree;
S2, controlling stream graph generation step, ergodic abstract syntax tree generate controlling stream graph in conjunction with the characteristic of ST language;
S3, dynamic symbol execute step and are modeled according to controlling stream graph to variable's attribute and canonical function, generate just Beginning test case is substituted into controlling stream graph and is executed, and obtains overlay path, obtains constraint set, determines candidate road according to constraint set Diameter pond, selected from path candidate pond one as execution route;
S4, constraint solving step, according to standard feature block, canonical function, variable's attribute and the transformation rule after modeling, It is solved after being converted to the constraint set on execution route, obtains new test case;
S5, statistics and output step, save all test cases that an input source program obtains, according to overlay path It determines coverage rate information, exports all test cases and coverage rate information.
Wherein, controlling stream graph includes: variable initial value, constraint EQ, executes the information such as constraint and secondary order constrained.
Constraint set includes: constraint EQ, executes constraint and secondary order constrained.
Path candidate pond includes: one or more path candidate.
It solves, comprising: use the satisfiability theory of modules (SatisfiabilityModuloTheories, SMT) solver Constraint set after conversion is solved.
SMT solver includes: Z3 solver and Yice solver etc..
Transformation rule is set as needed.Transformation rule dynamic symbol execute step interacted with constraint solving step when It waits and uses, the conversion comprising identifier, data type, operator and sentence.
Equivalent ST program is exactly to indicate the standard feature block expansion in ST source program.It is still ST program, only originally It is a line, replaces with multirow now.
Compiler is used to ST program resolving to abstract syntax tree.
Variable's attribute refers to: in external writeable variable's attribute, the variable that they are stated all is a part of test case;When For variable's attribute when external not writeable, the variable that they are stated cannot function as test case.
Variable's attribute is modeled, i.e., according to the attribute of variable, is classified to variable.In variable, some conducts are defeated Enter variable, has plenty of built-in variable.Dynamic symbol executes step in each variable of execution, can all judge its attribute, according to Variable's attribute, dynamic symbol executes step and constraint solution procedure carries out different processing to variable.
Canonical function in ST source program, which is modeled in constraint solving step, has corresponding function corresponding.
Coverage rate information includes: sentence covering rate and branch covering rate etc..It is calculated according to the following formula:
Sentence covering rate=(empty number of edges × 2 that the number of edges-covered has covered)/(total number of edges-sky number of edges × 2);
Branch covering rate=covering branch number/total number.
All test cases include: initial test case and newly-generated all test cases.That is, according to the one of input All test cases that ST source program generates.
Structured text ST is one of the language of IEC 61131-3 standard, and IEC 61131-3 standard defines three kinds of programs Organizational unit (Program Organization Unit, POU) type: function (Function, FN), functional block (Function Block, FB) and program (Program, PROG).Program PROG is normally used for constituting main program.It is various initialization of variable With the initial position of context statement.Function FN and functional block FB may be constructed user's favorite subroutine.
Initial test case is generated, substitutes into controlling stream graph and executes, constraint set is obtained, path candidate is determined according to constraint set Pond, selected from path candidate pond one as execution route, comprising:
S31 generates initial test case using the variable initial value in controlling stream graph;
Initial test case is substituted into controlling stream graph and is executed, obtains overlay path by S32;
S33 obtains the constraint set on overlay path, negates to each constraint of constraint set, obtain path candidate pond;
S34 selects a path candidate as execution route according to route searching strategy from path candidate pond.
Wherein, route searching strategy includes: depth-first search and breadth first search.
Dynamic symbol executes step and mainly includes modeling procedure, executes step and filtration step.Wherein, modeling procedure packet It includes: according to controlling stream graph, variable's attribute and canonical function being modeled.Executing step includes: generation initial test case, generation Enter in controlling stream graph and execute, obtain overlay path, obtains constraint set, determine that (S31 is extremely in path candidate pond according to constraint set S33).Filtration step include: select one as execution route (S34).
Filtration step is determining path candidate pond according to constraint set, selected from path candidate pond one as execute road After diameter, further includes:
S351 updates path candidate and coverage information in path candidate pond;
S352 selects a path candidate as new execution route from updated path candidate pond.
It is solved after being converted to the constraint set on execution route, after obtaining new test case, further includes:
If there is new execution route in path candidate pond, new test case is substituted into controlling stream graph and is executed;
If without new execution route, loop termination in the controlling stream graph of path candidate pond.
In order to better understand, workflow of the invention will be illustrated below.
Standard feature block in the structured text ST source program of input is modeled, equivalent ST program is obtained, is used Compiler parses equivalent ST program, obtains abstract syntax tree.
Preferably, ST program is parsed into abstract syntax using the lexical analyzer of MATIEC compiler and syntax analyzer Tree.
The abstract syntax tree obtained is traversed, in conjunction with the characteristic of ST language, generates controlling stream graph.
According to controlling stream graph, variable's attribute and canonical function are modeled;Initial test case is substituted into controlling stream graph Middle execution obtains overlay path.The constraint set on overlay path is obtained, each constraint of constraint set is negated, is waited Routing diameter pond;According to route searching strategy, select a path candidate as execution route from path candidate pond.
The path candidate selected is removed from path candidate pond, or the path candidate selected is marked, more Path candidate and coverage information in new path candidate pond;
From updated path candidate pond, select a path candidate as new execution route.
If in updated path candidate pond, without path candidate, then without new execution route.
It is chosen in the path candidate that execution route is never selected.
According to standard feature block, canonical function, variable's attribute and the transformation rule after modeling, to the pact on execution route Constriction solves after being converted, and obtains new test case.
If there is new execution route in path candidate pond, new test case is substituted into controlling stream graph and is executed;
If without new execution route, loop termination in the controlling stream graph of path candidate pond.
All test cases that an input source program obtains are saved, coverage rate information is determined according to overlay path, it is defeated All test cases and coverage rate information out.
In the following, the interaction that dynamic symbol executes step and constrains solution procedure is further elaborated.
Before generating initial test case using the variable initial value in controlling stream graph, it is assumed that path candidate is at the beginning 0, initial test case is generated using variable initial value, obtaining the path p1 that one covers, (path p1 is that performance variable is initial What value was formed), path candidate is obtained according to p1, it is assumed that obtain 3, be path candidate a, path candidate b and path candidate respectively c.Candidate route pond is formed by this 3 path candidates.
Select a path candidate (as execution route), it is assumed that selection path candidate a.
Constraint set on to acquisite approachs a (execution route) is asked after converting to the constraint set on path a (execution route) Solution, obtains new test case.
New test case is input in control flow chart and is executed, the path p2 of a covering is obtained, is obtained according to p2 More path candidates, it is assumed that be e, f.
Update path candidate pond.At this point, path candidate e and path candidate f are increased in path candidate pond, but candidate road Diameter a was executed, so path candidate a is removed from path candidate pond, or path candidate a was marked.
It was not selected before selection one in selection path candidate pond, as execution route next time, it is assumed that select Path be b.
Constraint set in acquisite approachs b, is then converted, and is solved, is obtained new test case.And so on, until candidate Path all without, that is, without new execution route.
Dynamic symbol executes step and constraint solution procedure and utilizes controlling stream graph ST_CFG according to method as shown in Figure 2 Generate the test use cases covered based on branch.Input includes: that G is controlling stream graph ST_CFG, route searching strategy SS (Search Strategy), coverage criteria CC (Coverage Criteria).Output includes: test use cases TS (Test Case Set) With coverage rate CR (Coverage Rate).
Select Z3 solver for the solution of path constraint collection in constraint solving step.Firstly, non-overlay path CP (Candidate Paths) is set as empty, and test use cases TS is also sky, and the number of iterations iter is equal to 1.6th to the 12nd row is one A branched structure, respectively indicates: if the number of iterations iter is equal to 1, test case TC (Test Case) is assigned a value of being stored in control The initial value (the 7th row) of the variable V ar of flow graph processed;It is to survey by generating test case function if the number of iterations iter is greater than 1 Example TC assignment (the 11st row) on probation.13rd to the 22nd row is the circular flow structure for executing step and filtration step, until whole Covering terminates in this period without the path that can be capped.Test case TC is added in TSiter first.Actuator An a series of capped path p (being made of constraints) is obtained by calling z3 solver from test case TC.Because needing Record static variable state.Using the value of the static variable in a upper period as a part for asserting formula when calling z3.Meanwhile phase The Eval value that should be constrained becomes true from false in controlling stream graph, or keeps true constant.It can be generated according to path p more The variant of a path p judges whether to have existed in overlay path and non-overlay path CP one by one.If it is not, being then added to Non- overlay path CP, if so, (the 14th row) without any processing.17th to the 21st behavior generates test case process.
G in Fig. 2 includes: node collection N, constraint set S, variables set V, logical value L, conditional jump relationship E, start node Nstart, end node Nend, coverage rate statistical information C.
Wherein, the serial number of node collection N is arranged since 1 by genesis sequence.Constraint set S is from ST program statement.Variable Collection V is the set of all variables in program.Logical value E, i.e. true or false, for assessing whether some constraint is performed to (capped).Start node Nstart and end node Nend is the sole inlet and sole outlet of controlling stream graph ST_CFG, right Answer the entrance and exit of ST program, conditional jump relationship
In the following, being further elaborated for inputting example procedure Hysteresis.
As shown in figure 3, being example procedure Hysteresis.The ST source program (Hysteresis) that user writes is converted to ST program is resolved to abstract syntax using the lexical analyzer and syntax analyzer of MATIEC compiler by ST program of equal value Tree.
Ergodic abstract syntax tree generates corresponding controlling stream graph ST_CFG.As shown in figure 4, for according to input The controlling stream graph of Hysteresis Program Generating.Node in controlling stream graph is according to map generalization serial number.Mend (negating) behaviour Be used as symbol "!" replace, null statement is indicated with " () ".There are 6 branches in this controlling stream graph, is (Q) respectively;(!Q);(IN1< (IN2-EPS));(!(IN1<(IN2-EPS)));(IN1>(IN2+EPS));(!(IN1>(IN2+EPS))).In addition, the control Flow graph also includes all variables, for information of coverage rate statistics etc..
Test use cases are as shown in table 1.
Table 1
First row indicates period order in table 1.2-4 column indicate the input value of input variable in current period.Reciprocal the Two column are the values of the output variable Q after having executed the period.Last arranges the path for being given at this periodic cover.When period etc. When 1, program directly is run using the initial value V of variable in program.Then implementation of test cases, path (n1, n4, n8, n2) Be performed, all constraints on extraction procedure execution route with obtain covering constraint set ((!Q), (!(IN_1>(IN_2+ EPS)))).According to depth-first search strategy choose two path candidates ((Q) and (!Q), (IN_1 > (IN_2+EPS))) in Latter item is as execution route.The constraint set obtained from execution route is converted to the input format of Z3, and is solved by Z3 Device finds out the variate-value for meeting and newly constraining, and obtains one group of new test case (IN1=1, IN2=0, EPS=0).
In second period, implementation of test cases, path (n1, n4, n7, n2) is performed.Meanwhile the value of Q is by original FALSE is updated to TRUE.The program PROG of ST has memory to output variable, and Q value will be retained.Newly-generated path candidate ((Q) (!Q), (!(IN_1 > (IN_2+EPS)))) it is invalid, because the former is existing in path candidate, the latter has been capped.When There was only a path candidate (Q) in preceding path candidate, it is solved and is met (sat), and solver does not give the change of assignment Amount inherits the value in last period.Third and fourth period covers two new paths, and updates the logical value L, not of ST_CFG Overlay path CP.Finally, all branches of program are capped.
The test use cases of Hysteresis are counted, output branch coverage rate is 100%.If changing the assignment of Q (i.e. N7, n2 and n5, n2 exchange), it will be unable to generate the test case being completely covered.From this, it can also be seen that, test case is can be found that Program error.
According to presently filed embodiment, it is also proposed that a kind of Test cases technology system executed based on dynamic symbol, such as Shown in Fig. 5, comprising:
Parsing module 101 is modeled for the standard feature block in the structured text ST source program to input, is obtained Equivalent ST program parses equivalent ST program using compiler, obtains abstract syntax tree;
Controlling stream graph generation module 102 is used for ergodic abstract syntax tree, in conjunction with the characteristic of ST language, generates controlling stream graph;
Dynamic symbol execution module 103, it is raw for being modeled to variable's attribute and canonical function according to controlling stream graph It at initial test case, substitutes into controlling stream graph and executes, obtain overlay path, obtain constraint set, determined and waited according to constraint set Routing diameter pond, selected from path candidate pond one as execution route;
Constraint solving module 104, for according to standard feature block, canonical function, variable's attribute and the conversion after modeling Rule solves after converting to the constraint set on execution route, obtains new test case;
Statistics and output module 105, all test cases obtained for saving an input source program, according to having covered Path determines coverage rate information, exports all test cases and coverage rate information.
Path candidate pond includes: one or more path candidate.
Controlling stream graph includes: variable initial value, constraint EQ, executes constraint and secondary order constrained.
Constraint set includes: constraint EQ, executes constraint and secondary order constrained.
It solves, comprising: the constraint set after conversion is solved using satisfiability theory of modules SMT solver.
Transformation rule is set as needed.
As shown in fig. 6, dynamic symbol execution module includes:
Modeling unit, for being modeled to variable's attribute and canonical function;
Execution unit uses initial testing for using the variable initial value in controlling stream graph to generate initial test case Example is substituted into controlling stream graph and is executed, and obtains overlay path, obtains the constraint set on overlay path, about to each of constraint set Beam negates, and obtains path candidate pond;
Filter element, for selecting a path candidate as execution from path candidate pond according to route searching strategy Path.
Route searching strategy includes: depth-first search and breadth first search.
Filter element is also used to:
The path candidate and coverage information in path candidate pond are updated, from updated path candidate pond, selects one Path candidate is as new execution route.
Execution unit is also used to:
If there is new execution route in path candidate pond, new test case is substituted into controlling stream graph and is executed;
If without new execution route, loop termination in the controlling stream graph of path candidate pond.
In the present processes, by directly applying to dynamic symbol execution in the Test cases technology of ST, in conjunction with ST The period of language executes characteristic, can automatically generate the test case of mass efficient, and save the test case of all generations, In Largely reduce cost of labor, avoids adverse effect caused by many human factors, improves the efficiency of test, In It copes in complicated system in large scale, positive effect will be given full play to.It can be the test of ST programming automatic generation high quality Use-case and correct coverage rate information execute the test case generated based on dynamic symbol, and with validity, redundancy is few, covers The high feature of rate.Code coverage provide one can refer to, the metric of traceable software quality, reflect tested software can By property degree.IEC61508 standard provides: SIL1 must satisfy 100% dot coverage;SIL2 must satisfy 100% sentence Coverage rate;SIL3 must satisfy 100% branch covering rate.The coverage rate information of this method programming count can be used for judging quilt Whether ranging sequence meets target SIL, and the test case that can also be generated by operation finds mistake.
The preferable specific embodiment of the above, only the application, but the protection scope of the application is not limited thereto, Within the technical scope of the present application, any changes or substitutions that can be easily thought of by anyone skilled in the art, Should all it cover within the scope of protection of this application.Therefore, the protection scope of the application should be with the protection model of the claim Subject to enclosing.

Claims (10)

1. a kind of method for generating test case executed based on dynamic symbol characterized by comprising
Analyzing step models the standard feature block in the structured text ST source program of input, obtains equivalent ST program, Equivalent ST program is parsed using compiler, obtains abstract syntax tree;
Controlling stream graph generation step, ergodic abstract syntax tree generate controlling stream graph in conjunction with the characteristic of ST language;
Dynamic symbol executes step and is modeled according to controlling stream graph to variable's attribute and canonical function, generates initial testing and uses Example is substituted into controlling stream graph and is executed, and obtains overlay path, is obtained constraint set, path candidate pond is determined according to constraint set, from time Selected in routing diameter pond one as execution route;
Constraint solving step, according to standard feature block, canonical function, variable's attribute and the transformation rule after modeling, to execution Constraint set on path solves after being converted, and obtains new test case;
Statistics and output step, save all test cases that an input source program obtains, and are covered according to the determination of overlay path Lid rate information, exports all test cases and coverage rate information.
2. the method as described in claim 1, which is characterized in that the generation initial test case is substituted into controlling stream graph and held Row obtains constraint set, determines path candidate pond according to constraint set, and one is selected from path candidate pond as execution route, is wrapped It includes:
Initial test case is generated using the variable initial value in controlling stream graph;
Initial test case is substituted into controlling stream graph and is executed, overlay path is obtained;
The constraint set on overlay path is obtained, each constraint of constraint set is negated, path candidate pond is obtained;
According to route searching strategy, select a path candidate as execution route from path candidate pond.
3. the method as described in claim 1, which is characterized in that path candidate pond is determined according to constraint set described, from candidate Selected in the pond of path one as execution route after, further includes:
Update the path candidate and coverage information in path candidate pond;
From updated path candidate pond, select a path candidate as new execution route.
4. the method as described in claim 1, which is characterized in that asked after the constraint set on execution route is converted Solution, after obtaining new test case, further includes:
If there is new execution route in path candidate pond, new test case is substituted into controlling stream graph and is executed;
If without new execution route, loop termination in the controlling stream graph of path candidate pond.
5. the method as described in claim 1, which is characterized in that the path candidate pond includes: one or more path candidate.
6. the method as described in claim 1, which is characterized in that the controlling stream graph include: variable initial value, constraint EQ, Execute constraint and time order constrained.
7. the method as described in claim 1, which is characterized in that the constraint set include: constraint EQ, execute constraint and Secondary order constrained.
8. the method as described in claim 1, which is characterized in that the solution, comprising: asked using satisfiability theory of modules SMT Device is solved to solve the constraint set after conversion.
9. the method as described in claim 1, which is characterized in that the transformation rule is set as needed.
10. method according to claim 2, which is characterized in that the route searching strategy includes: depth-first search and wide Spend first search.
CN201910824781.9A 2019-09-02 2019-09-02 A kind of method for generating test case executed based on dynamic symbol Pending CN110515857A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910824781.9A CN110515857A (en) 2019-09-02 2019-09-02 A kind of method for generating test case executed based on dynamic symbol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910824781.9A CN110515857A (en) 2019-09-02 2019-09-02 A kind of method for generating test case executed based on dynamic symbol

Publications (1)

Publication Number Publication Date
CN110515857A true CN110515857A (en) 2019-11-29

Family

ID=68630412

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910824781.9A Pending CN110515857A (en) 2019-09-02 2019-09-02 A kind of method for generating test case executed based on dynamic symbol

Country Status (1)

Country Link
CN (1) CN110515857A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111193640A (en) * 2019-12-26 2020-05-22 西安交通大学 Stateful data plane fault detection method using policy decomposition and symbolic execution
CN112162932A (en) * 2020-10-30 2021-01-01 中国人民解放军国防科技大学 Symbol execution optimization method and device based on linear programming prediction
CN112416800A (en) * 2020-12-03 2021-02-26 网易(杭州)网络有限公司 Intelligent contract testing method, device, equipment and storage medium
CN114238154A (en) * 2022-02-24 2022-03-25 湖南泛联新安信息科技有限公司 Symbol execution method, unit testing method, electronic device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102736979A (en) * 2012-06-29 2012-10-17 南京大学 Symbolic-execution-based method for generating test cases with feedback
US8448134B1 (en) * 2009-08-24 2013-05-21 Symantec Corporation Systems and methods for reliably identifying controls invoked during quality-assurance reviews of user interfaces
CN103294594A (en) * 2013-05-08 2013-09-11 南京大学 Test based static analysis misinformation eliminating method
CN107193745A (en) * 2017-05-26 2017-09-22 中国人民解放军信息工程大学 Automated construction method of the PLC program to NuSMV input models

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8448134B1 (en) * 2009-08-24 2013-05-21 Symantec Corporation Systems and methods for reliably identifying controls invoked during quality-assurance reviews of user interfaces
CN102736979A (en) * 2012-06-29 2012-10-17 南京大学 Symbolic-execution-based method for generating test cases with feedback
CN103294594A (en) * 2013-05-08 2013-09-11 南京大学 Test based static analysis misinformation eliminating method
CN107193745A (en) * 2017-05-26 2017-09-22 中国人民解放军信息工程大学 Automated construction method of the PLC program to NuSMV input models

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111193640A (en) * 2019-12-26 2020-05-22 西安交通大学 Stateful data plane fault detection method using policy decomposition and symbolic execution
CN111193640B (en) * 2019-12-26 2021-07-13 西安交通大学 Stateful data plane fault detection method using policy decomposition and symbolic execution
CN112162932A (en) * 2020-10-30 2021-01-01 中国人民解放军国防科技大学 Symbol execution optimization method and device based on linear programming prediction
CN112162932B (en) * 2020-10-30 2022-07-19 中国人民解放军国防科技大学 Symbol execution optimization method and device based on linear programming prediction
CN112416800A (en) * 2020-12-03 2021-02-26 网易(杭州)网络有限公司 Intelligent contract testing method, device, equipment and storage medium
CN112416800B (en) * 2020-12-03 2023-09-15 网易(杭州)网络有限公司 Intelligent contract testing method, device, equipment and storage medium
CN114238154A (en) * 2022-02-24 2022-03-25 湖南泛联新安信息科技有限公司 Symbol execution method, unit testing method, electronic device and storage medium

Similar Documents

Publication Publication Date Title
CN110515856A (en) A kind of Test cases technology system executed based on dynamic symbol
CN110515857A (en) A kind of method for generating test case executed based on dynamic symbol
WO2012032890A1 (en) Source code conversion method and source code conversion program
WO2007001108A1 (en) System for providing feature-oriented software product line engineering environment
US20160283201A1 (en) Activity Diagram Model-Based System Behavior Simulation Method
CN109143952A (en) Programmable logic controller (PLC) programming language converting system
US10997335B2 (en) Exceptional logic element management
US20160350449A1 (en) Exceptional logic element management
EP1548581A2 (en) Methods, apparatus and programs for system development
US20070245327A1 (en) Method and System for Producing Process Flow Models from Source Code
Rosiak et al. Custom-tailored clone detection for IEC 61131-3 programming languages
CN109032056A (en) Programmable logic controller (PLC) programming language conversion method
JP6568017B2 (en) Test support apparatus and test support method
US11099978B2 (en) Modeling system for software-implemented testing using domain specific profiles to translate tests for a subset of paths included in a UML test model
CN117369521B (en) Method, device and equipment for generating behavior tree model path for unmanned aerial vehicle decision
CN114201397A (en) Interface test modeling method and device, electronic equipment and storage medium
CN117707612A (en) Code processing method and device and electronic equipment
Adiego et al. Model-based automated testing of critical PLC programs
Vogel-Heuser et al. Goal-Lever-Indicator-Principle to derive recommendations for improving IEC 61131-3 control software
Jose et al. SMT based false causal loop detection during code synthesis from polychronous specifications
Fischer et al. Reuse Assessment of IEC 61131-3 Control Software Modules Using Metrics–An Industrial Case Study
JP2006277282A (en) Model evaluation analysis system and model evaluation analysis program
CN114610649A (en) Instruction tracking test method, system, equipment and medium
Fischer et al. Reengineering workflow for planned reuse of IEC 61131-3 legacy software
Sarmiento et al. Analysis of scenarios with Petri-Net models

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20191129

RJ01 Rejection of invention patent application after publication