WO2017201853A1 - Method for locating program regression fault using slicing model - Google Patents

Method for locating program regression fault using slicing model Download PDF

Info

Publication number
WO2017201853A1
WO2017201853A1 PCT/CN2016/090956 CN2016090956W WO2017201853A1 WO 2017201853 A1 WO2017201853 A1 WO 2017201853A1 CN 2016090956 W CN2016090956 W CN 2016090956W WO 2017201853 A1 WO2017201853 A1 WO 2017201853A1
Authority
WO
WIPO (PCT)
Prior art keywords
statement
program
statements
execution
slice
Prior art date
Application number
PCT/CN2016/090956
Other languages
French (fr)
Chinese (zh)
Inventor
刘烃
王海军
郑庆华
管晓宏
陈泽华
朱海萍
Original Assignee
西安交通大学
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 西安交通大学 filed Critical 西安交通大学
Publication of WO2017201853A1 publication Critical patent/WO2017201853A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • 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/3688Test management for test execution, e.g. scheduling of test suites

Definitions

  • the invention relates to the field of trusted software and software testing, in particular to a method for locating regression errors in a program.
  • ADD Algmented Delta Debugging
  • AFTER Automatic Fault Explanation for Regression testing
  • the automatic isolation of ADD by combining coverage analysis and Delta debugging results in a modification of program execution failure.
  • ADD does not analyze the semantics of the program, so the misplacement of the positioning may simply avoid the failure of the program execution and not the real error.
  • AFTER uses dynamic analysis based on Delta debugging and semantic analysis based on symbol analysis to locate regression errors.
  • the main problem with AFTER is its extensibility. As we all know, symbol analysis is a huge process, so it is difficult to apply to large-scale programs.
  • a practical regression error localization technique not only requires precise positioning to cause errors, but also provides a context in which the modification causes the program to fail.
  • the object of the present invention is to propose a program regression error localization method based on a slice model.
  • the program behavior slice causing the program regression error is output, and the problem of regression error location in the program test is solved.
  • a program regression error location method based on a slice model includes the following steps:
  • the execution trajectory is organized into a tree structure, each node of the tree is a function execution sequence; the trajectory function body statement corresponding method is called, and the execution trajectory of the two versions of the program extracted in step S2) is corresponding;
  • step S6 determining whether the slice analysis queue is empty, if it is empty, then jumping to step S9), otherwise jumping to step S7);
  • step S7 take out the first end statement of the slice analysis queue, and determine whether the first end statement needs to be sliced, if not required Analysis then jumps to step S6), otherwise jumps to step S8);
  • step S8 adding the current analysis sentence to the regression error slice, and adding the dependency statement and the corresponding statement that need to be sliced according to the sentence classification in step S4) to the slice analysis queue;
  • a further improvement of the present invention is that the process of code rearrangement in the step S1) comprises the following steps:
  • each of the two versions of the program source code is divided into two categories: identical statements, modified statements;
  • a further improvement of the present invention is that the tree structure of the execution trajectory in step S3) is defined as follows: each node in the tree is an execution trajectory of a function body, and a child node of one node is called in a function body represented by the node The execution trajectory of the function body; in step S3), the trajectory function body statement is correspondingly started from the root node of the tree structure (main function body trajectory), and specifically includes the following steps:
  • step S301 determining whether the corresponding statement in the currently corresponding function body needs to be empty, if it is empty, the function body statement corresponding method execution end returns, otherwise, the process proceeds to step S302);
  • step S303 determining whether the current corresponding statement is a function call statement, if it is a function call statement, then jumping to step S304), otherwise jumping to step S306);
  • step S304 determining whether the function call has a corresponding function call in the corresponding track, if there is a corresponding function call, then jump to step S305), otherwise jump to step S301);
  • step S305 calling the function body statement corresponding method corresponding to the statement in the function body track, after the execution ends, the process proceeds to step S301);
  • step S306 determining whether the current statement has a corresponding statement in the corresponding track, if there is a corresponding statement, then jump to step S307), otherwise jump to step S301);
  • step S307 the current statement is associated with the corresponding statement in the corresponding track, and after the process ends, the process proceeds to step S301).
  • a further improvement of the present invention is that the strategy for classifying the sentences in step S4) is to classify all the statements in the track into the following four categories according to the source code sentence classification, the track correspondence result, and the variable value information contained in the statement in step S102):
  • the classification process includes the following steps:
  • step S401 determining whether the statements in the trajectory have all been classified, if all the classifications have been performed, then the process proceeds to step S407), otherwise, the process proceeds to step S402);
  • step S403 determines whether the statement is a modified statement, if the modified statement is marked as modified resulting in a different statement and jump to step S401), otherwise jump to step S404);
  • step S404 determines whether the statement has a corresponding statement, if there is no corresponding statement, the statement is marked as a different flow statement and jump to step S401), otherwise jump to step S405);
  • step S405 according to the variable value information included in the statement, determining whether the statement and the variable value included in the corresponding statement are the same, and if at least one variable value is not the same, marking the statement as a statement having a different value and jumping to step S401) Otherwise, go to step S406);
  • step S406 marking the statement as a consistent statement and jumping to step S401);
  • a further improvement of the present invention is that the criterion for determining whether the statement needs to be sliced in step S7) is that if the statement has been analyzed or belongs to the statement consistent in step S4), no slice analysis is required, otherwise the slice needs to be sliced. analysis.
  • a further improvement of the present invention is that the analysis strategy of the statement that needs to be sliced in step S8) is that, for the statement with different median value in step S4), only the data dependency statement and the corresponding statement in the corresponding track are added to the slice analysis queue; For statements with different flows, only the control dependency statement is added to the slice analysis queue; for the classification to modify to cause different statements, the control dependency and data dependency statements are added to the slice analysis queue.
  • the current statement analyzed in step S8) needs to be added to the regression error slice.
  • the present invention proposes a program regression error localization method based on a slice model, and performs slice analysis on two versions of the program to output a program behavior slice that causes a program regression error. Solve the problem of regression error location in program testing.
  • the method compares the two versions of the program source code, identifies different parts thereof, and rearranges the source code of the two versions of the program according to the recognition result, so that the two sequences are executed without affecting the execution order of the program code.
  • the original corresponding code in the version program has the same line number; in the corresponding stage of the track, the statements on the two execution tracks are performed according to the execution trajectory of the obtained two versions of the program, the dependency relationship between the statements, and the variable value information. Corresponding, and classifying the sentences according to the corresponding results of the trajectory; in the slice analysis stage, based on the control dependence of the program, the data dependency, and the classification of the statements, the slice analysis is started from the new program execution failure point as the starting point; Its dependency, backtracking the statement entity that caused the program to fail, until the dependency statement to be analyzed is empty, and the analyzed current statement does not need to continue to analyze its dependencies; finally, all the parsed statement entities in the stage of the slice analysis are Program behavior slice output that causes regression errors. Compared with the existing regression error localization method, this method clarifies the mechanism of regression error and has a guiding role in the repair of regression errors.
  • Figure 1 is a general flow chart of the method of the present invention
  • FIG. 3 is a flow chart of a method corresponding to a function body statement
  • Figure 4 is a flow chart of the sentence classification process
  • Figure 5 is a schematic diagram showing an exemplary procedure in a specific embodiment
  • Figure 6 is a comparison of the results of the source code
  • Figure 7 is a diagram of code rearrangement results
  • Figure 8 is a diagram corresponding to the trajectory
  • Figure 9 is a regression error slice diagram
  • Figure 10 is a diagram of a slice analysis process.
  • the program to be tested v1 is the original version
  • the program to be tested v2 is the modified new version.
  • Step S1 Calculate the difference between the source code of the two versions of the program according to the two versions of the program to be tested, and rearrange the source code of the two versions according to the source code, so that the same code has the same line number.
  • the different codes correspond to the blank lines.
  • the flow chart is shown in Figure 2. Specifically, the following steps are included:
  • Step S101 Calculate the difference between the source codes of the two versions according to the source code of the two versions of the program
  • Step S102 According to the calculated difference between the source code of the two versions of the program, the statements in the source code are divided into two categories, the same statement and the modified statement, and the modified statement is marked (c1-c4), as shown in FIG. 6. Shown
  • Step S103 On the basis of not changing the execution order of the program statement, the identical statements have the same line number, the modified statement corresponds to the blank line, and the code rearrangement result is as shown in FIG. 7;
  • Step S104 The two versions of the program source code to be tested after the code rearrangement are output as a new program to be tested.
  • Program v1 track Main#c 1 2 3 5 6 7 11 12 13 mian#r
  • Program v2 track Mian#c 1 2 4 8 9 11 12 13 main#r
  • Step S3 Calling the trajectory function body sentence corresponding method, corresponding to the execution trajectory of the two versions of the program extracted in step S2), the flowchart is as shown in FIG. 3, and the function body statement corresponding method:
  • step S301 determining whether the corresponding statement in the currently corresponding function body needs to be empty, if it is empty, the function body statement corresponding method execution end returns, otherwise, the process proceeds to step S302);
  • step S303 determining whether the current corresponding statement is a function call statement, if it is a function call statement, then jumping to step S304), otherwise jumping to step S306);
  • step S304 determining whether the function call has a corresponding function call in the corresponding track, if there is a corresponding function call, then jump to step S305), otherwise jump to step S301);
  • step S305 calling the function body statement corresponding method to correspond to the statement in the function body track, after the execution ends, the process proceeds to step S301);
  • step S306 determining whether the current statement has a corresponding statement in the corresponding track, if there is a corresponding statement, then jump to step S307), otherwise jump to step S301);
  • the specific process includes:
  • Step S301 the main function body needs to be corresponding to the statement is not empty, so go to S302;
  • Step S302 taking out the statement 1 in the program v1 that the main does not respond, go to step S303;
  • Step S303 statement 1 is not a function call statement, proceeds to step S306;
  • Step S306 The main function statement 1 in the path v1 track corresponds to the main function statement 1 in the program v2 track, and the process proceeds to step S307;
  • Step S307 Corresponding to the main function statement 1 in the two version program tracks, and marking the corresponding statement.
  • Step S4 According to the difference of the source code, the track corresponding result, and the variable value included in the statement, the statements in the track are divided into four categories: modifying different statements, different statements, different values, and consistent statements.
  • the classification strategy is as follows:
  • step S401 determining whether the statements in the track have been all classified, if all the categories have been classified, then the process proceeds to step S407), otherwise, the process proceeds to step S402);
  • step S403 according to the classification of the source code, determine whether the statement is a modified statement, if the modified statement is marked as modified resulting in a different statement and jump to step S401), otherwise jump to step S404);
  • step S404 determining whether the statement has a corresponding statement according to the result of the track correspondence, if there is no corresponding statement, marking the statement as a statement with a different flow and jumping to step S401), otherwise jumping to step S405);
  • step S405) determining, according to the variable value information included in the statement, whether the value of the variable included in the statement and the corresponding statement is the same, such as If at least one variable value is not the same, the statement is marked as a statement with a different value and jumps to step S401), otherwise jumps to step S406);
  • the specific classification process includes:
  • Step S401 the statements in the trajectory are not all classified, and the process proceeds to S402;
  • Step S402 Extract the unclassified statement 2 in the track
  • Step S403 statement 2 non-modified statement, go to S403;
  • Step S403 statement 2 has a corresponding statement, and proceeds to S404;
  • Step S404 the two variables in the two sentences contain the same variable value, go to step S405;
  • Step S405 Mark the statement 2 in the two tracks as a consistent statement.
  • Step S5 Begin the slice analysis by generating the failure point of the new version program as a starting point, and add the failure point statement to the slice analysis queue.
  • the new version program is program v2
  • the execution failure point statement is the output point.
  • Statement 13 in the program v2 track is added to the slice analysis queue;
  • Step S6 determining whether the slice analysis queue is empty, if it is empty, then jumping to step S9), otherwise jumping to step S7), the current queue is not empty, so the process goes to step S7);
  • Step S7 taking out the first end statement of the slice analysis queue, and determining whether the first end statement needs to perform slice analysis. If no analysis is needed, the process jumps to step S6), otherwise it jumps to step S8), whether it needs to perform slice analysis.
  • the criterion is that if the statement has been analyzed or belongs to a statement that is consistent in step S4), no slice analysis is required, otherwise a slice analysis is required. Since the statement 13 in the program v2 track belongs to a statement with a different value, it is necessary to perform slice analysis, and the process proceeds to step S8);
  • Step S8 adding the current analysis sentence to the regression error slice, and adding the dependency statement and the corresponding statement that need to be sliced according to the sentence classification in step S4) to the slice analysis queue. Therefore, the statement 13 in the program v2 is added to the regression error slice, and the statement 13 corresponding to the program v1 track is added to the slice analysis queue. Since the statement 13 in the program v2 belongs to a statement having a different value, it is necessary to add its data dependency statement 12 to the slice analysis queue as well. After the step ends, the process jumps to step S6);
  • step S6 jumps to step S9).
  • the loop process is schematically illustrated in Figure 10.
  • the solid line with an arrow in the figure indicates the dependency between the statements, and the slash fill indicates that the statement is added to the regression error slice.
  • Step S9 Output a regression error slice, and an example regression error slice is shown in FIG.
  • an example regression error slice is shown in FIG.
  • Statement 3 is deleted from program v2 relative to program v1, resulting in a different output, ie a regression error in the discussion. Therefore, the slice provides a context for the regression error, and we can accurately correct the regression error based on the slice.

Abstract

A method for locating a program regression fault using a slicing model, comprising: in a program pre-processing phase, comparing source codes of two versions of a program to identify parts that differ therebetween, and rearranging the source codes according to the identification result; in a trajectory association phase, on the basis of execution trajectories of the two acquired program versions, dependencies among statements thereof, and information of variables thereof, associating and classifying the statements of two execution trajectories; in a slicing analysis phase, taking an execution failure point of a new-version program as a starting point and performing slicing analysis; according to the statement entity classification and the dependencies thereof, backtracking to a statement entity causing the program execution failure, until there are no further dependency statements to be analyzed and the dependency of the current statement under analysis no longer needs to be analyzed; and using all statement entities analyzed in all phases in the slicing analysis as program behavior slicing output causing a regression error. The present invention explains the mechanism by which a regression fault is generated, and provides guidance for recovery from the regression fault.

Description

基于切片模型的程序回归错误定位方法Program regression error location method based on slice model 技术领域Technical field
本发明涉及可信软件及软件测试领域,特别涉及一种程序中回归错误的定位方法。The invention relates to the field of trusted software and software testing, in particular to a method for locating regression errors in a program.
背景技术Background technique
软件测试是用来保证软件质量的基本手段,并且也是软件开发过程中最耗费人力和物力的过程。经验表明,在软件更新的过程中经常会引入回归错误,因此进行回归测试是非常有必要的。即便现在有许多技术使得回归测试的过程变得自动化,但是回归测试仅仅只是软件测试过程中的第一步。而更加重要和富有挑战性的任务是找到导致程序执行失败的程序修改,并且提供这些修改为什么会导致程序执行失败的上下文环境。然而,该过程并不简单。首先,随着程序变得越来越复杂,回归错误总是出现在特定的环境或配置之中。第二,由于时间和人力的限制,通常只能获得一个测试案例。该测试案例在旧版本程序中能够成功执行,而在新版本程序中执行失败。第三,程序执行失败的精确上下文环境是很难获得的。只有测试人员能够读懂程序执行失败的上下文环境,他们才能够依据这些信息精确的修复错误。Software testing is the basic means to ensure the quality of software, and it is also the most labor-intensive and material-intensive process in the software development process. Experience has shown that regression errors are often introduced during software updates, so regression testing is necessary. Even though there are many technologies that automate the process of regression testing, regression testing is only the first step in the software testing process. The more important and challenging task is to find the program modifications that caused the program to fail, and provide a context for why these changes would cause the program to fail. However, the process is not simple. First, as programs become more complex, regression errors always appear in specific environments or configurations. Second, due to time and labor constraints, usually only one test case is available. This test case was successfully executed in the old version of the program, but failed in the new version of the program. Third, the precise context in which program execution fails is difficult to obtain. Only the tester can read the context in which the program failed to execute, and they can accurately fix the error based on this information.
近年来,许多关于回归错误测试的技术被提出,例如ADD(Augmented Delta Debugging)和AFTER(Automated Fault Explanation for Regression testing)。ADD通过结合覆盖分析和Delta调试来自动化的隔离导致程序执行失败的修改。然而,ADD并不分析程序的语义,因此定位的错位可能仅仅只是避免了程序执行失败而并非真正的错误。AFTER利用基于Delta调试的动态分析以及基于符号分析的语义分析来定位回归错误。AFTER的主要问题是它的可延展性。众所周知,符号分析是一个开销巨大的过程,因此它很难被应用于大规模程序。即使这些技术能够自动化的定位导致程序执行失败的程序修改,却很少被实际应用,因为他们不能提供导致程序执行失败的上下文环境。在现有的技术当中,一个普遍接受的假设是测试者能够很容易的 理解程序为什么执行失败。事实上,对程序执行失败原因的理解并不简单,因此现有技术对修复回归错误的帮助是很少的。In recent years, many techniques for regression error testing have been proposed, such as ADD (Augmented Delta Debugging) and AFTER (Automated Fault Explanation for Regression testing). The automatic isolation of ADD by combining coverage analysis and Delta debugging results in a modification of program execution failure. However, ADD does not analyze the semantics of the program, so the misplacement of the positioning may simply avoid the failure of the program execution and not the real error. AFTER uses dynamic analysis based on Delta debugging and semantic analysis based on symbol analysis to locate regression errors. The main problem with AFTER is its extensibility. As we all know, symbol analysis is a huge process, so it is difficult to apply to large-scale programs. Even though these techniques can be automated to locate program changes that cause program execution to fail, they are rarely used because they cannot provide a context that causes the program to fail. Among the existing technologies, a generally accepted assumption is that testers can easily Understand why the program failed to execute. In fact, the understanding of the reasons for program execution failure is not simple, so the prior art has little help in repairing regression errors.
因此,一个实用的回归错误定位技术不仅需要精确定位导致错误的修改,还要能提供该修改导致程序执行失败的上下文环境。Therefore, a practical regression error localization technique not only requires precise positioning to cause errors, but also provides a context in which the modification causes the program to fail.
发明内容Summary of the invention
本发明的目的在于提出一种基于切片模型的程序回归错误定位方法,通过对两个版本程序进行切片分析,输出导致程序回归错误的程序行为切片,解决程序测试中回归错误定位的问题。The object of the present invention is to propose a program regression error localization method based on a slice model. By performing slice analysis on two versions of the program, the program behavior slice causing the program regression error is output, and the problem of regression error location in the program test is solved.
为了实现上述目的,本发明采用如下技术方案:In order to achieve the above object, the present invention adopts the following technical solutions:
基于切片模型的程序回归错误定位方法,包括如下步骤:A program regression error location method based on a slice model includes the following steps:
S1)、根据输入的两个版本待测程序,计算出两个版本程序源代码的不同之处,根据源代码的不同对两个版本程序的源码重排,使得相同的代码有相同的行号,不同的代码与空行对应;S1), according to the two versions of the program to be tested, calculate the difference between the two versions of the program source code, according to the source code, the source code of the two versions of the program is rearranged, so that the same code has the same line number , different codes correspond to blank lines;
S2)、用两个经过代码重排后的程序执行会导致修改版本程序执行失败的测试案例,并提取两个版本程序的执行轨迹、语句包含的变量值以及语句的依赖关系;S2), using two code reordering program execution will lead to a test case in which the modified version program execution fails, and extract the execution trajectory of the two versions of the program, the variable values contained in the statement, and the dependency of the statement;
S3)、将执行轨迹组织成树形结构,树的每个节点是一个函数执行序列;调用轨迹函数体语句对应方法,对步骤S2)中提取到的两版本程序的执行轨迹进行对应;S3), the execution trajectory is organized into a tree structure, each node of the tree is a function execution sequence; the trajectory function body statement corresponding method is called, and the execution trajectory of the two versions of the program extracted in step S2) is corresponding;
S4)、根据源代码的不同、轨迹对应结果以及语句包含的变量值,将轨迹中的语句分为四类:修改导致不同的语句、流不同的语句、值不同的语句以及一致的语句;S4), according to the difference of the source code, the track corresponding result and the variable value contained in the statement, the statements in the track are divided into four categories: modifying different statements, different statements, different values, and consistent statements;
S5)、以新版本程序执行失败点为起点开始对回归错误的产生进行切片分析,将失败点语句加入切片分析队列;S5), starting with a new version of the program execution failure point as a starting point, performing a slice analysis on the generation of the regression error, and adding the failure point statement to the slice analysis queue;
S6)、判断切片分析队列是否为空,若为空则跳转至步骤S9),否则跳转至步骤S7);S6), determining whether the slice analysis queue is empty, if it is empty, then jumping to step S9), otherwise jumping to step S7);
S7)、取出切片分析队列首端语句,并判断首端语句是否需要进行切片分析,若不需进行 分析则跳转至步骤S6),否则跳转至步骤S8);S7), take out the first end statement of the slice analysis queue, and determine whether the first end statement needs to be sliced, if not required Analysis then jumps to step S6), otherwise jumps to step S8);
S8)、将当前分析语句加入回归错误切片,并根据步骤S4)中语句分类将其需要进行切片分析的依赖语句及对应语句加入切片分析队列;S8), adding the current analysis sentence to the regression error slice, and adding the dependency statement and the corresponding statement that need to be sliced according to the sentence classification in step S4) to the slice analysis queue;
S9)、输出回归错误切片。S9), output regression error slice.
本发明的进一步改进在于,所述步骤S1)中代码重排的过程包括以下步骤:A further improvement of the present invention is that the process of code rearrangement in the step S1) comprises the following steps:
S101)、根据两个版本程序的源代码,计算出两个版本程序源码的不同;S101), according to the source code of the two versions of the program, calculate the difference between the two versions of the program source code;
S102)、根据计算出的两个版本程序源代码的不同之处,将两个版本程序源代码中的每条语句分为两类:完全相同的语句、修改的语句;S102), according to the difference between the calculated two versions of the program source code, each of the two versions of the program source code is divided into two categories: identical statements, modified statements;
S103)、在不改变程序语句执行顺序的基础上,使完全相同的语句具有相同的行号,修改的语句与空行对应;S103), on the basis of not changing the execution order of the program statement, so that the identical statements have the same line number, and the modified statement corresponds to the blank line;
S104)、输出代码重排之后的两个版本待测程序源码作为新的待测程序。S104), the two versions of the program source code after the output code rearrangement are used as the new program to be tested.
本发明的进一步改进在于,步骤S3)中执行轨迹的树形结构定义如下:树中的每一个节点为一个函数体的执行轨迹,一个节点的子节点为该节点所表述的函数体中所调用的函数体的执行轨迹;步骤S3)中从树形结构的根节点(main函数体轨迹)开始进行轨迹函数体语句对应,具体包括以下步骤:A further improvement of the present invention is that the tree structure of the execution trajectory in step S3) is defined as follows: each node in the tree is an execution trajectory of a function body, and a child node of one node is called in a function body represented by the node The execution trajectory of the function body; in step S3), the trajectory function body statement is correspondingly started from the root node of the tree structure (main function body trajectory), and specifically includes the following steps:
S301)、判断当前对应的函数体中需要进行对应的语句是否为空,若为空则函数体语句对应方法执行结束返回,否则跳转至步骤S302);S301), determining whether the corresponding statement in the currently corresponding function body needs to be empty, if it is empty, the function body statement corresponding method execution end returns, otherwise, the process proceeds to step S302);
S302)、迭代取出函数体中的语句作为当前进行对应的语句;S302), iteratively extracting the statement in the function body as the current corresponding statement;
S303)、判断当前对应语句是否为函数调用语句,若为函数调用语句则跳转至步骤S304),否则跳转至步骤S306);S303), determining whether the current corresponding statement is a function call statement, if it is a function call statement, then jumping to step S304), otherwise jumping to step S306);
S304)、判断该函数调用在对应轨迹中是否有对应的函数调用,若有对应函数调用则跳转至步骤S305),否则跳转至步骤S301); S304), determining whether the function call has a corresponding function call in the corresponding track, if there is a corresponding function call, then jump to step S305), otherwise jump to step S301);
S305)、调用函数体语句对应方法对该函数体轨迹中的语句进行对应,执行结束后跳转至步骤S301);S305), calling the function body statement corresponding method corresponding to the statement in the function body track, after the execution ends, the process proceeds to step S301);
S306)、判断当前语句在对应轨迹中是否有对应的语句,若有对应语句则跳转至步骤S307),否则跳转至步骤S301);S306), determining whether the current statement has a corresponding statement in the corresponding track, if there is a corresponding statement, then jump to step S307), otherwise jump to step S301);
S307)、将当前语句与对应轨迹中的对应语句进行对应,结束后跳转至步骤S301)。S307), the current statement is associated with the corresponding statement in the corresponding track, and after the process ends, the process proceeds to step S301).
本发明的进一步改进在于:步骤S4)中语句分类的策略是,根据步骤S102)中源码语句分类、轨迹对应结果以及语句包含的变量值信息,将轨迹中的所有语句分为以下四类:A further improvement of the present invention is that the strategy for classifying the sentences in step S4) is to classify all the statements in the track into the following four categories according to the source code sentence classification, the track correspondence result, and the variable value information contained in the statement in step S102):
(1)修改导致不同的语句:修改的语句。(1) Modification results in different statements: modified statements.
(2)流不同的语句:非修改的语句,且在对应轨迹中没有对应语句;(2) Flow different statements: non-modified statements, and there is no corresponding statement in the corresponding track;
(3)值不同的语句:两条轨迹中有对应的语句,且语句包含的变量值至少有一个不同;(3) Statements with different values: there are corresponding statements in the two tracks, and the statement contains at least one variable value;
(4)一致的语句:两条轨迹中有对应的语句,且语句包含的变量值均相同;(4) Consistent statement: There are corresponding statements in the two tracks, and the values of the variables contained in the statement are the same;
其分类流程包括以下步骤:The classification process includes the following steps:
S401)、判断轨迹中的语句是否已全部分类,若已全部分类则跳转至步骤S407),否则跳转至步骤S402);S401), determining whether the statements in the trajectory have all been classified, if all the classifications have been performed, then the process proceeds to step S407), otherwise, the process proceeds to step S402);
S402)、迭代取出轨迹中未分类的语句,对其进行分类;S402), iteratively extracting unclassified sentences in the trajectory and classifying them;
S403)、根据源代码的分类,判断该语句是否为修改的语句,若为修改的语句则标记为修改导致不同的语句并跳转至步骤S401),否则跳转至步骤S404);S403), according to the classification of the source code, determine whether the statement is a modified statement, if the modified statement is marked as modified resulting in a different statement and jump to step S401), otherwise jump to step S404);
S404)、根据轨迹对应结果,判断该语句是否有对应语句,若没有对应语句则将该语句标记为流不同的语句并跳转至步骤S401),否则跳转至步骤S405);S404), according to the trajectory corresponding result, determine whether the statement has a corresponding statement, if there is no corresponding statement, the statement is marked as a different flow statement and jump to step S401), otherwise jump to step S405);
S405)、根据语句包含的变量值信息,判断该语句与对应语句中包含的变量值是否相同,如果至少包含一个变量值不相同则将该语句标记为值不同的语句并跳转至步骤S401),否则跳转至步骤S406); S405), according to the variable value information included in the statement, determining whether the statement and the variable value included in the corresponding statement are the same, and if at least one variable value is not the same, marking the statement as a statement having a different value and jumping to step S401) Otherwise, go to step S406);
S406)、将该语句标记为一致的语句并跳转至步骤S401);S406), marking the statement as a consistent statement and jumping to step S401);
S407)、轨迹中的语句分类结束,返回。S407), the sentence classification in the track ends and returns.
本发明的而进一步改进在于:步骤S7)中语句是否需要进行切片分析的判断标准是:如果该语句已经被分析过或属于步骤S4)中一致的语句则不需要进行切片分析,否则需要进行切片分析。A further improvement of the present invention is that the criterion for determining whether the statement needs to be sliced in step S7) is that if the statement has been analyzed or belongs to the statement consistent in step S4), no slice analysis is required, otherwise the slice needs to be sliced. analysis.
本发明的进一步改进在于:步骤S8)中需要进行切片分析的语句的分析策略是,对于步骤S4)中值不同的语句,仅将其数据依赖语句及对应轨迹中的对应语句加入切片分析队列;对于流不同的语句,仅将其控制依赖语句加入切片分析队列;对于分类为修改导致不同的语句,则将其控制依赖和数据依赖语句均加入切片分析队列。同时步骤S8)中分析的当前语句需要加入回归错误切片中。A further improvement of the present invention is that the analysis strategy of the statement that needs to be sliced in step S8) is that, for the statement with different median value in step S4), only the data dependency statement and the corresponding statement in the corresponding track are added to the slice analysis queue; For statements with different flows, only the control dependency statement is added to the slice analysis queue; for the classification to modify to cause different statements, the control dependency and data dependency statements are added to the slice analysis queue. At the same time, the current statement analyzed in step S8) needs to be added to the regression error slice.
相对于现有技术,本发明的具有以下有益效果:本发明提出了一种基于切片模型的程序回归错误定位方法,通过对两个版本程序进行切片分析,输出导致程序回归错误的程序行为切片,解决程序测试中回归错误定位的问题。在程序预处理阶段,该方法通过对比两个版本程序源码,识别其不同的部分,根据识别结果对两个版本程序的源码进行重排,在不影响程序代码执行顺序的前提下,使得两个版本程序中原来相对应的代码具有相同的行号;在轨迹对应阶段,根据获取到的两个版本程序的执行轨迹、语句间的依赖关系和变量值信息,对两条执行轨迹上的语句进行对应,并根据轨迹对应结果对语句进行分类;在切片分析阶段,以程序的控制依赖、数据依赖以及语句的分类为基础,从新版本程序执行失败点为起点开始进行切片分析;根据语句实体分类及其依赖关系,回溯导致程序执行失败的语句实体,直至待分析的依赖语句为空,且被分析的当前语句不需要继续分析其依赖关系;最后,将切片分析的阶段所有被分析的语句实体作为导致回归错误的程序行为切片输出。相比现有的回归错误定位方法,本方法阐明了回归错误的产生机理,对回归错误的修复具有指导作用。 Compared with the prior art, the present invention has the following beneficial effects: the present invention proposes a program regression error localization method based on a slice model, and performs slice analysis on two versions of the program to output a program behavior slice that causes a program regression error. Solve the problem of regression error location in program testing. In the pre-processing stage of the program, the method compares the two versions of the program source code, identifies different parts thereof, and rearranges the source code of the two versions of the program according to the recognition result, so that the two sequences are executed without affecting the execution order of the program code. The original corresponding code in the version program has the same line number; in the corresponding stage of the track, the statements on the two execution tracks are performed according to the execution trajectory of the obtained two versions of the program, the dependency relationship between the statements, and the variable value information. Corresponding, and classifying the sentences according to the corresponding results of the trajectory; in the slice analysis stage, based on the control dependence of the program, the data dependency, and the classification of the statements, the slice analysis is started from the new program execution failure point as the starting point; Its dependency, backtracking the statement entity that caused the program to fail, until the dependency statement to be analyzed is empty, and the analyzed current statement does not need to continue to analyze its dependencies; finally, all the parsed statement entities in the stage of the slice analysis are Program behavior slice output that causes regression errors. Compared with the existing regression error localization method, this method clarifies the mechanism of regression error and has a guiding role in the repair of regression errors.
附图说明DRAWINGS
图1为本发明方法整体流程图;Figure 1 is a general flow chart of the method of the present invention;
图2为代码重排方法流程图;2 is a flow chart of a code rearrangement method;
图3为函数体语句对应方法流程图;3 is a flow chart of a method corresponding to a function body statement;
图4为语句分类过程的流程图;Figure 4 is a flow chart of the sentence classification process;
图5为说明具体实施方式中示例程序示意图;Figure 5 is a schematic diagram showing an exemplary procedure in a specific embodiment;
图6为源码比较结果图;Figure 6 is a comparison of the results of the source code;
图7为代码重排结果图;Figure 7 is a diagram of code rearrangement results;
图8为轨迹对应结果图;Figure 8 is a diagram corresponding to the trajectory;
图9为回归错误切片图;Figure 9 is a regression error slice diagram;
图10为切片分析过程图。Figure 10 is a diagram of a slice analysis process.
具体实施方式detailed description
以下结合实例详细说明本发明的实施方式。Embodiments of the present invention will be described in detail below with reference to examples.
请参阅图5所示,待测程序v1为原版本,待测程序v2为修改后的新版本。Referring to FIG. 5, the program to be tested v1 is the original version, and the program to be tested v2 is the modified new version.
步骤S1:根据输入的两个版本待测程序,计算出两个版本程序源代码的不同之处,根据源代码的不同对两个版本程序的源码重排,使得相同的代码有相同的行号,不同的代码与空行对应,流程图如图2所示,具体包括以下步骤:Step S1: Calculate the difference between the source code of the two versions of the program according to the two versions of the program to be tested, and rearrange the source code of the two versions according to the source code, so that the same code has the same line number. The different codes correspond to the blank lines. The flow chart is shown in Figure 2. Specifically, the following steps are included:
步骤S101:根据两个版本程序的源代码,计算两个版本程序源码的不同;Step S101: Calculate the difference between the source codes of the two versions according to the source code of the two versions of the program;
步骤S102:根据计算出的两个版本程序源代码的不同之处,对源码中的语句分为两类,相同的语句和修改的语句,修改的语句进行标记(c1-c4),如图6所示;Step S102: According to the calculated difference between the source code of the two versions of the program, the statements in the source code are divided into two categories, the same statement and the modified statement, and the modified statement is marked (c1-c4), as shown in FIG. 6. Shown
步骤S103:在不改变程序语句执行顺序的基础上,使完全相同的语句具有相同的行号,修改的语句与空行对应,代码重排结果如图7所示; Step S103: On the basis of not changing the execution order of the program statement, the identical statements have the same line number, the modified statement corresponds to the blank line, and the code rearrangement result is as shown in FIG. 7;
步骤S104:输出代码重排之后的两个版本待测程序源码作为新的待测程序。Step S104: The two versions of the program source code to be tested after the code rearrangement are output as a new program to be tested.
步骤S2:用两个经过代码重排后的程序执行会导致修改版本程序执行失败的测试案例<x=1,y=1,z=2>,提取两个版本程序的执行轨迹、语句包含的变量值以及语句的依赖关系;Step S2: Execute the test case <x=1, y=1, z=2> which causes the modified version program to fail to execute, and extract the execution track of the two versions of the program, and the statement contains The value of the variable and the dependencies of the statement;
表1程序执行轨迹Table 1 program execution track
程序v1轨迹Program v1 track main#c 1 2 3 5 6 7 11 12 13 mian#r Main#c 1 2 3 5 6 7 11 12 13 mian#r
程序v2轨迹Program v2 track mian#c 1 2 4 8 9 11 12 13 main#r Mian#c 1 2 4 8 9 11 12 13 main#r
步骤S3:调用轨迹函数体语句对应方法,对步骤S2)中提取到的两版本程序的执行轨迹进行对应,流程图如图3所示,函数体语句对应方法:Step S3: Calling the trajectory function body sentence corresponding method, corresponding to the execution trajectory of the two versions of the program extracted in step S2), the flowchart is as shown in FIG. 3, and the function body statement corresponding method:
S301)判断当前对应的函数体中需要进行对应的语句是否为空,若为空则函数体语句对应方法执行结束返回,否则跳转至步骤S302);S301) determining whether the corresponding statement in the currently corresponding function body needs to be empty, if it is empty, the function body statement corresponding method execution end returns, otherwise, the process proceeds to step S302);
S302)迭代取出函数体中的语句作为当前进行对应的语句;S302) iteratively extracting the statement in the function body as the current corresponding statement;
S303)判断当前对应语句是否为函数调用语句,若为函数调用语句则跳转至步骤S304),否则跳转至步骤S306);S303) determining whether the current corresponding statement is a function call statement, if it is a function call statement, then jumping to step S304), otherwise jumping to step S306);
S304)判断该函数调用在对应轨迹中是否有对应的函数调用,若有对应函数调用则跳转至步骤S305),否则跳转至步骤S301);S304) determining whether the function call has a corresponding function call in the corresponding track, if there is a corresponding function call, then jump to step S305), otherwise jump to step S301);
S305)调用函数体语句对应方法对该函数体轨迹中的语句进行对应,执行结束后跳转至步骤S301);S305) calling the function body statement corresponding method to correspond to the statement in the function body track, after the execution ends, the process proceeds to step S301);
S306)判断当前语句在对应轨迹中是否有对应的语句,若有对应语句则跳转至步骤S307),否则跳转至步骤S301);S306) determining whether the current statement has a corresponding statement in the corresponding track, if there is a corresponding statement, then jump to step S307), otherwise jump to step S301);
S307)将当前语句与对应轨迹中的对应语句进行对应,结束后跳转至步骤S301)。S307) Corresponding to the corresponding statement in the corresponding track, and then jumping to step S301).
以两条轨迹中的main函数体轨迹为例,其具体流程包括:Take the main function body trajectory in two tracks as an example. The specific process includes:
步骤S301:main函数体中需要对应的语句不为空,所以转S302; Step S301: the main function body needs to be corresponding to the statement is not empty, so go to S302;
步骤S302:取出程序v1中main未应的语句1,转步骤S303;Step S302: taking out the statement 1 in the program v1 that the main does not respond, go to step S303;
步骤S303:语句1非函数调用语句,转步骤S306;Step S303: statement 1 is not a function call statement, proceeds to step S306;
步骤S306:程v1轨迹中main函数语句1在程序v2轨迹中有main函数语句1对应,转步骤S307;Step S306: The main function statement 1 in the path v1 track corresponds to the main function statement 1 in the program v2 track, and the process proceeds to step S307;
步骤S307:将两个版本程序轨迹中main函数语句1对应,且标记为已对应语句。Step S307: Corresponding to the main function statement 1 in the two version program tracks, and marking the corresponding statement.
重复上述步骤,直至两条轨迹中未对应的语句为空,得到轨迹对应结果如图8所示。Repeat the above steps until the uncorrelated statement in the two tracks is empty, and the corresponding result of the trace is as shown in Fig. 8.
步骤S4:根据源代码的不同、轨迹对应结果以及语句包含的变量值,将轨迹中的语句分为四类:修改导致不同的语句、流不同的语句、值不同的语句以及一致的语句,其分类策略如下:Step S4: According to the difference of the source code, the track corresponding result, and the variable value included in the statement, the statements in the track are divided into four categories: modifying different statements, different statements, different values, and consistent statements. The classification strategy is as follows:
(1)修改导致不同的语句:修改的语句。(1) Modification results in different statements: modified statements.
(2)流不同的语句:非修改的语句,且在对应轨迹中没有对应语句;(2) Flow different statements: non-modified statements, and there is no corresponding statement in the corresponding track;
(3)值不同的语句:两条轨迹中有对应的语句,且语句包含的变量值至少有一个不同;(3) Statements with different values: there are corresponding statements in the two tracks, and the statement contains at least one variable value;
(4)一致的语句:两条轨迹中有对应的语句,且语句包含的变量值均相同;(4) Consistent statement: There are corresponding statements in the two tracks, and the values of the variables contained in the statement are the same;
其分类流程如图4所示,具体包括以下步骤:The classification process is shown in Figure 4, which specifically includes the following steps:
S401)判断轨迹中的语句是否已全部分类,若已全部分类则跳转至步骤S407),否则跳转至步骤S402);S401) determining whether the statements in the track have been all classified, if all the categories have been classified, then the process proceeds to step S407), otherwise, the process proceeds to step S402);
S402)迭代取出轨迹中未分类的语句,对其进行分类;S402) Iteratively extracts unclassified sentences in the trajectory and classifies them;
S403)根据源代码的分类,判断该语句是否为修改的语句,若为修改的语句则标记为修改导致不同的语句并跳转至步骤S401),否则跳转至步骤S404);S403) according to the classification of the source code, determine whether the statement is a modified statement, if the modified statement is marked as modified resulting in a different statement and jump to step S401), otherwise jump to step S404);
S404)根据轨迹对应结果,判断该语句是否有对应语句,若没有对应语句则将该语句标记为流不同的语句并跳转至步骤S401),否则跳转至步骤S405);S404) determining whether the statement has a corresponding statement according to the result of the track correspondence, if there is no corresponding statement, marking the statement as a statement with a different flow and jumping to step S401), otherwise jumping to step S405);
S405)根据语句包含的变量值信息,判断该语句与对应语句中包含的变量值是否相同,如 果至少包含一个变量值不相同则将该语句标记为值不同的语句并跳转至步骤S401),否则跳转至步骤S406);S405) determining, according to the variable value information included in the statement, whether the value of the variable included in the statement and the corresponding statement is the same, such as If at least one variable value is not the same, the statement is marked as a statement with a different value and jumps to step S401), otherwise jumps to step S406);
S406)将该语句标记为一致的语句并跳转至步骤S401);S406) marking the statement as a consistent statement and jumping to step S401);
S407)轨迹中的语句分类结束,返回。S407) The sentence classification in the trajectory ends and returns.
以语句2为例,其具体分类流程包括:Taking the statement 2 as an example, the specific classification process includes:
步骤S401:轨迹中的语句未全部分类,转S402;Step S401: the statements in the trajectory are not all classified, and the process proceeds to S402;
步骤S402:取出轨迹中未分类的语句2;Step S402: Extract the unclassified statement 2 in the track;
步骤S403:语句2非修改的语句,转S403;Step S403: statement 2 non-modified statement, go to S403;
步骤S403:语句2有对应的语句,转S404;Step S403: statement 2 has a corresponding statement, and proceeds to S404;
步骤S404:两条轨迹中语句2包含的变量值相同,转步骤S405;Step S404: the two variables in the two sentences contain the same variable value, go to step S405;
步骤S405:将两条轨迹中的语句2标记为一致的语句。Step S405: Mark the statement 2 in the two tracks as a consistent statement.
重复上述步骤,直至轨迹中所有的语句已分类,得到语句分类结果如表2所示。Repeat the above steps until all the statements in the track have been classified, and the result of the sentence classification is shown in Table 2.
表2语句分类结果Table 2 statement classification results
程序v1轨迹Program v1 track 程序v2轨迹Program v2 track 语句分类Statement classification
1:void main(int x,int y,int z)1:void main(int x,int y,int z) 1:void main(int x,int y,int z)1:void main(int x,int y,int z) 一致的Consistent
2:int abs=x;2:int abs=x; 2:int abs=x;2:int abs=x; 一致的Consistent
3:if(x<0)3: if (x < 0)   修改导致不同Modifications lead to different
  4:abs=-x;4: abs=-x; 流不同Different flow
5:int max=y;5: int max=y;   修改导致不同Modifications lead to different
6:if(y<z)6: if(y<z)   修改导致不同Modifications lead to different
7:max=z;7:max=z;   修改导致不同Modifications lead to different
  8:int max=z;8: int max=z; 修改导致不同Modifications lead to different
  9:if(y>z)9: if (y>z) 修改导致不同Modifications lead to different
11:int out=max;11:int out=max; 11:int out=max;11:int out=max; 一致的Consistent
12:out=abs+out;12: out=abs+out; 12:out=abs+out;12: out=abs+out; 值不同Different value
13:printf(“%d”,out);13: printf ("%d", out); 13:printf(“%d”,out);13: printf ("%d", out); 值不同Different value
步骤S5:以新版本程序执行失败点为起点开始对回归错误的产生进行切片分析,将失败点语句加入切片分析队列,在该示例中新版本程序即程序v2,其执行失败点语句即输出点语句13,所以将程序v2轨迹中的语句13加入切片分析队列;Step S5: Begin the slice analysis by generating the failure point of the new version program as a starting point, and add the failure point statement to the slice analysis queue. In this example, the new version program is program v2, and the execution failure point statement is the output point. Statement 13, so the statement 13 in the program v2 track is added to the slice analysis queue;
步骤S6:判断切片分析队列是否为空,若为空则跳转至步骤S9),否则跳转至步骤S7),当前队列不为空,所以跳转至步骤S7);Step S6: determining whether the slice analysis queue is empty, if it is empty, then jumping to step S9), otherwise jumping to step S7), the current queue is not empty, so the process goes to step S7);
步骤S7:取出切片分析队列首端语句,并判断首端语句是否需要进行切片分析,若不需进行分析则跳转至步骤S6),否则跳转至步骤S8),是否需要进行切片分析的判断标准是:如果该语句已经被分析过或属于步骤S4)中一致的语句则不需要进行切片分析,否则需要进行切片分析。由于程序v2轨迹中的语句13属于值不同的语句,所以需要进行切片分析,跳转至步骤S8);Step S7: taking out the first end statement of the slice analysis queue, and determining whether the first end statement needs to perform slice analysis. If no analysis is needed, the process jumps to step S6), otherwise it jumps to step S8), whether it needs to perform slice analysis. The criterion is that if the statement has been analyzed or belongs to a statement that is consistent in step S4), no slice analysis is required, otherwise a slice analysis is required. Since the statement 13 in the program v2 track belongs to a statement with a different value, it is necessary to perform slice analysis, and the process proceeds to step S8);
步骤S8:将当前分析语句加入回归错误切片,并根据步骤S4)中语句分类将其需要进行切片分析的依赖语句及对应语句加入切片分析队列。所以将程序v2中的语句13加入回归错误切片,并将程序v1轨迹中与之对应的语句13加入切片分析队列。因为程序v2中的语句13属于值不同的语句,所以需要将其数据依赖语句12也加入切片分析队列。该步骤结束后跳转至步骤S6);Step S8: adding the current analysis sentence to the regression error slice, and adding the dependency statement and the corresponding statement that need to be sliced according to the sentence classification in step S4) to the slice analysis queue. Therefore, the statement 13 in the program v2 is added to the regression error slice, and the statement 13 corresponding to the program v1 track is added to the slice analysis queue. Since the statement 13 in the program v2 belongs to a statement having a different value, it is necessary to add its data dependency statement 12 to the slice analysis queue as well. After the step ends, the process jumps to step S6);
重复上述步骤,直至步骤S6)跳转至步骤S9)。该循环过程示意如图10所示,图中带箭头的实线表示语句间的依赖关系,斜杠填充表示该语句被加入到回归错误切片中。The above steps are repeated until step S6) jumps to step S9). The loop process is schematically illustrated in Figure 10. The solid line with an arrow in the figure indicates the dependency between the statements, and the slash fill indicates that the statement is added to the regression error slice.
步骤S9:输出回归错误切片,示例的回归错误切片如图9所示。从该切片可以看出,由 于程序v2相对程序v1删除了语句3,从而导致了输出的不同,即讨论的回归错误。因此,该切片提供了回归错误产生的上下文环境,同时我们可以根据该切片精确的修复回归错误。 Step S9: Output a regression error slice, and an example regression error slice is shown in FIG. As can be seen from the slice, by Statement 3 is deleted from program v2 relative to program v1, resulting in a different output, ie a regression error in the discussion. Therefore, the slice provides a context for the regression error, and we can accurately correct the regression error based on the slice.

Claims (7)

  1. 基于切片模型的程序回归错误定位方法,其特征在于,包括以下步骤:A program regression error location method based on a slice model, comprising the following steps:
    S1)、根据输入的两个版本待测程序,计算出两个版本程序源代码的不同之处,根据源代码的不同对两个版本程序的源码重排,使得相同的代码有相同的行号,不同的代码与空行对应;S1), according to the two versions of the program to be tested, calculate the difference between the two versions of the program source code, according to the source code, the source code of the two versions of the program is rearranged, so that the same code has the same line number , different codes correspond to blank lines;
    S2)、用两个经过代码重排后的程序执行会导致修改版本程序执行失败的测试案例,并提取两个版本程序的执行轨迹、语句包含的变量值以及语句的依赖关系;S2), using two code reordering program execution will lead to a test case in which the modified version program execution fails, and extract the execution trajectory of the two versions of the program, the variable values contained in the statement, and the dependency of the statement;
    S3)、将执行轨迹组织成树形结构,树的每个节点是一个函数执行序列;调用轨迹函数体语句对应方法,对步骤S2)中提取到的两版本程序的执行轨迹进行对应;S3), the execution trajectory is organized into a tree structure, each node of the tree is a function execution sequence; the trajectory function body statement corresponding method is called, and the execution trajectory of the two versions of the program extracted in step S2) is corresponding;
    S4)、根据源代码的不同、轨迹对应结果以及语句包含的变量值,将轨迹中的语句分为四类:修改导致不同的语句、流不同的语句、值不同的语句以及一致的语句;S4), according to the difference of the source code, the track corresponding result and the variable value contained in the statement, the statements in the track are divided into four categories: modifying different statements, different statements, different values, and consistent statements;
    S5)、以新版本程序执行失败点为起点开始对回归错误的产生进行切片分析,将失败点语句加入切片分析队列;S5), starting with a new version of the program execution failure point as a starting point, performing a slice analysis on the generation of the regression error, and adding the failure point statement to the slice analysis queue;
    S6)、判断切片分析队列是否为空,若为空则跳转至步骤S9),否则跳转至步骤S7);S6), determining whether the slice analysis queue is empty, if it is empty, then jumping to step S9), otherwise jumping to step S7);
    S7)、取出切片分析队列首端语句,并判断首端语句是否需要进行切片分析,若不需进行分析则跳转至步骤S6),否则跳转至步骤S8);S7), take out the slice analysis queue head end statement, and determine whether the first end statement needs to perform slice analysis, if not need to analyze, then jump to step S6), otherwise jump to step S8);
    S8)、将当前分析语句加入回归错误切片,并根据步骤S4)中语句分类将其需要进行切片分析的依赖语句及对应语句加入切片分析队列,结束后跳转至步骤S6);S8), adding the current analysis statement to the regression error slice, and adding the dependency statement and the corresponding statement that need to be sliced according to the sentence classification in step S4) to the slice analysis queue, and then jumping to step S6);
    S9)、输出回归错误切片。S9), output regression error slice.
  2. 根据权利要求1所述的基于切片模型的程序回归错误定位方法,其特征在于,步骤S1)中代码重排的过程包括以下步骤:The slice model based program regression error localization method according to claim 1, wherein the process of code rearrangement in step S1) comprises the following steps:
    S101)、根据两个版本程序的源代码,计算出两个版本程序源码的不同;S101), according to the source code of the two versions of the program, calculate the difference between the two versions of the program source code;
    S102)、根据计算出的两个版本程序源代码的不同之处,将两个版本程序源代码中的每条语句分为两类:完全相同的语句、修改的语句; S102), according to the difference between the calculated two versions of the program source code, each of the two versions of the program source code is divided into two categories: identical statements, modified statements;
    S103)、在不改变程序语句执行顺序的基础上,对两个版本程序的源码进行重排,使完全相同的语句具有相同的行号,修改的语句与空行对应;S103), on the basis of not changing the execution order of the program statement, rearranging the source codes of the two versions of the program, so that the identical statements have the same line number, and the modified statement corresponds to the blank line;
    S104)、输出代码重排之后的两个版本待测程序源码作为新的待测程序。S104), the two versions of the program source code after the output code rearrangement are used as the new program to be tested.
  3. 根据权利要求1所述的基于切片模型的程序回归错误定位方法,其特征在于,步骤S3)中执行轨迹的树形结构定义如下:树中的每一个节点为一个函数体的执行轨迹,一个节点的子节点为该节点所表述的函数体中所调用的函数体的执行轨迹;步骤S3)中从树形结构的根节点开始进行轨迹函数体语句对应,具体包括以下步骤:The slice model based program regression error localization method according to claim 1, wherein the tree structure of the execution track in step S3) is defined as follows: each node in the tree is an execution track of a function body, and one node The child node is the execution trajectory of the function body called in the function body represented by the node; in step S3), the trajectory function body statement is correspondingly started from the root node of the tree structure, and specifically includes the following steps:
    S301)、判断当前对应的函数体中需要进行对应的语句是否为空,若为空则函数体语句对应方法执行结束返回,否则跳转至步骤S302);S301), determining whether the corresponding statement in the currently corresponding function body needs to be empty, if it is empty, the function body statement corresponding method execution end returns, otherwise, the process proceeds to step S302);
    S302)、迭代取出函数体中的语句作为当前进行对应的语句;S302), iteratively extracting the statement in the function body as the current corresponding statement;
    S303)、判断当前对应语句是否为函数调用语句,若为函数调用语句则跳转至步骤S304),否则跳转至步骤S306);S303), determining whether the current corresponding statement is a function call statement, if it is a function call statement, then jumping to step S304), otherwise jumping to step S306);
    S304)、判断该函数调用在对应轨迹中是否有对应的函数调用,若有对应函数调用则跳转至步骤S305),否则跳转至步骤S301);S304), determining whether the function call has a corresponding function call in the corresponding track, if there is a corresponding function call, then jump to step S305), otherwise jump to step S301);
    S305)、调用函数体语句对应方法对该函数体轨迹中的语句进行对应,执行结束后跳转至步骤S301);S305), calling the function body statement corresponding method corresponding to the statement in the function body track, after the execution ends, the process proceeds to step S301);
    S306)、判断当前语句在对应轨迹中是否有对应的语句,若有对应语句则跳转至步骤S307),否则跳转至步骤S301);S306), determining whether the current statement has a corresponding statement in the corresponding track, if there is a corresponding statement, then jump to step S307), otherwise jump to step S301);
    S307)、将当前语句与对应轨迹中的对应语句进行对应,结束后跳转至步骤S301)。S307), the current statement is associated with the corresponding statement in the corresponding track, and after the process ends, the process proceeds to step S301).
  4. 根据权利要求1所述的基于切片模型的程序回归错误定位方法,其特征在于,步骤S4)中语句分类的方法为:根据步骤S102)中源码语句分类、轨迹对应结果以及语句包含的变量值信息,将轨迹中的所有语句分为以下四类: The slice model-based program regression error locating method according to claim 1, wherein the method for classifying the sentences in step S4) is: according to the step S102), the source code sentence classification, the track correspondence result, and the variable value information included in the statement. , divide all the statements in the track into the following four categories:
    (1)修改导致不同的语句:修改的语句;(1) The modification results in a different statement: the modified statement;
    (2)流不同的语句:非修改的语句,且在对应轨迹中没有对应语句;(2) Flow different statements: non-modified statements, and there is no corresponding statement in the corresponding track;
    (3)值不同的语句:两条轨迹中有对应的语句,且语句包含的变量值至少有一个不同;(3) Statements with different values: there are corresponding statements in the two tracks, and the statement contains at least one variable value;
    (4)一致的语句:两条轨迹中有对应的语句,且语句包含的变量值均相同。(4) Consistent statement: There are corresponding statements in the two tracks, and the values of the variables contained in the statement are the same.
  5. 根据权利要求1或4所述的基于切片模型的程序回归错误定位方法,其特征在于,步骤S4)中分类流程包括以下步骤:The slice model based program regression error localization method according to claim 1 or 4, wherein the classification process in step S4) comprises the following steps:
    S401)、判断轨迹中的语句是否已全部分类,若已全部分类则跳转至步骤S407),否则跳转至步骤S402);S401), determining whether the statements in the trajectory have all been classified, if all the classifications have been performed, then the process proceeds to step S407), otherwise, the process proceeds to step S402);
    S402)、迭代取出轨迹中未分类的语句,对其进行分类;S402), iteratively extracting unclassified sentences in the trajectory and classifying them;
    S403)、根据源代码的分类,判断该语句是否为修改的语句,若为修改的语句则标记为修改导致不同的语句并跳转至步骤S401),否则跳转至步骤S404);S403), according to the classification of the source code, determine whether the statement is a modified statement, if the modified statement is marked as modified resulting in a different statement and jump to step S401), otherwise jump to step S404);
    S404)、根据轨迹对应结果,判断该语句是否有对应语句,若没有对应语句则将该语句标记为流不同的语句并跳转至步骤S401),否则跳转至步骤S405);S404), according to the trajectory corresponding result, determine whether the statement has a corresponding statement, if there is no corresponding statement, the statement is marked as a different flow statement and jump to step S401), otherwise jump to step S405);
    S405)、根据语句包含的变量值信息,判断该语句与对应语句中包含的变量值是否相同,如果至少包含一个变量值不相同则将该语句标记为值不同的语句并跳转至步骤S401),否则跳转至步骤S406);S405), according to the variable value information included in the statement, determining whether the statement and the variable value included in the corresponding statement are the same, and if at least one variable value is not the same, marking the statement as a statement having a different value and jumping to step S401) Otherwise, go to step S406);
    S406)、将该语句标记为一致的语句并跳转至步骤S401);S406), marking the statement as a consistent statement and jumping to step S401);
    S407)、轨迹中的语句分类结束,返回。S407), the sentence classification in the track ends and returns.
  6. 根据权利要求1所述的基于切片模型的程序回归错误定位方法,其特征在于,步骤S7)中语句是否需要进行切片分析的判断标准是:如果该语句已经被分析过或属于步骤S4)中一致的语句则不需要进行切片分析,否则需要进行切片分析。The slice model-based program regression error locating method according to claim 1, wherein the criterion for determining whether the statement needs to be sliced in step S7) is: if the statement has been analyzed or belongs to the step S4) The statement does not need to be sliced, otherwise it needs to be sliced.
  7. 根据权利要求1所述的基于切片模型的程序回归错误定位方法,其特征在于,步骤S8) 中需要进行切片分析的语句的分析策略是:对于步骤S4)中值不同的语句,仅将其数据依赖语句及对应轨迹中的对应语句加入切片分析队列;对于流不同的语句,仅将其控制依赖语句加入切片分析队列;对于分类为修改导致不同的语句,则将其控制依赖和数据依赖语句均加入切片分析队列。 The slice model based program regression error localization method according to claim 1, wherein step S8) The analysis strategy of the statement that needs to be sliced and analyzed is: for the statement with different median value in step S4), only the data dependency statement and the corresponding statement in the corresponding track are added to the slice analysis queue; for the different sentences, only the control is controlled. The dependency statement is added to the slice analysis queue; for the classification to modify to cause different statements, its control dependencies and data dependency statements are added to the slice analysis queue.
PCT/CN2016/090956 2016-05-26 2016-07-22 Method for locating program regression fault using slicing model WO2017201853A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610368555.0 2016-05-26
CN201610368555.0A CN106095663B (en) 2016-05-26 2016-05-26 Program based on hierarchical model returns location of mistake method

Publications (1)

Publication Number Publication Date
WO2017201853A1 true WO2017201853A1 (en) 2017-11-30

Family

ID=57230282

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/090956 WO2017201853A1 (en) 2016-05-26 2016-07-22 Method for locating program regression fault using slicing model

Country Status (2)

Country Link
CN (1) CN106095663B (en)
WO (1) WO2017201853A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107643905B (en) * 2017-09-13 2021-01-12 扬州大学 Automatic repair method for software version consistency defects
CN110851353B (en) * 2019-10-22 2023-03-31 天津大学 Concurrent program defect positioning method based on Delta debug and constraint solution

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101859276A (en) * 2010-05-14 2010-10-13 东南大学 Regression testing case selection method based on hierarchical slicing
CN101916222A (en) * 2010-08-09 2010-12-15 哈尔滨工程大学 Software testing method based on combination of control flow graph traversal and slice forward traversal
US20110239204A1 (en) * 2010-03-29 2011-09-29 Gm Global Technology Operations, Inc. Method and apparatus for analyzing software
CN103970845A (en) * 2014-04-28 2014-08-06 南京邮电大学 Webpage filtering method based on program slicing technology

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7926036B2 (en) * 2007-04-26 2011-04-12 Microsoft Corporation Technologies for code failure proneness estimation
CN102902619B (en) * 2011-07-29 2015-09-09 阿里巴巴集团控股有限公司 The regression testing method of web application and device
CN103678097A (en) * 2012-09-05 2014-03-26 百度在线网络技术(北京)有限公司 Method and device for selecting regression test case
CN105446723B (en) * 2014-09-02 2018-11-23 国际商业机器公司 Method and apparatus for identifying the semantic differential between source code version

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110239204A1 (en) * 2010-03-29 2011-09-29 Gm Global Technology Operations, Inc. Method and apparatus for analyzing software
CN101859276A (en) * 2010-05-14 2010-10-13 东南大学 Regression testing case selection method based on hierarchical slicing
CN101916222A (en) * 2010-08-09 2010-12-15 哈尔滨工程大学 Software testing method based on combination of control flow graph traversal and slice forward traversal
CN103970845A (en) * 2014-04-28 2014-08-06 南京邮电大学 Webpage filtering method based on program slicing technology

Also Published As

Publication number Publication date
CN106095663B (en) 2017-06-27
CN106095663A (en) 2016-11-09

Similar Documents

Publication Publication Date Title
CN108509336B (en) Operating system standard formalization verification and test method
US9032371B2 (en) Method and apparatus for automatic diagnosis of software failures
CN105701008B (en) System and method for test case generation
EP2960799A1 (en) Defect localization in software integration tests
US9384117B2 (en) Machine and methods for evaluating failing software programs
US20060107121A1 (en) Method of speeding up regression testing using prior known failures to filter current new failures when compared to known good results
US20160342720A1 (en) Method, system, and computer program for identifying design revisions in hardware design debugging
JP7404839B2 (en) Identification of software program defect location
CN110515826A (en) A kind of software defect positioning method based on number frequency spectrum and neural network algorithm
WO2017201853A1 (en) Method for locating program regression fault using slicing model
CN103198016A (en) Software error positioning method based on joint dependent probability modeling
CN110990282B (en) Automatic unit testing method
CN110990289B (en) Method and device for automatically submitting bug, electronic equipment and storage medium
Lipka et al. A method for semi-automated generation of test scenarios based on use cases
US10761962B1 (en) Automated software program repair
US10642716B1 (en) Automated software program repair
CN110851353A (en) Concurrent program defect positioning method based on Delta debug and constraint solution
US10481969B2 (en) Configurable system wide tests
US11256612B2 (en) Automated testing of program code under development
CN103150254B (en) Error locating method for software based on state-dependent probabilistic modeling
Burnard et al. Verifying and validating automatically generated code
Sharma et al. Model-based testing: the new revolution in software testing
Dixit et al. FormTester: effective integration of model-based and manually specified test cases
US11740895B2 (en) Generation of software program repair explanations
CN108228460A (en) A kind of visual testing scenario generation method and system

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16902840

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 23.05.2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16902840

Country of ref document: EP

Kind code of ref document: A1