WO2021115186A1 - 基于ann的程序检测方法和检测系统及应用 - Google Patents

基于ann的程序检测方法和检测系统及应用 Download PDF

Info

Publication number
WO2021115186A1
WO2021115186A1 PCT/CN2020/133517 CN2020133517W WO2021115186A1 WO 2021115186 A1 WO2021115186 A1 WO 2021115186A1 CN 2020133517 W CN2020133517 W CN 2020133517W WO 2021115186 A1 WO2021115186 A1 WO 2021115186A1
Authority
WO
WIPO (PCT)
Prior art keywords
test
target program
value
input
model
Prior art date
Application number
PCT/CN2020/133517
Other languages
English (en)
French (fr)
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 遵义职业技术学院
Priority to US17/783,298 priority Critical patent/US20230032058A1/en
Priority to EP20899972.2A priority patent/EP4075281A4/en
Publication of WO2021115186A1 publication Critical patent/WO2021115186A1/zh
Priority to US17/836,102 priority patent/US20220300820A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • 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
    • 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/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/10Interfaces, programming languages or software development kits, e.g. for simulating neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/048Activation functions

Definitions

  • the invention belongs to software detection technology, and specifically relates to a software function error detection method and a system for constructing a software detection model.
  • Software testing is a process used to promote the correctness, integrity, safety and quality of software. In other words, software testing is a review or comparison process between actual output and expected output.
  • the current software testing has basically formed: static testing method, dynamic testing method, black box testing method and white box testing method; the four testing methods have corresponding advantages for different software. In the actual application process, it is often mixed testing, and it can also be tested separately for simple programs. The specific functions and concepts of the four test methods are well-known technologies and will not be repeated here.
  • the black box test is to detect whether the software functions meet expectations, observe the data output through data input, and check whether the internal functions of the software are normal. In order to judge as much as possible whether the software function is implemented correctly or there are wrong results.
  • black box testing can only detect all errors in the program if exhaustive input testing is used, and all possible inputs are considered as test conditions.
  • the black box testing behavior must be able to be quantified in order to truly guarantee the quality of the software, and test cases are one of the methods to quantify the testing behavior.
  • test cases In the process of constructing test cases, we need to understand what the functions of the software are, and know the rules of the software, that is, because there are many function points, we need to build test cases based on functions, and writing test case documents should have a document template. Meet the requirements of internal regulations.
  • BP neural network is used to test software.
  • the program uses the probability of an artificial neural network to form an "input and output value set” through the input and output values of the algorithm program, and uses the input and output value set as the basis for building an artificial neural network, thus forming an "artificial neural network model” It has the same function as the tested "algorithm program”.
  • the tested "source code” is also called the target program in the following articles.
  • the target program Since the internal situation of the tested "source code” (hereinafter also referred to as the target program) is not known during the detection process, the calculations corresponding to the "source code” we want to check are often complicated, and the input value is an infinite number of variables. We cannot verify the input values one by one through the "traversal" method; this will result in that we can only take a random input of a part of the data to verify whether the function of the target program is correct; but in this way, the timely output results are completely consistent with our expected results, and we cannot Determine whether the function of the target program is correct; even if it is a limited input value, if the input amount is very large, the one-by-one verification method is a waste of resources.
  • the purpose of this application is to provide an ANN-based program detection method to solve the problem of not being able to obtain effective test input values when the actual requirements of the target program and the structure of the target program itself are not known.
  • the ANN-based program testing method includes the following steps:
  • Step 1 Routine testing: Test the code and function realization of the target program to ensure that the target program can run normally;
  • Step 2 Obtain the test model: Use the artificial neural network trainer to construct the initial model of the artificial neural network, use the input value and corresponding output value of the target program as training samples, and visualize the artificial neural network model constructed through simulation software. The training samples train the initial model. When the initial model is in the convergent state, stop adding training samples, and define the model in the convergent state as the test model;
  • Step 3 Selection of test output value: When the input value range of the target program is less than one million, take all the input values, otherwise at least one million random input values of the target program are input into the test model, according to the test The calculation of the model obtains the test output value;
  • Step 4 Selection of actual output value: take the same input value in step 3 and input it into the target program to obtain the actual output value;
  • Step 5 Filter the input value: compare the test output value and the actual output value corresponding to the same input value; if there is a deviation between the two, sort by the deviation value from large to small, and select the top 50 to 150 Corresponding input value; get the test value used to test whether the target program is correct.
  • Step 6 Store the test value of step 5 in a reproducible storage medium.
  • the application of the test value found by this method is to transfer the test value in step 6 to the target program for execution, and compare the running result with the actual functional requirements. If one of the running results does not meet the actual functional requirements, the target program is determined There are defects; otherwise, the target program is a program that meets the requirements.
  • the initial model of the artificial neural network is a BP neural network model; the input value of the target program is used as the input layer; the output value obtained after the input value is run through the target program is used as the output layer.
  • the initial model of the artificial neural network is a BP neural network model; the input value of the target program is used as the input layer; the output value obtained after the input value is run through the target program is used as the output layer; the number of nodes in the input layer and the output layer is 32 A.
  • the activation function used in the training process of the BP neural network model is: When the value of f(x) is less than 0.5, the output value of the output layer node takes 0. When the value of f(x) is greater than or equal to 0.5, the output value of the output layer node is taken as 1.
  • the output value of the hidden layer satisfies: Where w(j,m) represents the weight from the input layer node to the hidden layer node, and k is the number of hidden layer nodes.
  • the output value of the output layer satisfies: Where w ⁇ (m,n) represents the weight from the hidden layer node to the output layer node.
  • o n represents the output value realized by the function.
  • the error inversion algorithm is used to calculate the weights w(j,m) and w ⁇ (m.n). It includes two processes: forward propagation of information and back propagation of errors.
  • the input layer is responsible for receiving input information from the outside world and passing it to the hidden layer.
  • the hidden layer changes the information and sends it to the output layer. This is an active communication process. When the actual output does not match the expected output, it will enter the wrong backpropagation stage.
  • the error passes through the output layer, corrects the weights of each layer according to gradient descent, and returns to the hidden layer and the input layer.
  • the curve changes are observed through simulation software; the process of forward propagation of information and back propagation of errors is the process of continuously adjusting the weights of each layer, which can be very intuitively reflected in the curve changes, namely The process of neural network learning and training.
  • the range of input values in the training sample is less than 1 million, and all of them are used as training samples. Otherwise, 1 million are randomly selected as training samples.
  • 1 million are selected that have been able to mature the BP neural network model to a state of convergence.
  • this solution obtains the corresponding output by calling the target program, and uses the input and output as training artificial nerves.
  • the training samples of the network are used to obtain an artificial neural network model with functions similar to the objective function, and the input value is calculated through the model to obtain the output value. If there is a problem with the objective function, then there must be: the output value calculated by the model and the target for the same input value The output value of the function has a large deviation.
  • the output value corresponding to the deviation caused by the problem of the objective function must be in this column.
  • the input values of these output value pairs are delivered to the personnel who know the actual functional requirements of the program, and they can judge whether the target program has errors from a small range; that is, the target program can be accurately detected by using a small range of data. Whether there is a problem in the realization of the function.
  • an ANN-based program test detection system including: a basic program test unit, which is used to perform preliminary tests on the function of the target program and whether the program itself is wrong;
  • the artificial neural network trainer stores a variety of training models, and obtains the artificial neural network model of the convergence state through the training samples; the curve display connected with the artificial neural network trainer signal is used to display the convergence state of the model curve in real time; the memory is used A computer program is stored; a processor is used to implement the operation of the entire detection program when the computer program is executed; a readable storage medium is used to transfer data in various devices.
  • Figure 3 is a schematic diagram of the connection of the detection system of this solution.
  • Step 1 S1. Routine testing: The target program is tested for code and function realization. White box and black box tests are often used to ensure that the target program can run normally; this step can be implemented in the current conventional way, so don’t do it here. Detailed.
  • Step 2 S2.
  • Obtain the test model Use the artificial neural network trainer to build the initial model of the artificial neural network, use the input value and corresponding output value of the target program as the training sample, and train the initial model through the training sample.
  • the initial model is in After the convergence state, stop adding training samples, and define the model in the convergence state as the test model;
  • Step 3 S3. Selection of test output value: at least one million random input values of the target program are input into the test model, and the test output value is obtained according to the calculation of the test model;
  • Step 5 S5. Filter input value: compare the test output value and actual output value corresponding to the same input value; if there is a deviation between the two, sort them by deviation value from large to small, and select the top 50-150 The input value corresponding to the bit; get the test value used to test whether the target program is correct.
  • Step 6 S6 Store the test value of step 5 S5 in a reproducible storage medium.
  • Test application S7 Submit step 6 S6 to the judge who knows the actual functional requirements of the target program; the judge passes the test value to the target program to run, and the running result is compared with the actual functional requirement. If the running result has one of the If the actual functional requirements are not met, it is determined that the target program is defective, otherwise it means that the target program is written without errors and there is no functional defect.
  • the BP artificial neural network structure is used to establish a three-layer neural network model for learning.
  • the input layer node that represents the LabelSpace value is 32
  • the hidden layer node is k
  • the output layer node that represents the LabelSpace value after the label is assigned is 32.
  • the output value of the hidden layer node is: w(j,m) represents the weight from the input layer node to the hidden layer node.
  • the output value of the output layer node is: w ⁇ (m,n) represents the weight from the hidden layer node to the output layer node.
  • o n represents the output value realized by the function or the required output value.
  • the output value of the output layer node Since the value of the function f(x) is between 0 and 1, but the output value of the output layer node must be an integer 0 or 1, it is stipulated that when the value of f(x) is less than 0.5, the output value of the output layer node is taken 0. When the value of f(x) is greater than or equal to 0.5, the output value of the output layer node is taken as 1.
  • the error reverse algorithm (BP algorithm) is used to calculate the weights w(j,m) and w ⁇ (m.n). It includes two processes: forward propagation of information and back propagation of errors.
  • the input layer is responsible for receiving input information from the outside world and passing it to the hidden layer.
  • the hidden layer changes the information and sends it to the output layer. This is an active communication process. When the actual output does not match the expected output, it will enter the wrong backpropagation stage.
  • the error passes through the output layer, corrects the weights of each layer according to gradient descent, and returns to the hidden layer and the input layer.
  • the process of forward propagation of information and back propagation of error is the process of constantly adjusting the weights of each layer, that is, the process of neural network learning and training.
  • this embodiment uses the BP artificial neural network model to construct the test model, it is not limited to using this artificial neural network model to construct the test model.
  • Step 1 Judge the label allocation and determine whether the label space contains continuous idleness
  • Step 2 If the label is greater than or equal to the allocated number, allocate the label according to Table 1, and return 0; otherwise, return 1;
  • Assign_Label_Func() The function implementation of Assign_Label_Func() is given below. Since the code has passed the basic function and code correctness tests, it is the code that can be executed, so it can generate valid output based on the input.
  • the defect code form is as follows:
  • Table 1 Visual table of output value display range
  • Table 2 when there are code defects, when input is added to the test model and the target program respectively; Table 2 is the statistical output value, how many mismatches between the test model and the target program. Table 3 shows the three largest deviation values in the corresponding input.
  • Test model Function under test 300 102 120 400 11 59 600 0 1 800 0 1 1000 0 0
  • Table 2 and Table 3 can illustrate: As the amount of learning increases, the test model tends to converge, and the deviation between the test model and the target program becomes smaller.
  • the program detection device includes: a memory 105, which is used to store a computer program, and stores the program code that requires calculations in this solution; a processor 101, which is used to implement the steps of the program detection method of the above method embodiment when the computer program is executed .
  • the Shengong neural network trainer 100 may have relatively large differences due to different configurations or performances, and may include one or more processors 101 (central processing units, CPU) (for example, one or more processors) and a memory 105,
  • the storage medium 300 of the target program and the test model may be short-term storage or permanent storage.
  • the program stored in the memory 105 may include one or more unit modules, and each unit module may include a separately executable target program.
  • the processor 101 may communicate with the storage medium 300 through the input/output interface 106, and execute a series of instruction operations in the storage medium on the artificial neural network trainer 100.
  • the artificial neural network trainer 100 can run on multiple operating systems. For example, Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.; the artificial neural network trainer 100 communicates with the curve display 200 through the input and output interface 106 to display the degree of convergence of the test model.
  • Windows ServerTM Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
  • the artificial neural network trainer 100 communicates with the curve display 200 through the input and output interface 106 to display the degree of convergence of the test model.
  • the readable storage medium can specifically be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk, or an optical disk that can store program codes. Readable storage medium.

Abstract

一种基于ANN的程序测试方法,针对功能可完成、代码能正常运行的目标程序进行测试,涉及软件测试领域。所述方法包括先通过人工神经网络构建测试模型,然后取目标程序的输入值输入到测试模型中,根据该测试模型的计算得到测试输出值;再然后,输入值输入到目标程序得到实际输出值;根据同一输入值对应的测试输出值和实际输出值的偏差量选出排在前50~150位对应的输入值,将选出的输入值传递到目标程序进行运行,运行结果与实际功能需求进行对比,如果运行结果有其一与实际功能需求不符合,则判定目标程序存在缺陷。当目标程序具体代码规格和实现需求均不知晓的情况,采用所述测试方法可以很好的得到准确的测试用例,减少了测试过程的资源消耗。

Description

基于ANN的程序检测方法和检测系统及应用 技术领域
本发明属于软件检测技术,具体涉及到软件功能错误检测方法和构建软件检测模型的系统。
背景技术
软件测试是用来促进鉴定软件的正确性、完整性、安全性和质量的过程。换句话说,软件测试是一种实际输出与预期输出之间的审核或者比较过程。
现在的软件测试经过长期人们经验积累和技术的改进,基本上形成了:静态测试方法、动态测试方法、黑盒测试方法和白盒测试方法;四种测试方式针对不同的软件有相应的优势。在实际运用过程中经常是混合测试,对于简单程序也可单独测试。四种测试方式具体的作用和概念为公知技术,在此不再赘述。
其中,黑盒测试是针对软件功能是否达到预期来进行检测,通过数据输入观察数据输出,检查软件内部功能是否正常。为了尽可能判断出软件功能实现是正确的或者存在错误的结果。从理论上讲,黑盒测试只有采用穷举输入测试,把所有可能的输入都作为测试情况考虑,才能查出程序中所有的错误。实际上测试情况有无穷多个,人们不仅要测试所有合法的输入,而且还要对那些不合法但可能的输入进行测试。这样看来,完全测试是不可能的,所以我们要进行有针对性的测试,通过制定测试案例指导测试的实施,保证软件测试有组织、按步骤,以及有计划地进行。黑盒测试行为必须能够加以量化,才能真正保证软件质量,而测试用例就是将测试行为具体量化的方法之一。
测试用例在构建过程中,我们需要了解软件实现的功能是什么,并且需要知道软件的规则,也就是由于功能点较多,需要根据功能来构建测试案例,编写测试用例文档应有文档模板,须符合内部的规范要求。
设计基本事件的用例,应该参照用例规约(或设计规格说明书),根据关联的功能、操作按路径分析法设计测试用例。如何灵活运用各种基该方法来设 计完整的测试用例,需要很强的逻辑性和专业性,现在要设计出准确的测试用例,全凭测试设计人员的丰富经验和精心设计。
随着人工神经网络的概念出现,研究人员也将该概念逐渐应用于软件测试领域中,人工神经网络具有“自我学习”的能力,现在用神经网络用于软件检测,用途主要是在形成准确的测试用例上,如作者“吕珊珊”在其硕士论文“基于BP神经网络软件测试缺陷预测技术研究及应用”中提到,采用BP神经网络对软件进行测试,该文中的研究重点是通过对一段算法程序(函数)采用人工神经网络的概率通过对该算法程序的输入和输出值形成“输入输出值集合”,将输入输出值集合作为构建人工神经网络的基础,这样形成的“人工神经网络模型”与被测的“算法程序”具有相同的功能。
该文献的观点虽然很好的证明了通过“人工神经网络”构建的模型在功能上可以等价于提供“输入输出集合”的“算法程序”;但是要用于检测一个功能未知、结构未知、程序复杂程度未知的“算法程序”是否有错误,该文献还没有给出指导方向,用上述方法也无法得到测试用例。
在实际工程应用中,要加快“软件”尽快推入市场”,企业可以将“软件测试”环节外包给专门进行“软件测试”的机构完成,由于知识产权意识逐渐在人们心中受到重视。在外包过程中,其实是不希望将“源代码”和“需求规格”交给软件测试机构的,基于此,可对“源代码”进行加密,检测机构只能进行类似“黑盒检测”方式检测“源代码”的功能是否正确。
被测“源代码”在后面的文章中也称目标程序。
由于在检测过程中不知晓被测“源代码”(下文也称目标程序)的内部情况,常常我们要检测的“源代码”对应的计算很复杂,输入值为无穷多的一个变量,这个时候我们无法通过“遍历”方式将输入值进行一一验证;这样将导致,我们只能采取随机输入一部分数据来验证目标程序的功能是否正确;但是这样及时输出结果与我们预期结果完全一致,也无法断定目标程序的功能是否正确;即使是有限个输入值,如果输入量非常大时候,采用一一验证的办法也是非常浪费资源。
发明内容
本申请的目的是提供一种基于ANN的程序检测方法,来解决在无法得知目标程序实际需求和目标程序本身结构的状态下,无法得到有效的测试输入值的问题。
为了达到上述目和解决上述问题,本申请提供的基于ANN的程序测试方法,包括如下步骤:
步骤一,常规测试:将目标程序进行代码和功能实现测试,确保目标程序能够正常运行;
步骤二、得到测试模型:利用人工神经网络训练器构建人工神经网络的初始模型,将目标程序的输入值及对应的输出值作为训练样本,通过仿真软件将构建的人工神经网络模型进行可视化,通过训练样本对初始模型进行训练,当初始模型处于收敛状态后,停止增加训练样本,并将收敛状态的模型定义为测试模型;
步骤三、测试输出值的选取:当目标程序的输入值范围小于一百万个,取全部输入值,否则至少取随机的一百万个目标程序的输入值输入到测试模型中,根据该测试模型的计算得到测试输出值;
步骤四、实际输出值的选取:取步骤三中同样的输入值输入到目标程序中,进而得到实际输出值;
步骤五、筛选输入值:对同一输入值对应的测试输出值和实际输出值进行比较;如果两者存在偏差量,以偏差量数值从大到小进行排序,选出排在前50~150位所对应的输入值;得到用于测试目标程序是否正确的测试值。
步骤六、将步骤五的测试值存储在可复制的存储介质中。
通过上述方法,可以准确的找到50~150个测试值,具体内容见实施例中描述。
本方法找到的测试值的应用:是将步骤六中的测试值传递到目标程序进行运行,运行结果与实际功能需求进行对比,如果运行结果有其一与实际功能需求不符合,则判定目标程序存在缺陷;否则,目标程序为符合要求的程序。
在步骤二中,所述人工神经网络的初始模型为BP神经网络模型;将目标程序的输入值作为输入层;将输入值经过目标程序运行后得到的输出值作为输出层。所述人工神经网络的初始模型为BP神经网络模型;将目标程序的输入值作为输入层;将输入值经过目标程序运行后得到的输出值作为输出层;输入层和输出层的节点数为32个。
BP神经网络模型在训练过程中采用的激活函数为:
Figure PCTCN2020133517-appb-000001
当f(x)的值小于0.5时,输出层节点的输出值取0。当f(x)的值大于或等于0.5时,输出层节点的输出值取为1。
隐藏层的输出值满足:
Figure PCTCN2020133517-appb-000002
其中w(j,m)表示从输入层节点到隐藏层节点的权重,k为隐藏层的节点数。
输出层的输出值满足:
Figure PCTCN2020133517-appb-000003
其中w`(m,n)表示从隐藏层节点到输出层节点的权重。
偏差量满足:
Figure PCTCN2020133517-appb-000004
其中o n表示函数实现的输出值。
误差反向算法用于计算权重w(j,m)和w`(m.n)。它包括两个过程:信息的正向传播和误差的反向传播。输入层负责接收外部世界的输入信息并将其传递给隐藏层。隐藏层更改信息并将其发送到输出层。这是一个积极的传播过程。当实际输出与预期输出不匹配时,它将进入错误的反向传播阶段。误差通过输出层,根据梯度下降修正各层的权值,并传回隐藏层和输入层。
在对BP神经网络模型进行训练过程中,通过仿真软件观察曲线变化;信息正向传播和误差反向传播的过程是不断调整各层权值的过程,可以很直观的体现在曲线变化上,即神经网络学习和训练的过程。
为了减少工作强度,训练样本中输入值的取值范围少于100万个,则全部作为训练样本,否则随机选择100万个作为训练样本。针对现在计算机水平100 万个的计算基本上在几秒中就可以完成,同时根据曲线输出的反馈,选取100万个已经能够将BP神经网络模型训练成熟达到收敛的状态。
综上,通过本申请的检测方法的优点,当得知有一个可以执行的程序代码,但是功能全然不知的状态下,本方案通过调用目标程序获得相应的输出,将输入和输出作为训练人工神经网络的训练样本,得到功能与目标函数相近的人工神经网络模型,将输入值通过该模型计算得到输出值,如果目标函数存在问题,那么必定会出现:同一输入值由模型计算的输出值与目标函数的输出值存在较大偏差。
如果选取输出值中偏差排在前50位的,那么因为目标函数本身问题导致的偏差对应的输出值必定在此列。将这些输出值对的输入值交付给知晓该程序实际功能需求的人员,他们就可以从很小范围来判断出目标程序是否存在错误了;即实现了使用小范围数据就可以准确的检测目标程序是否在功能实现上存在问题。
为实现上述方法,本申请还提供了基于ANN的程序测试的检测系统包括:程序基础测试单元,用于目标程序的功能和程序本身是否错误进行初步测试;
人工神经网络训练器,存储有多种训练模型,通过训练样本得到收敛状态的人工神经网络模型;与人工神经网络训练器信号连接的曲线显示器,用于实时显示模型曲线的收敛状态;存储器,用于存储计算机程序;处理器,用于执行所述计算机程序时实现整个检测程序的运行;可读存储介质,用于在各设备中转移数据。
附图说明
图1、为本方案的检测方法的流程图;
图2、BP人工神经网络模型结构图;
图3、为本方案的检测系统的连接示意图。
具体实施方式
下面通过具体实施方式进一步详细的说明:
实施例1:
如图1所示:
步骤一S1、常规测试:将目标程序进行代码和功能实现测试,常常会采取白盒和黑盒测试,确保目标程序能够正常运行;该步骤采用现在常规的方式来实现即可,在此不做详述。
步骤二S2、得到测试模型:利用人工神经网络训练器构建人工神经网络的初始模型,将目标程序的输入值及对应的输出值作为训练样本,通过训练样本对初始模型进行训练,当初始模型处于收敛状态后,停止增加训练样本,并将收敛状态的模型定义为测试模型;
步骤三S3、测试输出值的选取:至少取随机的一百万个目标程序的输入值输入到测试模型中,根据该测试模型的计算得到测试输出值;
步骤四S4、实际输出值的选取:取步骤三中同样的输入值输入到目标程序中,进而得到实际输出值;
步骤五S5、筛选输入值:对同一输入值对应的测试输出值和实际输出值进行比较;如果两者存在偏差量,以偏差量数值从大到小进行排序,选出排在前50~150位所对应的输入值;得到用于测试目标程序是否正确的测试值。
步骤六S6、将步骤五S5的测试值存储在可复制的存储介质中。
测试应用S7、将步骤六S6递交给知晓该目标程序实际功能需求的判断者;该判断者将测试值传递到目标程序进行运行,运行结果与实际功能需求进行对比,如果运行结果有其一与实际功能需求不符合,则判定目标程序存在缺陷,否则表示目标程序编写无错误,没有功能上的缺陷。
实施例2:
针对程序在执行过程中,我们通过如下方式对人工神经网络进行训练,方式如下:
如图2所示,采用BP人工神经网络结构建立一个三层神经网络模型用于学习。标签分配前表示LabelSpace值的输入层节点为32,隐藏层节点为k,标签分配后表示LabelSpace值的输出层节点为32,
其激活功能为:
Figure PCTCN2020133517-appb-000005
隐藏层节点的输出值为:
Figure PCTCN2020133517-appb-000006
w(j,m)表示从输入层节点到隐藏层节点的权重。
输出层节点的输出值为:
Figure PCTCN2020133517-appb-000007
w`(m,n)表示从隐藏层节点到输出层节点的权重。
偏差定义如下:
Figure PCTCN2020133517-appb-000008
其中o n表示函数实现的输出值或需求的输出值。
由于函数f(x)的值介于0和1之间,但输出层节点的输出值必须是整数0或1,因此规定当f(x)的值小于0.5时,输出层节点的输出值取0。当f(x)的值大于或等于0.5时,输出层节点的输出值取为1。
误差反向算法(BP算法)用于计算权重w(j,m)和w`(m.n)。它包括两个过程:信息的正向传播和误差的反向传播。输入层负责接收外部世界的输入信息并将其传递给隐藏层。隐藏层更改信息并将其发送到输出层。这是一个积极的传播过程。当实际输出与预期输出不匹配时,它将进入错误的反向传播阶段。误差通过输出层,根据梯度下降修正各层的权值,并传回隐藏层和输入层。信息正向传播和误差反向传播的过程是不断调整各层权值的过程,即神经网络学习和训练的过程。
虽然本实施例是通过BP人工神经网络模型进行测试模型的构建,但是并不只限定使用这一种人工神经网络模型对测试模型进行构造。
实施例3
通过对存在缺陷的目标函数进行实际检测进行观察,首先选择32位内存的运算器;因为内部数据以二进制方式表示,我们直接观察到相应位置的0/1变化就可以知晓是否能够准确找到缺陷,具体如下:
用32位的二进制整数表示32个标签(第0位表示标签0,第1位表示标签1,依此类推),如果任何位的值为0,表示未分配标签;如果任何位的值为1,则已分配相应的标签。
我们可以通过计算机编写识别相应位置的状态变化完成自动识别。自动识 别的方法如下:
步骤1:对标签分配情况进行判断,判断标签空间是否包含连续空闲;
步骤2:如果是标签大于或等于分配数,根据表1来分配标签,并返回0;否则,返回1;
开始从低位向高位看;在满足“连续空闲标签的数量大于或等于所需分配标签的数量”的范围集中,查找第一次出现的连续空闲标签范围元素的最小数量。
在上面找到的元素中从低到高分配标签。
下面给出Assign_Label_Func()的函数实现。由于代码已通过了基本功能和代码正确性测试,所以它是可以被执行的代码,因此可以根据输入生成有效的输出。
完整代码实现方式:
Figure PCTCN2020133517-appb-000009
Figure PCTCN2020133517-appb-000010
Figure PCTCN2020133517-appb-000011
在函数Assn_Label_Func()的实现中,将该函数中一小段代码删除(上文中通过底线标注部分)来模拟目标程序分支遗漏的错误。
缺陷代码形式如下:
Figure PCTCN2020133517-appb-000012
Figure PCTCN2020133517-appb-000013
Figure PCTCN2020133517-appb-000014
由于这种删除,只是删除了其中个分支,属于部分功能遗漏,然而这种错误通过路径测试无法发现。
见表1所示:假设AssignNum的值等于3,即需要分配三个标签。正确代码应选择范围C。但是,因为删除上述部分的代码,循环结束后就直接忽略范围了C,就会从范围B开始选择。
Figure PCTCN2020133517-appb-000015
表1:输出值显示范围可视表
函数Assn_Label_Func()将用作被测函数,该函数的实现被删除了一小段代码。下一点是演示如何通过实施例1的检测方法发现代码缺陷。
如表2和表3所示,在存在代码缺陷的情况下,当分别给测试模型和目标程序加入输入量后;其中表2是统计输出值中,测试模型和目标程序有多少个不匹配。表3是表示对应输入量中存在的最大的三个偏差值。
输入量(次) 测试模型 被测函数
300 102 120
400 11 59
600 0 1
800 0 1
1000 0 0
表2:出现偏差数量的统计
Figure PCTCN2020133517-appb-000016
表3:对出现偏差的数值大小排序表
结论:
一、表2和表3中的结果可以说明:随着学习量的增大,测试模型趋于收敛,测试模型和目标程序的偏差值变小。
二、在相同条件下,由于目标程序存在缺陷,导致被测函数无法正确输出,因此与实际需求相对应的测试模型更接近于收敛性,且具有较小的偏差。
实施例4:
如图3所示:下文描述的检测系统与上文的检测方法可相互对应参照。该程序检测设备包括:存储器105,用于存储计算机程序,将本方案中涉及到需要运算的程序代码进行存储;处理器101,用于执行计算机程序时实现上述方法实施例的程序检测方法的步骤。
神功神经网络训练器100可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器101(central processing units,CPU)(例如,一个或一个以上处理器)和存储器105,存储目标程序和测试模型的存储介质300。其中,存储器105和存储介质300可以是短暂存储或持久存储。存储在存储器105的程序可以包括一个或一个以上单元模块,每个单元模块可以包括单独可执行的目标程序。
更进一步地,处理器101可以通过输入输出接口106与存储介质300连接通信,在人工神经网络训练器100上执行存储介质中的一系列指令操作。
人工神经网络训练器100可以基于多个操作系统上运行。例如,Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等;人工神经网络训练器100通过输入输出接口106与曲线显示器200通信,用于显示测试模型的收敛程度。
该可读存储介质具体可以为U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可存储程序代码的可读存储介质。
本领域人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。

Claims (9)

  1. 基于ANN的程序测试方法,其特征在于,包括如下步骤:
    步骤一,常规测试:将目标程序进行代码和功能实现测试,确保目标程序能够正常运行;
    步骤二、得到测试模型:利用人工神经网络训练器构建人工神经网络的初始模型,将目标程序的输入值及对应的输出值作为训练样本,通过训练样本对初始模型进行训练,当初始模型处于收敛状态后,停止增加训练样本,并将收敛状态的模型定义为测试模型;
    步骤三、测试输出值的选取:当目标程序的输入值范围小于一百万个,取全部输入值,否则至少取随机的一百万个目标程序的输入值输入到测试模型中,根据该测试模型的计算得到测试输出值;
    步骤四、实际输出值的选取:取步骤三中同样的输入值输入到目标程序中,进而得到实际输出值;
    步骤五、筛选输入值:对同一输入值对应的测试输出值和实际输出值进行比较;如果两者存在偏差量,以偏差量数值从大到小进行排序,选出排在前50~150位所对应的输入值;得到用于测试目标程序是否正确的测试值;
    步骤六、将选出的测试值存储到可读存储介质中以待复制;
    步骤七、将步骤六中的测试值传递到目标程序进行运行,运行结果与实际功能需求进行对比,如果运行结果有其一与实际功能需求不符合,则判定目标程序存在缺陷;否则,目标程序为符合要求的程序。
  2. 根据权利要求1所述的基于ANN的程序测试方法,其特征在于:在步骤二中,所述人工神经网络的初始模型为BP神经网络模型;包括输入层、隐藏层和输出层;将目标程序的输入值作为输入层;将输入值经过目标程序运行后得到的输出值作为输出层;输入层和输出层的节点数为32个。
  3. 根据权利要求2所述的基于ANN的程序测试方法,其特征在于,所述BP神经网络模型在训练过程中采用的激活函数为:
    Figure PCTCN2020133517-appb-100001
    当f(x)的值小于0.5时,输出层节点的输出值取0;当f(x)的值大于或等于0.5时,输出层节点的输出值取为1。
  4. 根据权利要求3所述的基于ANN的程序测试方法,其特征在于,BP神经网络模型的隐藏层的输出值满足:
    Figure PCTCN2020133517-appb-100002
    其中w(j,m)表示从输入层节点到隐藏层节点的权重,k为隐藏层的节点数。
  5. 根据权利要求4所述的基于ANN的程序测试方法,其特征在于,BP神经网络模型的输出层的输出值满足:
    Figure PCTCN2020133517-appb-100003
    其中w`(m,n)表示从隐藏层节点到输出层节点的权重。
  6. 根据权利要求5所述的基于ANN的程序测试方法,其特征在于:步骤五中所述的偏差量满足:
    Figure PCTCN2020133517-appb-100004
    其中o n表示函数实现的输出值。
  7. 根据权利要求1或6所述的基于ANN的程序测试方法,其特征在于:在步骤二中,在对BP神经网络模型进行训练过程中,通过仿真软件观察曲线变化。
  8. 根据权利要求1所述的基于ANN的程序测试方法,其特征在于:所述步骤二中的训练样本中输入值的取值范围少于100万个,则全部作为训练样本,否则随机选择100万个作为训练样本。
  9. 根据权利要求1或8所述基于ANN的程序测试方法提供的检测系统,其特征在于,包括:程序基础测试单元,用于目标程序的功能和程序本身是否错误进行初步测试;
    人工神经网络训练器,存储有多种训练模型,通过训练样本得到收敛状态的人工神经网络模型;
    与人工神经网络训练器信号连接的曲线显示器,用于实时显示模型曲线的收敛状态;
    存储器,用于存储目标程序和测试模型本身以及运行过程中产生的数据;
    处理器,用于执行所述目标程序和测试模型的运行;
    可读存储介质,用于在各设备中转移数据。
PCT/CN2020/133517 2019-12-09 2020-12-03 基于ann的程序检测方法和检测系统及应用 WO2021115186A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US17/783,298 US20230032058A1 (en) 2019-12-09 2020-12-03 Ann-based program testing method, testing system and application
EP20899972.2A EP4075281A4 (en) 2019-12-09 2020-12-03 ANN-BASED PROGRAM TESTING PROCEDURE AND TESTING SYSTEM AND APPLICATION
US17/836,102 US20220300820A1 (en) 2019-12-09 2022-06-09 Ann-based program testing method, testing system and application

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911253427.1 2019-12-09
CN201911253427.1A CN111026664B (zh) 2019-12-09 2019-12-09 基于ann的程序检测方法和检测系统及应用

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/836,102 Continuation US20220300820A1 (en) 2019-12-09 2022-06-09 Ann-based program testing method, testing system and application

Publications (1)

Publication Number Publication Date
WO2021115186A1 true WO2021115186A1 (zh) 2021-06-17

Family

ID=70205134

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/133517 WO2021115186A1 (zh) 2019-12-09 2020-12-03 基于ann的程序检测方法和检测系统及应用

Country Status (4)

Country Link
US (2) US20230032058A1 (zh)
EP (1) EP4075281A4 (zh)
CN (1) CN111026664B (zh)
WO (1) WO2021115186A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115617696A (zh) * 2022-12-14 2023-01-17 江苏国创新云信息技术服务有限公司 软件测试方法、装置、设备和计算机可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026664B (zh) * 2019-12-09 2020-12-22 遵义职业技术学院 基于ann的程序检测方法和检测系统及应用
CN113434408B (zh) * 2021-06-25 2022-04-08 北京理工大学 一种基于测试预言的单元测试用例排序方法
WO2024080521A1 (en) * 2022-10-12 2024-04-18 Samsung Electronics Co., Ltd. Systems and methods for on-device validation of a neural network model

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103995775A (zh) * 2014-05-20 2014-08-20 浪潮电子信息产业股份有限公司 一种基于神经网络的测试数据生成方法
CN105843743A (zh) * 2016-04-11 2016-08-10 南京邮电大学 一种特殊自动化测试用例实际输出结果正确性的验证方法
CN108170594A (zh) * 2017-12-25 2018-06-15 郑州云海信息技术有限公司 一种神经网络模型的测试方法、装置及设备
CN108470000A (zh) * 2018-03-06 2018-08-31 睿云联(厦门)网络通讯技术有限公司 通讯终端软件自动测试方法、系统及介质
CN110297764A (zh) * 2019-05-30 2019-10-01 北京百度网讯科技有限公司 漏洞测试模型训练方法和装置
US20190362222A1 (en) * 2018-05-22 2019-11-28 Adobe Inc. Generating new machine learning models based on combinations of historical feature-extraction rules and historical machine-learning models
CN111026664A (zh) * 2019-12-09 2020-04-17 遵义职业技术学院 基于ann的程序检测方法和检测系统及应用

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2004268576A1 (en) * 2003-08-21 2005-03-10 Ischem Corporation Automated methods and systems for vascular plaque detection and analysis
CN101398758B (zh) * 2008-10-30 2012-04-25 北京航空航天大学 一种代码抄袭的检测方法
US10275227B1 (en) * 2015-02-20 2019-04-30 The Mathworks, Inc. Determining functional equivalence of configurations of a model
CN105608004A (zh) * 2015-12-17 2016-05-25 云南大学 一种基于cs-ann的软件缺陷预测方法
CN108008977B (zh) * 2017-12-27 2021-01-15 遵义职业技术学院 一种面向函数外包的软件开发服务平台
CN108170405B (zh) * 2017-12-27 2021-01-19 遵义职业技术学院 一种面向业务变量的软件开发方案生成方法
EP3735636B1 (en) * 2018-02-06 2021-09-22 Siemens Aktiengesellschaft Artificial intelligence enabled output space exploration for guided test case generation
EP3782082A1 (en) * 2018-05-18 2021-02-24 Google LLC Systems and methods for debugging neural networks with coverage guided fuzzing
CN108763096A (zh) * 2018-06-06 2018-11-06 北京理工大学 基于深度信念网络算法支持向量机的软件缺陷预测方法
US10460235B1 (en) * 2018-07-06 2019-10-29 Capital One Services, Llc Data model generation using generative adversarial networks

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103995775A (zh) * 2014-05-20 2014-08-20 浪潮电子信息产业股份有限公司 一种基于神经网络的测试数据生成方法
CN105843743A (zh) * 2016-04-11 2016-08-10 南京邮电大学 一种特殊自动化测试用例实际输出结果正确性的验证方法
CN108170594A (zh) * 2017-12-25 2018-06-15 郑州云海信息技术有限公司 一种神经网络模型的测试方法、装置及设备
CN108470000A (zh) * 2018-03-06 2018-08-31 睿云联(厦门)网络通讯技术有限公司 通讯终端软件自动测试方法、系统及介质
US20190362222A1 (en) * 2018-05-22 2019-11-28 Adobe Inc. Generating new machine learning models based on combinations of historical feature-extraction rules and historical machine-learning models
CN110297764A (zh) * 2019-05-30 2019-10-01 北京百度网讯科技有限公司 漏洞测试模型训练方法和装置
CN111026664A (zh) * 2019-12-09 2020-04-17 遵义职业技术学院 基于ann的程序检测方法和检测系统及应用

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4075281A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115617696A (zh) * 2022-12-14 2023-01-17 江苏国创新云信息技术服务有限公司 软件测试方法、装置、设备和计算机可读存储介质

Also Published As

Publication number Publication date
EP4075281A4 (en) 2023-01-25
US20220300820A1 (en) 2022-09-22
EP4075281A1 (en) 2022-10-19
US20230032058A1 (en) 2023-02-02
CN111026664B (zh) 2020-12-22
CN111026664A (zh) 2020-04-17

Similar Documents

Publication Publication Date Title
WO2021115186A1 (zh) 基于ann的程序检测方法和检测系统及应用
Basile It’s the end of the gold standard as we know it. on the impact of pre-aggregation on the evaluation of highly subjective tasks
US11914941B2 (en) Integrated circuit layout validation using machine learning
Cheung Issues in solving the problem of effect size heterogeneity in meta-analytic structural equation modeling: A commentary and simulation study on Yu, Downes, Carter, and O’Boyle (2016).
WO2022156065A1 (zh) 一种文本情感分析方法、装置、设备及存储介质
Olewnik et al. Limitations of the House of Quality to provide quantitative design information
US20230072297A1 (en) Knowledge graph based reasoning recommendation system and method
Hesse-Biber et al. Testing hypotheses on qualitative data: The use of hyper research computer-assisted software
Chiam et al. Applying a selection method to choose Quality Attribute Techniques
WO2021147405A1 (zh) 客服语句质检方法及相关设备
CN113761193A (zh) 日志分类方法、装置、计算机设备和存储介质
CN113282514A (zh) 问题数据的处理方法、装置、计算机设备和存储介质
CN112131587A (zh) 一种智能合约伪随机数安全检验方法、系统、介质和装置
Jagadamba Online subjective answer verifying system using artificial intelligence
CN111859985A (zh) Ai客服模型测试方法、装置、电子设备及存储介质
Olewnik et al. Can a house without a foundation support design?
CN112799938A (zh) 一种基于python的microbit编程题目自动评测方法及系统
Shannaq et al. Software Product Quality Management Methodology & the Quantitative Assessment of Analyzability Indicators
Geraldi et al. Towards Initial Evidence of SMartyCheck for Defect Detection on Product-Line Use Case and Class Diagrams.
Mulla et al. Role of Machine Learning & Artificial Intelligence Techniques in Software Testing
CN113706292B (zh) 基于虚拟数据的信用卡测试方法、装置、设备及介质
Kundu et al. Selection and classification of common factors affecting the maintainability on the basis of common criteria
CN113568831B (zh) 基于蜕变测试的自监督深度学习型缺陷定位方法
Gupta et al. ANALYSIS OF OBJECT ORIENTED SYSTEM QUALITY MODEL USING SOFT COMPUTING TECHNIQUES
De Souza et al. Static Analysis Model For Assessing Source Codes With TFIDF

Legal Events

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

Ref document number: 20899972

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2020899972

Country of ref document: EP

Effective date: 20220711