CN104461861A - EFSM model-based path testing data generation method - Google Patents
EFSM model-based path testing data generation method Download PDFInfo
- Publication number
- CN104461861A CN104461861A CN201410561899.4A CN201410561899A CN104461861A CN 104461861 A CN104461861 A CN 104461861A CN 201410561899 A CN201410561899 A CN 201410561899A CN 104461861 A CN104461861 A CN 104461861A
- Authority
- CN
- China
- Prior art keywords
- test data
- path
- individuals
- constraints
- efsm
- 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
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 70
- 238000000034 method Methods 0.000 title claims abstract description 69
- 230000002068 genetic effect Effects 0.000 claims abstract description 13
- 230000035772 mutation Effects 0.000 claims abstract description 5
- 238000004458 analytical method Methods 0.000 claims abstract description 4
- 230000006978 adaptation Effects 0.000 claims description 2
- 230000007704 transition Effects 0.000 description 12
- 238000013508 migration Methods 0.000 description 11
- 230000005012 migration Effects 0.000 description 11
- 230000014509 gene expression Effects 0.000 description 8
- 230000005540 biological transmission Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 210000000349 chromosome Anatomy 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000005206 flow analysis Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 108090000623 proteins and genes Proteins 0.000 description 1
- 238000013522 software testing Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
本发明公开了基于EFSM模型的路径测试数据生成方法,包括以下步骤:步骤一、对EFSM模型进行符号执行和数据流依赖分析,获得每条EFSM模型的路径约束;步骤二、使用遗传算法生成满足路径约束的测试数据,给定初始个体;步骤三、根据适应度函数评估初始个体的适应度值,若个体的适应值为0,那么这样的初始个体就是满足路径约束的测试数据,算法终止;步骤四、若步骤三中的适应值没有超过设定的最大代数,可以在当前代中选取两个具有最小适应值的个体作为父个体进行交叉操作或变异操作,生成新一代个体,并对新一代个体重复步骤三和步骤四。对于具有复杂约束或涉及多变量的路径,我们的方法生成满足所有约束条件的测试数据的成功率要比S.Kalaji方法高的多。
The invention discloses a method for generating path test data based on an EFSM model, comprising the following steps: step 1, performing symbolic execution and data flow dependency analysis on the EFSM model, and obtaining the path constraints of each EFSM model; step 2, using a genetic algorithm to generate The test data of the path constraint, given the initial individual; step 3, evaluate the fitness value of the initial individual according to the fitness function, if the fitness value of the individual is 0, then such an initial individual is the test data that satisfies the path constraint, and the algorithm terminates; Step 4. If the fitness value in step 3 does not exceed the set maximum number of generations, two individuals with the minimum fitness value can be selected as the parent individuals in the current generation to perform crossover or mutation operations to generate a new generation of individuals, and the new generation Repeat steps 3 and 4 for one generation of individuals. For paths with complex constraints or involving multiple variables, our method has a much higher success rate than S.Kalaji's method in generating test data satisfying all constraints.
Description
技术领域 technical field
本发明涉及软件测试领域,具体涉及基于EFSM模型的路径测试数据生成方法。 The invention relates to the field of software testing, in particular to a method for generating path testing data based on an EFSM model. the
背景技术 Background technique
目前已经有很多关于程序的测试数据生成的研究,也已经有很多研究者把基于搜索的方法应用到了该领域。但是关于EFSM模型的测试数据生成方法的文章不是很多,目前主要的方法如下: At present, there have been many researches on program test data generation, and many researchers have applied search-based methods to this field. However, there are not many articles about the test data generation method of the EFSM model. At present, the main methods are as follows:
J.Zhang等提出了一种面向路径的测试数据生成方法,首先符号执行获取路径约束,然后采用约束求解器求解该路径约束,获取满足约束条件的输入值。但是符号执行和约束求解的局限是不能求解非线性约束。 J. Zhang et al. proposed a path-oriented test data generation method. First, symbolic execution obtains path constraints, and then uses a constraint solver to solve the path constraints to obtain input values that meet the constraints. But the limitation of symbolic execution and constraint solving is that it cannot solve nonlinear constraints. the
R.Lefticaru等定义了一个适应度估算方法来获取路径的输入序列,该方法把Tracey的适应值函数应用到了路径的每一条迁移,路径的适应值通过把路径中的每一个函数看作是一个关键结点来定义。该方法的局限是它要求每个函数不能包含内部路径即嵌套的IF语句,要不然就不能使用Tracy的方法。 R.Lefticaru defined a fitness estimation method to obtain the input sequence of the path. This method applies Tracey's fitness value function to each migration of the path. The fitness value of the path is regarded as a function of each function in the path. Key nodes are defined. The limitation of this method is that it requires that each function cannot contain internal paths, that is, nested IF statements, otherwise Tracy's method cannot be used. the
S.Kalaji等提出使用遗传算法来测试EFSM,他把分支距离和接近层次结合起来作为遗传算法的适应度函数,该适应度函数对于具有 复杂约束的EFSM路径生成测试数据的成功率不高。对于包含等式约束的EFSM路径,不能生成符合所有约束的测试数据,生成的测试数据违反的平均约束率较高,说明测试数据的质量不高。 S. Kalaji proposed to use genetic algorithm to test EFSM. He combined branch distance and close level as the fitness function of genetic algorithm. The fitness function has a low success rate for generating test data for EFSM paths with complex constraints. For the EFSM path containing equality constraints, the test data conforming to all the constraints cannot be generated, and the average constraint rate of the generated test data violation is high, indicating that the quality of the test data is not high. the
R.Lefticaru等改进了S.Kalaji的适应度函数,他们把路径分解成多条独立子路径,并根据S.Kalaji的方法计算每条子路径的适应值,整条路径的适应值是各条子路径的适应值之和。他们给予那些满足较多条件的个体较好的适应值,这跟我们的方法类似。但是,他们的方法仍会碰到S.Kalaji方法一样的问题,而且我们不是总能找到路径的独立子路径。 R.Lefticaru et al. improved the fitness function of S.Kalaji. They decomposed the path into multiple independent sub-paths, and calculated the fitness value of each sub-path according to the method of S.Kalaji. The fitness value of the whole path is each sub-path The sum of fitness values. They give better fitness values to those individuals that meet more conditions, which is similar to our method. However, their method still suffers from the same problems as S. Kalaji's method, and we cannot always find independent subpaths of a path. the
发明内容 Contents of the invention
本发明要解决的技术问题是提供基于EFSM模型的路径测试数据生成方法,以扩展有穷状态机(EFSM)模型作为研究对象,使用遗传算法来生成面向EFSM路径的测试数据,在计算个体的适应度时同时考虑了它的分支距离和未覆盖的条件比率。在实验中,我们的方法与现有技术的S.Kalaji的方法进行了比较,结果表明我们的方法具有较好的效果并能获得质量较好的测试数据。 The technical problem to be solved in the present invention is to provide a path test data generation method based on the EFSM model, take the extended finite state machine (EFSM) model as the research object, use the genetic algorithm to generate the test data facing the EFSM path, and calculate the individual adaptation The degree takes into account both its branch distance and the ratio of uncovered conditions. In the experiment, our method is compared with the method of S. Kalaji in the prior art, and the results show that our method has better effect and can obtain test data with better quality. the
为达到上述目的,本发明的技术方案如下: To achieve the above object, the technical scheme of the present invention is as follows:
基于EFSM模型的路径测试数据生成方法,包括以下步骤: The path test data generation method based on EFSM model, comprises the following steps:
步骤一、对EFSM模型进行符号执行和数据流依赖分析,获得每条EFSM模型的路径约束; Step 1. Perform symbolic execution and data flow dependency analysis on the EFSM model to obtain the path constraints of each EFSM model;
步骤二、使用遗传算法生成满足路径约束的测试数据,给定初始个体; Step 2. Use the genetic algorithm to generate test data that satisfies the path constraints, given the initial individual;
步骤三、根据适应度函数评估初始个体的适应度值,若个体的适应值为0,那么这样的初始个体就是满足路径约束的测试数据,算法 终止; Step 3. Evaluate the fitness value of the initial individual according to the fitness function. If the fitness value of the individual is 0, then such an initial individual is the test data that satisfies the path constraint, and the algorithm terminates;
步骤四、若步骤三中的适应值没有超过设定的最大代数,可以在当前代中选取两个具有最小适应值的个体作为父个体进行交叉操作或变异操作,生成新一代个体,并对新一代个体重复步骤三和步骤四。 Step 4. If the fitness value in step 3 does not exceed the set maximum number of generations, two individuals with the minimum fitness value can be selected as the parent individuals in the current generation to perform crossover or mutation operations to generate a new generation of individuals, and the new generation Repeat steps 3 and 4 for one generation of individuals. the
在本发明的一个优选实施例中,所述步骤四中的适应值超过了设定的最大代数,算法终止。 In a preferred embodiment of the present invention, if the fitness value in step 4 exceeds the set maximum number of generations, the algorithm is terminated. the
在本发明的一个优选实施例中,所述步骤一中的路径约束采用平行的IF语句表示。 In a preferred embodiment of the present invention, the path constraints in step 1 are expressed by parallel IF statements. the
在本发明的一个优选实施例中,所述路径约束中只包含输入变量。 In a preferred embodiment of the present invention, the path constraints only include input variables. the
在本发明的一个优选实施例中,所述适应度函数是初始个体的分支距离与个体未覆盖的路径约束中的条件的比率之和。 In a preferred embodiment of the present invention, the fitness function is the sum of the ratios of the branch distances of the initial individual and the conditions in the path constraints not covered by the individual. the
通过上述技术方案,本发明的有益效果是: Through the above technical scheme, the beneficial effects of the present invention are:
对于具有复杂约束或涉及多变量的路径,我们的方法生成满足所有约束条件的测试数据的成功率要比S.Kalaji方法高的多; For paths with complex constraints or involving multiple variables, our method has a much higher success rate in generating test data that satisfies all constraints than the S.Kalaji method;
对于只能生成不能完全满足所有条件的测试数据的路径即包含等式的路径,我们以生成的测试数据违反的平均约束率来衡量生成测试数据的质量,我们的方法生成的测试数据质量要比S.Kalaji方法的要高。 For paths that can only generate test data that cannot fully satisfy all conditions, that is, paths that contain equations, we use the average constraint rate of the generated test data to measure the quality of the generated test data. The quality of the test data generated by our method is better than that of The method of S.Kalaji is higher. the
附图说明 Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些 附图获得其他的附图。 In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings on the premise of not paying creative work. the
图1为本发明的工作流程图。 Fig. 1 is the work flowchart of the present invention. the
图2a为本发明的实施例1的EFSM模型。 Fig. 2a is the EFSM model of embodiment 1 of the present invention. the
图2b为本发明的实施例2的EFSM模型。 Fig. 2b is the EFSM model of embodiment 2 of the present invention. the
图2c为本发明的实施例3的EFSM模型。 Fig. 2c is the EFSM model of embodiment 3 of the present invention. the
图3a为本发明的简单飞机安全系统的扩展状态机模型生成测试数据的平均代数。 Figure 3a is the average generation of test data generated for the extended state machine model of the simple aircraft safety system of the present invention. the
图3b为本发明的简单飞机安全系统的扩展状态机模型生成测试数据的成功率。 Fig. 3b is the success rate of generating test data for the extended state machine model of the simple aircraft safety system of the present invention. the
图3c为本发明的传输协议的扩展状态机模型生成测试数据的平均代数。 Fig. 3c is the average generation of test data generated by the extended state machine model of the transmission protocol of the present invention. the
图3d为本发明的电梯系统的扩展状态机模型生成的测试数据的平均代数。 Figure 3d is the average generation of test data generated by the extended state machine model of the elevator system of the present invention. the
图3e为本发明的电梯系统的扩展状态机模型生产的测试数据违反的平均约束率。 Fig. 3e is the average constraint rate of test data violations produced by the extended state machine model of the elevator system of the present invention. the
具体实施方式Detailed ways
为了使本发明实现的技术手段、创作特征、达成目的与功效易于明白了解,下面结合具体图示,进一步阐述本发明。 In order to make the technical means, creative features, goals and effects achieved by the present invention easy to understand, the present invention will be further described below in conjunction with specific illustrations. the
参照图1,基于EFSM模型的路径测试数据生成方法,包括以下步骤: Referring to Fig. 1, the path test data generation method based on EFSM model comprises the following steps:
步骤一、对于EFSM模型进行符号执行和数据流依赖分析,获得每条EFSM路径的路径约束。 Step 1: Perform symbolic execution and data flow dependency analysis on the EFSM model to obtain path constraints for each EFSM path. the
步骤二、使用遗传算法生成满足路径约束的测试数据,给定初始个体。 Step 2: Use the genetic algorithm to generate test data satisfying the path constraints, and an initial individual is given. the
步骤三、根据适应度函数评估个体的适应度值,这里的适应度函数是个体的分支距离与个体未覆盖的路径约束中的条件的比率之和。如果个体的适应值为0,那么这样的个体就是满足路径约束的测试数据,算法终止。 Step 3. Evaluate the fitness value of the individual according to the fitness function, where the fitness function is the sum of the ratios of the branch distance of the individual to the condition in the path constraint not covered by the individual. If the individual's fitness value is 0, then such an individual is the test data that satisfies the path constraint, and the algorithm terminates. the
步骤四、否则,如果没有超过设定的最大代数,可以在当前代中选取两个具有最小适应值的个体作为父个体进行交叉操作,生成新一代的个体;或者在当前代中选取一个具有最小适应值的个体作为父个体进行变异操作,生成新一代的个体。如果超过了设定的最大代数,算法终止。重复步骤三-步骤四。 Step 4. Otherwise, if the set maximum number of generations is not exceeded, two individuals with the minimum fitness value can be selected in the current generation as the parent individuals for crossover operation to generate a new generation of individuals; or one individual with the minimum fitness value can be selected in the current generation. The individual with the fitness value is used as the parent individual for mutation operation to generate a new generation of individuals. If the set maximum number of generations is exceeded, the algorithm terminates. Repeat steps three to four. the
与本发明有关的概念如下: Concepts relevant to the present invention are as follows:
1.1扩展的有穷状态机(EFSM) 1.1 Extended Finite State Machine (EFSM)
有穷状态机(FSM)是一种Mealy自动机,它包含了有穷状态集、迁移集和输入输出集。由于其不能建模系统的数据部分,所以本文采用扩展的有穷状态机作为系统模型。扩展的有穷状态机在FSM的基础上扩展了上下文变量、谓词和操作。 A finite state machine (FSM) is a Mealy automaton that includes a finite state set, a transition set, and an input-output set. Because it cannot model the data part of the system, this paper adopts the extended finite state machine as the system model. The extended finite state machine extends context variables, predicates and operations on the basis of FSM. the
EFSM是一个六元组(S;s0;V;I;O;T),其中S是有穷状态集合;s0是初始状态;V是上下文变量的集合;I是有穷的输入消息集合;O是有穷的输出消息集合;T是有穷的迁移集合。 EFSM is a six-tuple (S; s 0 ; V; I; O; T), where S is a finite set of states; s 0 is an initial state; V is a set of context variables; I is a finite set of input messages ; O is a finite output message set; T is a finite migration set.
迁移t∈T是一个五元组(ss;i;g;op;se),其中ss是t的源状态;i∈I是输入,它可能与输入参数有关;g是称为监护条件的逻辑表达式;op是由赋值语句或输出语句等组成的操作;se是t的目标状态。 A transition t ∈ T is a five-tuple (s s ; i; g; op; s e ), where s s is the source state of t; i ∈ I is the input, which may be related to the input parameters; A logical expression of a condition; op is an operation composed of an assignment statement or an output statement, etc.; s e is the target state of t.
当在状态ss时,如果接收的是输入i且监护条件g满足,那么触发 迁移t=(ss;i;g;op;se),同时执行op中的操作且状态转换为se。g和op都可以包含输入参数和上下文变量。我们这里只考虑确定的EFSMs。如果对于从同一状态出发的具有相同输入的多个迁移,一次只有一个迁移的监护条件满足,即一次只能触发一个迁移,那么EFSM是确定的。 When in the state s s , if the input i is received and the monitoring condition g is satisfied, then trigger transition t=(s s ; i; g; op; s e ), at the same time execute the operation in op and the state transitions to s e . Both g and op can contain input parameters and context variables. We only consider identified EFSMs here. An EFSM is deterministic if, for multiple transitions from the same state with the same input, only one transition's guard condition is satisfied at a time, i.e., only one transition can be triggered at a time.
在EFSM中,迁移的监护条件可以由逻辑运算符AND和OR连接。由AND连接的监护条件我们表示成嵌套的IF语句。由OR连接的监护条件,我们把它划分成OR操作符个数+1个迁移,分别计算它们的适应值,最后把它们之间的最小值作为整个监护条件的适应值。 In EFSM, transition guard conditions can be connected by logical operators AND and OR. Guardian conditions connected by AND we express as nested IF statements. For the guardianship condition connected by OR, we divide it into the number of OR operators + 1 transition, calculate their fitness values respectively, and finally take the minimum value between them as the fitness value of the whole guardianship condition. the
1.2符号执行 1.2 Symbolic execution
符号执行是一种静态的程序分析方法,它使用符号值而不是实际值来执行程序,执行的结果是一个关于符号的表达式。这对于分析输入和输出之间的关系很有用。 Symbolic execution is a static program analysis method that uses symbolic values instead of actual values to execute programs, and the result of execution is an expression about symbols. This is useful for analyzing the relationship between inputs and outputs. the
当符号执行应用到路径的测试数据生成中时,它就把测试数据生成问题刻画成了求解用符号值执行路径后得到的符号表达式的问题。例如,考虑迁移路径t1t2t3,各个迁移中的谓词分别是x>0,y<15,z≥10,我们分别用符号值a,b,c代入变量x,y,z,用符号值执行路径t1t2t3后得到符号表达式(a>0ANDb<15ANDc≥10),生成路径t1t2t3测试数据的问题就转换成了寻找符号表达式(a>0ANDb<15ANDc≥10)解的问题。 When symbolic execution is applied to the test data generation of paths, it characterizes the test data generation problem as a problem of solving the symbolic expressions obtained after executing paths with symbolic values. For example, considering the transition path t 1 t 2 t 3 , the predicates in each transition are x>0, y<15, z≥10, we use symbolic values a, b, c to substitute variables x, y, z respectively, and use The symbolic value executes the path t 1 t 2 t 3 to obtain the symbolic expression (a>0ANDb<15ANDc≥10), and the problem of generating the test data of the path t 1 t 2 t 3 is transformed into finding the symbolic expression (a>0ANDb< 15ANDc≥10) to solve the problem.
1.3数据流依赖 1.3 Data flow dependency
在EFSM中存在一些输入变量和上下文变量。通常我们只用输入变量来表示需要求解的符号表达式。那么对于路径中的上下文变量我 们需要使用数据流分析技术把它们替换成相应的值和输入变量。 There are some input variables and context variables in EFSM. Usually we only use input variables to represent the symbolic expression to be solved. Then for the context variables in the path, we need to use data flow analysis techniques to replace them with corresponding values and input variables. the
给定变量v,如果v在迁移t中作为输入参数或在t的操作中被赋值,那么称v在t中被定义,记为def(t)。如果v在迁移t的谓词中引用(p-use)中或操作中引用(c-use),那么称v在t中被使用,记为use(t)。 Given a variable v, if v is used as an input parameter in the migration t or is assigned a value in the operation of t, then v is said to be defined in t, denoted as def(t). If v is referenced in the predicate of migration t (p-use) or referenced in the operation (c-use), then v is said to be used in t, denoted as use(t). the
给定从迁移ti到tj的迁移路径,v∈def(ti)且v∈use(tj),如果v在ti和tj间的迁移上都没有重新定义,那么我们称从ti到tj的路径为v的定义清晰路径。(ti;tj)称为v的定义-引用对,tj数据依赖于ti。 Given a migration path from t i to t j , v∈def(t i ) and v∈use(t j ), if v is not redefined on the transfer between t i and t j , then we call The path from t i to t j is a well-defined path of v. (t i ; t j ) is called a definition-reference pair of v, and the data of t j depends on t i .
在得到每个迁移上上下文变量的数据流依赖后,我们采用后向替换技术把这些上下文变量替换成相应的值和输入变量。所谓后向替换,就是从路径的最后一个迁移从后往前处理,把迁移上引用的变量替换成它所依赖的定义,最后得到的路径表达式是只包含了输入变量的符号表达式。 After getting the data flow dependencies of context variables on each transition, we use the backward replacement technique to replace these context variables with corresponding values and input variables. The so-called backward replacement means that the last migration of the path is processed from the back to the front, and the variable referenced in the migration is replaced with the definition it depends on. The final path expression obtained is a symbolic expression that only contains input variables. the
1.4遗传算法 1.4 Genetic Algorithm
基于搜索的测试方法把测试数据的生成问题表示成了最优化问题。在基于搜索的测试方法中必须要选择一种表示候选解的方式和一种评估候选解的方法。候选解的表示方式通常有二进制、整型和实型编码。而评估候选解的方法我们通常称为适应度函数。适应度函数是用来衡量候选解优劣的方法,它给每个候选解赋一个正数,这个正数用来评估候选解离可接受的解还有多远。因为最优化问题通常是最小化问题,所以具有较低适应值的候选解较好,具有适应值是0的解则是可接受的解。 Search-based testing methods formulate the problem of generating test data as an optimization problem. In search-based testing methods it is necessary to choose a way of representing candidate solutions and a method of evaluating candidate solutions. Candidate solutions are usually expressed in binary, integer and real codes. The method of evaluating candidate solutions is usually called the fitness function. The fitness function is a method used to measure the pros and cons of candidate solutions. It assigns a positive number to each candidate solution, and this positive number is used to evaluate how far the candidate is from an acceptable solution. Since optimization problems are usually minimization problems, candidate solutions with lower fitness values are better, and solutions with a fitness value of 0 are acceptable solutions. the
当我们选择好编码方式和定义了适应度函数后,就可以使用元启 发式搜索技术。而遗传算法则是一种功能强大的元启发式技术。在遗传算法中每个解我们称为染色体,它们是由基因组成的。遗传算法的主要流程是对种群中的个体使用适应度函数进行评估,选择具有较好适应值的解作为父个体,然后通过交叉和变异操作生成下一代的新个体。 After we have chosen the encoding method and defined the fitness function, we can use the meta-heuristic search technology. The genetic algorithm is a powerful meta-heuristic technique. In the genetic algorithm, each solution is called a chromosome, which is composed of genes. The main process of the genetic algorithm is to evaluate the individuals in the population using the fitness function, select the solution with a better fitness value as the parent individual, and then generate the next generation of new individuals through crossover and mutation operations. the
下文对S.Kalaji方法与本发明的实施例进行对比说明: The S.Kalaji method is compared with the embodiments of the present invention below:
我们从三个方面来分析。 We analyze it from three aspects. the
参照图2a为本发明的EFSM模型的实施例1(Simple in-flight safety system EFSM—简单的飞机安全系统的扩展状态机模型),为第一个方面是生成测试数据的平均代数。 Referring to Fig. 2 a, it is embodiment 1 (Simple in-flight safety system EFSM-the extended state machine model of simple aircraft safety system) of the EFSM model of the present invention, is the average algebra that generates test data for the first aspect. the
参照图2b为本发明的EFSM模型的实施例2(Class II transport protocol EFSM—传输协议的扩展状态机模型),为第二个方面是在不能100%生成测试数据的情况下,考虑两种方法的成功率。 Referring to Fig. 2b, it is embodiment 2 (Class II transport protocol EFSM—extended state machine model of transmission protocol) of the EFSM model of the present invention, for the second aspect is under the situation that test data cannot be generated 100%, consider two methods success rate. the
参照图2c为本发明的EFSM模型的实施例3(Lift system EFSM—电梯系统的扩展状态机模型),为第三个方面是在完全不能生成满足约束条件的测试数据的情况下,考虑生成的测试数据违反路径中约束的平均比率。 Referring to Fig. 2c, it is the embodiment 3 (Lift system EFSM-extended state machine model of elevator system) of the EFSM model of the present invention, for the third aspect is under the situation that the test data that satisfies constraint condition can not be generated at all, consider generating The average rate at which the test data violates the constraints in the path. the
我们的方法和S.Kalaji的方法都用Genetic Algorithm and Direct Search Toolbox for Mathlab 7.0来实现。我们使用实型编码表示个体,采用随机均匀选择,选择标量交叉,交叉概率为0.8,使用高斯变异,选择种群大小为20,每个变量的初始取值范围是[0…100],搜索终止的条件是适应值为0或者到达最大代数1000。 为每条迁移路径执行搜索10次。 Both our method and S.Kalaji's method are implemented with Genetic Algorithm and Direct Search Toolbox for Mathlab 7.0. We use real coding to represent individuals, use random uniform selection, select scalar crossover, the crossover probability is 0.8, use Gaussian variation, select the population size as 20, the initial value range of each variable is [0…100], the search terminates The condition is that the fitness value is 0 or the maximum number of generations is 1000. Perform the search 10 times for each migration path. the
参照3a,图3b,图3c以及图3d;根据迁移覆盖准则,Simple in-flight safety system EFSM总共有20条迁移路径,为这20条路径生成测试数据的平均代数见图3(a)。 Refer to Figure 3a, Figure 3b, Figure 3c, and Figure 3d; according to the migration coverage criterion, Simple in-flight safety system EFSM has a total of 20 migration paths, and the average generation of test data generated for these 20 paths is shown in Figure 3(a). the
两种方法在对除了路径p2;p17;p18;p19;p20;p21外的其它路径生成测试数据时,它们的平均代数大致相同,都在52左右。这是可能因为在这些路径中,它们的约束都很简单,并且只涉及单个变量。对于这样的情况,两种方法的性能相同。在对路径p2;p17;p18;p19;p20;p21生成测试数据时,我们提出的方法的平均代数要比S.Kalaji的方法的高。 When the two methods generate test data for paths other than the path p 2 ; p 17 ; p 18 ; p 19 ; p 20 ; p 21 , their average algebra is roughly the same, about 52. This is possible because in these paths, their constraints are simple and involve only a single variable. For such cases, the performance of both methods is the same. When generating test data for the paths p 2 ; p 17 ; p 18 ; p 19 ; p 20 ; p 21 , the average algebra of our proposed method is higher than that of S. Kalaji's method.
两种方法都不能在10次搜索中每次都成功生成满足路径约束的测试数据,但是我们的方法生成测试数据的成功概率要比S.Kalaji的方法高的多,两种方法为这6条路径生成测试数据的成功率见图3(b)。 Neither method can successfully generate test data that satisfies path constraints every time in 10 searches, but our method has a much higher probability of success in generating test data than S.Kalaji's method. The success rate of path generation test data is shown in Fig. 3(b). the
这是可能这6条路径的约束较复杂,并且涉及多个变量,S.Kalaji的方法在个体不满足较外层的约束时就给它赋较高的适应值,可是有些个体虽然不满足个别外层约束但满足多个内层约束,选择这样的个体可能会生成最优解。这样的个体在S.Kalaji生成测试数据的过程中却被舍弃了,导致S.Kalaji方法较快的收敛即较快的获得较差的最优解,所以导致他不能为具有复杂约束的路径生成测试数据。 It is possible that the constraints of these 6 paths are more complex and involve multiple variables. The method of S.Kalaji assigns a higher fitness value to individuals when they do not meet the constraints of the outer layer, but some individuals do not satisfy individual Selecting individuals whose outer constraints satisfy multiple inner constraints is likely to generate an optimal solution. Such individuals are discarded in the process of generating test data by S.Kalaji, which leads to the faster convergence of the S.Kalaji method, that is, to obtain a poorer optimal solution faster, so it cannot be generated for paths with complex constraints. Test Data. the
而我们提出的方法考虑了个体对于约束的覆盖情况,覆盖率越高 的个体适应值越低。我们的方法会选择可能生成最优解的个体,即不满足外层约束但满足多个内层约束的个体。所以导致生成测试数据时平均代数比S.Kalaji方法要高,但是生成测试数据的成功率要比S.Kalaji方法高的多。 However, the method we propose considers the coverage of constraints by individuals, and the higher the coverage, the lower the fitness value of the individual. Our method selects individuals that are likely to generate optimal solutions, i.e. individuals that do not satisfy the outer constraints but satisfy multiple inner constraints. Therefore, the average algebra when generating test data is higher than that of the S.Kalaji method, but the success rate of generating test data is much higher than that of the S.Kalaji method. the
类似地,根据迁移覆盖准则,Transport Protocol EFSM总共有12条路径,为这12条路径生成测试数据的平均代数见图3(c)。两种方法都能为除了p8以外的路径生成测试数据,且平均代数几乎相同。不能为p8生成测试数据的原因是p8的路径约束中包含等式,而等式是很难满足的。 Similarly, according to the migration coverage criterion, Transport Protocol EFSM has a total of 12 paths, and the average number of generations to generate test data for these 12 paths is shown in Fig. 3(c). Both methods generate test data for paths other than p 8 with almost the same average algebra. The reason why test data cannot be generated for p 8 is that the path constraints of p 8 contain equations, which are difficult to satisfy.
Lift System EFSM中有24条路径,其中只有p1和p2两条路径可以通过遗传算法获取数据。对于其它路径来说,两种方法都不能生成满足约束条件的测试数据,但是我们的方法生成最优解的平均代数比S.Kalaji的方法高,造成这个结果的原因同In Flight Safety System EFSM中的解释。对于这些未能生成测试数据的路径,为了分析两种方法的优劣,我们从生成的测试数据违反的平均约束比率来进行比较。S.Kalaji的方法违反的平均约束比率在80%上下,而我们的方法违反的平均约束比率在10%上下,也就是说我们的方法生成的测试数据除了违反了等式以外其它约束都是满足。我们以测试数据违反的平均约束比率来衡量测试数据的质量,违反的平均约束比率越低,则测试数据质量越高。从图3e来看,我们的方法生成的测试数据的质量要比S.Kalaji方法高很多。 There are 24 paths in Lift System EFSM, of which only two paths p1 and p2 can obtain data through genetic algorithm. For other paths, neither method can generate test data that satisfies the constraints, but the average algebra of the optimal solution generated by our method is higher than that of S.Kalaji's method. The reason for this result is the same as that in In Flight Safety System EFSM explanation of. For these paths that fail to generate test data, in order to analyze the pros and cons of the two methods, we compare them from the average constraint ratio of the generated test data violations. The average constraint ratio of S.Kalaji's method violation is around 80%, while the average constraint ratio of our method is around 10%, that is to say, the test data generated by our method satisfies all constraints other than the violation of the equation . We measure the quality of the test data by the average constraint ratio violated by the test data, and the lower the average constraint ratio violated, the higher the quality of the test data. From Figure 3e, the quality of test data generated by our method is much higher than that of S.Kalaji method. the
以上显示和描述了本发明的基本原理和主要特征和本发明的优 点。本行业的技术人员应该了解,本发明不受上述实施例的限制,上述实施例和说明书中描述的只是说明本发明的原理,在不脱离本发明精神和范围的前提下,本发明还会有各种变化和改进,这些变化和改进都落入要求保护的本发明范围内。本发明要求保护范围由所附的权利要求书及其等效物界定。 The basic principles and main features of the present invention and advantages of the present invention have been shown and described above. Those skilled in the industry should understand that the present invention is not limited by the above-mentioned embodiments. What are described in the above-mentioned embodiments and the description only illustrate the principle of the present invention. Without departing from the spirit and scope of the present invention, the present invention will also have Variations and improvements are possible, which fall within the scope of the claimed invention. The protection scope of the present invention is defined by the appended claims and their equivalents. the
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410561899.4A CN104461861B (en) | 2014-10-21 | 2014-10-21 | Path test data generation method based on EFSM models |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410561899.4A CN104461861B (en) | 2014-10-21 | 2014-10-21 | Path test data generation method based on EFSM models |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104461861A true CN104461861A (en) | 2015-03-25 |
CN104461861B CN104461861B (en) | 2018-07-27 |
Family
ID=52907950
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410561899.4A Active CN104461861B (en) | 2014-10-21 | 2014-10-21 | Path test data generation method based on EFSM models |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104461861B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104765690A (en) * | 2015-04-22 | 2015-07-08 | 哈尔滨工业大学 | Embedded software test data generating method based on fuzzy-genetic algorithm |
CN104881359A (en) * | 2015-06-10 | 2015-09-02 | 南京大学 | Method for automatically generating test data realizing path covering through linear fitting |
CN107153605A (en) * | 2016-03-02 | 2017-09-12 | 阿里巴巴集团控股有限公司 | The generation method and device of test sample |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010123111A (en) * | 2008-11-21 | 2010-06-03 | Toyota Motor Engineering & Manufacturing North America Inc | Method and system for automatic test data generation for lookup table |
CN102368226A (en) * | 2011-10-10 | 2012-03-07 | 南京大学 | Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine) |
US20140026125A1 (en) * | 2012-07-23 | 2014-01-23 | Infosys Llimited | Methods for generating software test input data and devices thereof |
CN104077228A (en) * | 2014-07-08 | 2014-10-01 | 浙江理工大学 | EFSM performable test sequence generating method based on predicate dependency graph |
-
2014
- 2014-10-21 CN CN201410561899.4A patent/CN104461861B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010123111A (en) * | 2008-11-21 | 2010-06-03 | Toyota Motor Engineering & Manufacturing North America Inc | Method and system for automatic test data generation for lookup table |
CN102368226A (en) * | 2011-10-10 | 2012-03-07 | 南京大学 | Method for automatically generating test cases based on analysis on feasible paths of EFSM (extended finite state machine) |
US20140026125A1 (en) * | 2012-07-23 | 2014-01-23 | Infosys Llimited | Methods for generating software test input data and devices thereof |
CN104077228A (en) * | 2014-07-08 | 2014-10-01 | 浙江理工大学 | EFSM performable test sequence generating method based on predicate dependency graph |
Non-Patent Citations (2)
Title |
---|
KALAJI A S, HIERONS R M, SWIFT S: "An integrated search-based approach for automatic testing from extended finite state machine (EFSM) models", 《INFORMATION AND SOFTWARE TECHNOLOGY》 * |
LEFTICARU R, IPATE F: "An improved test generation approach from extended finite state machines using genetic algorithms", 《INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING AND FORMAL METHODS》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104765690A (en) * | 2015-04-22 | 2015-07-08 | 哈尔滨工业大学 | Embedded software test data generating method based on fuzzy-genetic algorithm |
CN104765690B (en) * | 2015-04-22 | 2017-10-27 | 哈尔滨工业大学 | Embedded software test data generation method based on fuzzy genetic algorithm |
CN104881359A (en) * | 2015-06-10 | 2015-09-02 | 南京大学 | Method for automatically generating test data realizing path covering through linear fitting |
CN104881359B (en) * | 2015-06-10 | 2017-11-24 | 南京大学 | A kind of automatic generation of test data covered with linear fit realizing route |
CN107153605A (en) * | 2016-03-02 | 2017-09-12 | 阿里巴巴集团控股有限公司 | The generation method and device of test sample |
CN107153605B (en) * | 2016-03-02 | 2021-07-06 | 阿里巴巴集团控股有限公司 | Test sample generation method and device |
Also Published As
Publication number | Publication date |
---|---|
CN104461861B (en) | 2018-07-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Bryce et al. | SMT-based nonlinear PDDL+ planning | |
CN106294120A (en) | The test method of code, equipment and computer program | |
CN110287002A (en) | A method and system for detecting defects in an Ethereum virtual machine | |
Duret-Lutz et al. | Self-loop aggregation product—a new hybrid approach to on-the-fly LTL model checking | |
CN107103244B (en) | AADL-based Web application architecture security evaluation method | |
CN101710305B (en) | Method and system for realizing white box testing of computer software | |
CN107025169A (en) | A kind of software error layering diagnostic method based on Bayesian Network Inference | |
CN104461861B (en) | Path test data generation method based on EFSM models | |
US9043746B2 (en) | Conducting verification in event processing applications using formal methods | |
CN105068928A (en) | Complex network theory based software test use-case generating method | |
CN110825548B (en) | Anomaly detection method, model training method and related device | |
Geyer et al. | On the robustness of deep learning-predicted contention models for network calculus | |
CN105577432A (en) | A Prediction Method of Network Packet Loss Probability Based on Correlation Analysis | |
JPWO2013085025A1 (en) | Minimum cut set evaluation system, minimum cut set calculation method and program | |
Anand et al. | Information flow in parameterized quantum circuits | |
Zhang et al. | EcoAct: Economic Agent Determines When to Register What Action | |
CN104639430A (en) | Methods and systems for determining community gatekeepers in networked systems | |
GB2534375A (en) | Improvements in and relating to network analysis | |
CN112699376A (en) | Source code logic vulnerability detection method and device, computer equipment and storage medium | |
Bergami | Fast Synthetic Data-Aware Log Generation for Temporal Declarative Models | |
CN116560882A (en) | Fault root cause positioning method, device, equipment and computer storage medium | |
Li et al. | Analysis of care pathway variation patterns in patient records | |
US11080266B2 (en) | Graph functional dependency checking | |
CN108197314B (en) | A Modeling Verification Method for Historical Transactions | |
JP2010238057A (en) | Apparatus, method and program for extracting test restriction |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |