CN110232023B - Software defect positioning method, device and medium based on convolutional neural network - Google Patents
Software defect positioning method, device and medium based on convolutional neural network Download PDFInfo
- Publication number
- CN110232023B CN110232023B CN201910429282.XA CN201910429282A CN110232023B CN 110232023 B CN110232023 B CN 110232023B CN 201910429282 A CN201910429282 A CN 201910429282A CN 110232023 B CN110232023 B CN 110232023B
- Authority
- CN
- China
- Prior art keywords
- neural network
- convolutional neural
- coverage information
- dimensional
- test case
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000013527 convolutional neural network Methods 0.000 title claims abstract description 147
- 230000007547 defect Effects 0.000 title claims abstract description 55
- 238000000034 method Methods 0.000 title claims abstract description 48
- 238000012360 testing method Methods 0.000 claims abstract description 220
- 238000012549 training Methods 0.000 claims abstract description 52
- 238000006243 chemical reaction Methods 0.000 claims abstract description 30
- 230000006870 function Effects 0.000 claims description 25
- 230000009466 transformation Effects 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 11
- 238000012545 processing Methods 0.000 claims description 10
- 230000004807 localization Effects 0.000 claims description 9
- 238000010276 construction Methods 0.000 claims description 7
- 238000011156 evaluation Methods 0.000 claims description 6
- 238000011176 pooling Methods 0.000 description 11
- 238000004364 calculation method Methods 0.000 description 6
- 238000004422 calculation algorithm Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000004913 activation Effects 0.000 description 3
- 238000001228 spectrum Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000001131 transforming effect Effects 0.000 description 2
- 241000041200 Nobia Species 0.000 description 1
- 206010042635 Suspiciousness Diseases 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 238000005065 mining Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000013522 software testing Methods 0.000 description 1
- 238000009827 uniform distribution Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3692—Test management for test results analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/084—Backpropagation, e.g. using gradient descent
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Quality & Reliability (AREA)
- Computer Hardware Design (AREA)
- General Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Evolutionary Computation (AREA)
- Computational Linguistics (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Biophysics (AREA)
- Data Mining & Analysis (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Artificial Intelligence (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the invention discloses a method, a device and a computer readable storage medium for positioning software defects based on a convolutional neural network, which are used for calling a preset test case to test a program to be tested and generating one-dimensional statement coverage information of the test case and an execution result of the test case; converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule; training the initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting the preset requirement; the incidence relation between the one-dimensional statement coverage information and the execution result of the test case is fully excavated through the convolutional neural network, the accuracy of the convolutional neural network in positioning software defects is effectively improved, the program to be tested is processed according to the convolutional neural network, the suspicious value of each statement in the program to be tested is obtained, and the predicted suspicious value is more accurate.
Description
Technical Field
The invention relates to the technical field of software testing, in particular to a method and a device for positioning software defects based on a convolutional neural network and a computer readable storage medium.
Background
Software bug fixes are intended to detect and locate error codes that cause software failures. The traditional debugging method for manually setting the breakpoint has the disadvantages of difficult breakpoint position selection and huge time overhead. Therefore, it is a common pursuit of the software academia and the industry to realize the automation of defect localization. In recent years, researchers have tried to propose a series of methods for assisting in automated defect localization from different perspectives, including a slice-based method, a program-invariant-based method, a model inspection method, a program-spectrum-based method, and the like.
Compared with a slicing-based method, a program invariant-based method and a model checking method, a spectrum-based defect localization (SFL) method is an important method which is effective because the characteristics of no need of considering the internal structure of a program and low execution overhead are provided. The SFL method mainly estimates the error possibility of program entities (such as sentences, predicates and the like) by comparing and analyzing program spectrum information of a tested program in successful execution and failure execution and constructing a corresponding suspicion degree calculation formula. The accuracy of software defect positioning cannot reach high due to the limitation of a suspicious degree calculation formula.
Therefore, how to improve the accuracy of software defect positioning is a problem to be solved urgently by those skilled in the art.
Disclosure of Invention
The embodiment of the invention aims to provide a method and a device for positioning software defects based on a convolutional neural network and a computer readable storage medium, which can improve the accuracy of positioning the software defects.
In order to solve the above technical problem, an embodiment of the present invention provides a method for locating a software defect based on a convolutional neural network, including:
the embodiment of the invention also provides a software defect positioning method based on the convolutional neural network, which comprises the following steps:
calling a preset test case to test a program to be tested, and generating one-dimensional statement coverage information of the test case and an execution result of the test case;
converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule;
training an initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting a preset requirement;
and processing the program to be tested according to the convolutional neural network to obtain the suspicious value of each statement in the program to be tested.
Optionally, the converting the one-dimensional statement coverage information of the test case into the two-dimensional statement coverage information according to the set conversion rule includes:
when the one-dimensional statement coverage information of the test case is dense data, converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to the corresponding relation between a function and the one-dimensional statement coverage information of the test case;
and when the one-dimensional statement coverage information of the test case is sparse data, randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list to obtain two-dimensional statement coverage information.
Optionally, the training the initial convolutional neural network with the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting a preset requirement includes:
dividing the sample data into a training sample set and a testing sample set;
training the initial convolutional neural network by using the training sample set to obtain a trained convolutional neural network;
inputting a target test sample into the convolutional neural network to obtain an output result; the target test sample is any one of the test samples in the test sample set which are not tested;
judging whether the deviation value of the output result and the execution result of the test sample is within a preset range or not;
if not, returning to the step of training the initial convolutional neural network by using the training sample set to obtain a trained convolutional neural network;
if so, selecting an untested test sample from the test sample set as a target test sample, returning to the step of inputting the target test sample into the convolutional neural network to obtain an output result, and taking the convolutional neural network as the convolutional neural network meeting the preset requirement until all the test samples in the test sample set are tested.
Optionally, the processing the program to be tested according to the convolutional neural network to obtain a suspicious value of each statement of the program to be tested includes:
constructing a virtual test case corresponding to each statement in the program to be tested;
converting the one-dimensional statement coverage information of the virtual test case into two-dimensional statement coverage information according to the conversion rule;
and inputting the two-dimensional statement coverage information into the convolutional neural network to obtain the suspicious value of each statement of the program to be tested.
The embodiment of the invention also provides a software defect positioning device based on the convolutional neural network, which comprises a generating unit, a converting unit, a training unit and an evaluating unit;
the generating unit is used for calling a preset test case to test the program to be tested and generating one-dimensional statement coverage information of the test case and an execution result of the test case;
the conversion unit is used for converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule;
the training unit is used for training an initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting a preset requirement;
and the evaluation unit is used for processing the program to be tested according to the convolutional neural network so as to obtain the suspicious value of each statement in the program to be tested.
Optionally, the transformation unit comprises a dense transformation unit and a sparse transformation unit;
the dense conversion module is used for converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to the corresponding relation between the function and the one-dimensional statement coverage information of the test case when the one-dimensional statement coverage information of the test case is dense data;
the sparse conversion module is used for randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list to obtain two-dimensional statement coverage information when the one-dimensional statement coverage information of the test case is sparse data.
Optionally, the training unit includes a dividing subunit, a training subunit, a testing subunit, a judging subunit, and a selecting subunit;
the dividing subunit is configured to divide the sample data into a training sample set and a test sample set;
the training subunit is configured to train the initial convolutional neural network by using the training sample set to obtain a trained convolutional neural network;
the test subunit is used for inputting a target test sample into the convolutional neural network to obtain an output result; the target test sample is any one of the test samples in the test sample set which are not tested;
the judging subunit is configured to judge whether a deviation value between the output result and the execution result of the test sample is within a preset range; if not, returning to the training subunit; if yes, triggering the selected subunit;
the selecting subunit is configured to select an untested test sample from the test sample set as a target test sample, and return the test sample to the testing subunit until all test samples in the test sample set are tested, and then use the convolutional neural network as a convolutional neural network meeting a preset requirement.
Optionally, the evaluation unit comprises a construction subunit, a transformation subunit and an output subunit;
the construction subunit is used for constructing a virtual test case corresponding to each statement in the program to be tested;
the conversion unit is used for converting the one-dimensional statement coverage information of the virtual test case into two-dimensional statement coverage information according to the conversion rule;
and the output subunit is used for inputting the two-dimensional statement coverage information into the convolutional neural network so as to obtain a suspicious value of each statement of the program to be tested.
The embodiment of the invention also provides a software defect positioning device based on the convolutional neural network, which comprises the following components:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the above convolutional neural network-based software defect localization method.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the software defect localization method based on the convolutional neural network are implemented as described above.
According to the technical scheme, the preset test case is called to test the program to be tested, and one-dimensional statement coverage information of the test case and an execution result of the test case are generated; in order to adapt to the data format of the convolutional neural network, one-dimensional statement coverage information of the test case needs to be converted into two-dimensional statement coverage information according to a set conversion rule; training the initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting the preset requirement; the method has the advantages that the incidence relation between the one-dimensional statement coverage information and the execution result of the test case is fully mined through the convolutional neural network, the accuracy of the convolutional neural network in positioning software defects is effectively improved, and when the software defects of the program to be tested need to be analyzed, the program to be tested can be processed according to the convolutional neural network, so that the suspicious value of each statement in the program to be tested can be obtained. The incidence relation between the one-dimensional statement coverage information of the test case and the execution result is effectively mined based on the convolutional neural network, so that the predicted suspicious value is more accurate.
Drawings
In order to illustrate the embodiments of the present invention more clearly, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is a flowchart of a method for locating a software defect based on a convolutional neural network according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a software defect locating apparatus based on a convolutional neural network according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a software defect locating apparatus based on a convolutional neural network according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative work belong to the protection scope of the present invention.
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Software bug fixes are primarily aimed at detecting and locating error codes that cause software failures. In the traditional method, calculation formulas of other related fields are often introduced, and a large amount of experimental research is carried out to design a calculation formula of the suspiciousness of defect positioning; or starting from the tested program, and constructing a new spectrum method by mining some regular information contained in the program, such as the information amount contained in the event, the execution track mode and the like. Based on the premise, researchers use statement coverage information generated by test case execution and an execution result of the test case to construct a suspicion degree calculation formula Tarrantula, so that software defect positioning is assisted. The Tarrantula formula defines 4 classes of factorsThe method is used for describing the relationship between statement coverage information generated by test case execution and an execution result: a is11Representing the number of times a certain statement is covered in the failure test; a is10Representing the number of times a certain statement is covered in the success test; a is00Representing the number of times that a statement is not covered in a success test; a is01Indicating the number of times a statement has not been covered in the failure test.
Part of the reasons for the effect difference of the conventional defect positioning method can be summarized as follows: how to utilize a11、a10、a00、a01The 4 weighting factors contain information to calculate the suspicious degree of the statement. According to the hypothesis of potential association between statement coverage information generated by test case execution and an execution result, the more accurate the weights of the 4 factors are considered, the better the defect positioning effect of the corresponding method is.
The potential correlation existing between statement coverage information generated by test case execution and execution results is the basis for determining the degree of suspicion. Obviously, the defect revealing information contained in the potential correlation is fully mined and utilized, and the effectiveness of defect positioning of the doubtful degree calculation formula is improved. Therefore, according to the software defect positioning method, device and computer readable storage medium based on the convolutional neural network provided by the embodiment of the invention, the convolutional neural network is utilized to fully mine the potential relationship between statement coverage information generated by the execution of the test case and the execution result, and the statement coverage information generated by the execution of the test case and the execution result of the test case are respectively used as the characteristic data and the marking data of the sample to train the convolutional neural network, so that the accuracy of the test result of the convolutional neural network is effectively improved.
Next, a software defect localization method based on a convolutional neural network according to an embodiment of the present invention is described in detail. Fig. 1 is a flowchart of a method for locating a software defect based on a convolutional neural network according to an embodiment of the present invention, where the method includes:
s101: and calling a preset test case to test the program to be tested, and generating one-dimensional statement coverage information of the test case and an execution result of the test case.
The test case is utilized to run in the program to be tested, when the test case traverses to a certain statement in the program to be tested, the test case is represented to cover the statement.
For convenience of description, P ═ s may be used1,s2,…,szDenotes the program to be tested. Wherein s isiAnd (1 is more than or equal to i and less than or equal to z) represents the ith statement, and z represents the number of statements forming the program to be tested.
The program to be tested is generally composed of a plurality of functions, each of which contains a plurality of statements. Expressing test case P ═ { f) in functional form1,f2,…,fm}. Wherein f isi(1. ltoreq. i.ltoreq.m) represents the ith function, and m represents the number of functions constituting the program.
fi={Ei1,Ei2,…,EinDenotes the function fiA set of statements in. Wherein E isij(1. ltoreq. i.ltoreq.m, 1. ltoreq. j.ltoreq.n) represents the function fiThe j-th statement of (1), n represents the function fiThe total number of sentences of (2).
T={t1,t2,…,tlDenotes the set of test cases. Wherein, ti(1. ltoreq. i. ltoreq.l) represents the ith test case.
Ps(ti)={e1,e2,…,ej,…,ezDenotes the test case ti(1 ≦ i ≦ l) executing the one-dimensional statement coverage information for the generated test case. Wherein e isj(1. ltoreq. j. ltoreq.z) represents tiWhether to cover statement sjIf t isiCovering statement sjThen ejValue 1, otherwise ejThe value is 0.
Rs(ti) Representing test cases ti(1. ltoreq. i.ltoreq.l) if tiSuccessful execution, then Rs (t)i) Is 0, if tiFailure to execute Rs (t)i) Is 1.
Taking a program to be tested as an example, the corresponding statement coverage information and test case execution result are shown in table 1:
TABLE 1
The correspondence between functions and statements is shown in table 2:
TABLE 2
S102: and converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule.
In the embodiment of the invention, a convolutional neural network is utilized to mine the potential relation between statement coverage information generated by test case execution and an execution result. Considering that the convolutional neural network is used for processing high-dimensional data, it is necessary to convert the one-dimensional statement coverage information of the obtained test case into two-dimensional statement coverage information.
In the embodiment of the invention, two different conversion modes can be adopted to convert the one-dimensional statement coverage information of the test case into the two-dimensional statement coverage information.
Specifically, when the one-dimensional statement coverage information of the test case is dense data, the one-dimensional statement coverage information of the test case can be converted into two-dimensional statement coverage information according to the corresponding relationship between the function and the one-dimensional statement coverage information of the test case; and when the one-dimensional statement coverage information of the test case is sparse data, randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list to obtain two-dimensional statement coverage information.
It should be noted that, in practical application, for sparse data, the one-dimensional statement coverage information of the test case may also be converted into two-dimensional statement coverage information according to the corresponding relationship between the function and the one-dimensional statement coverage information of the test case; for dense data, one-dimensional statement coverage information of the test case can also be randomly arranged in the two-dimensional list to obtain two-dimensional statement coverage information. In the embodiment of the present invention, there is no limitation on which conversion method is specifically used.
Assume that the number of columns and the number of rows of the converted two-dimensional data are Dh and Dl. When the one-dimensional statement coverage information of the test case is dense, according to the corresponding relationship between the functions and the statements in table 2, Dh may be equal to the number m of the functions, Dl may be equal to the number of the statements of the "function with the largest number of statements", and data in each column represents coverage information of the statements of a certain function. The initial format for converting the one-dimensional statement coverage information of the test case in table 1 into the two-dimensional statement coverage information is shown in table 3a below:
E11 | E21 | E31 |
E12 | E22 | filling in |
E13 | Filling in | Filling in |
TABLE 3a
When Dh Dl ≠ z, data filling is required for Dh Dl-z spaces. Wherein z represents the number of statements in the sample data.
The filled data can conform to the random normal distribution, uniform distribution, and the minimum value of the effective range is directly filled. Without loss of generality, the data to be filled may be set to 0, and accordingly, the form after filling table 3a is as shown in the following table:
using the format shown in Table 3a as an example, test case t1The corresponding two-dimensional statement coverage information is shown in the following table 3b, and the corresponding execution result is 1:
1 | 1 | 0 |
1 | 0 | 0 |
0 | 0 | 0 |
TABLE 3b
Test case t2The corresponding two-dimensional statement coverage information is shown in table 3c below, and the corresponding execution result is 0:
0 | 1 | 1 |
1 | 0 | 0 |
1 | 0 | 0 |
TABLE 3c
Test case t3The corresponding two-dimensional statement coverage information is shown in table 3d below, and the corresponding execution result is 1:
0 | 1 | 0 |
0 | 1 | 0 |
0 | 0 | 0 |
TABLE 3d
When the one-dimensional statement coverage information of the test case is sparse, the one-dimensional statement coverage data can be randomly placed in z grids of Dh multiplied by Dl grids,wherein
One initial format for converting the one-dimensional statement coverage information of the test case in table 1 into two-dimensional statement coverage information is shown in table 4a below:
E22 | E21 | E13 |
E12 | E11 | E31 |
TABLE 4a
It should be noted that the form of table 4a is only one possible table form because it is randomly set.
Using the format shown in Table 4a as an example, test case t1The corresponding two-dimensional statement coverage information is shown in the following table 4b, and the corresponding execution result is 1:
0 | 1 | 0 |
1 | 1 | 0 |
TABLE 4b
Test case t2The corresponding two-dimensional statement coverage information is shown in table 4c below, and the corresponding execution result is 0:
0 | 1 | 1 |
1 | 0 | 1 |
TABLE 4c
Test case t3The corresponding two-dimensional statement coverage information is shown in table 4d below, and the corresponding execution result is 1:
1 | 1 | 0 |
0 | 0 | 0 |
TABLE 4d
S103: and training the initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain the convolutional neural network meeting the preset requirement.
The two-dimensional statement coverage information is the statement coverage information form of the test case which can be identified by the convolutional neural network.
In the embodiment of the invention, sample data is divided into a training sample set and a test sample set; and training the initial convolutional neural network by utilizing the training sample set to obtain the trained convolutional neural network.
The convolutional neural network is mainly composed of input layers, convolutional layers, Pooling (Pooling) layers, full-link layers and output layers. By adding these layers together, a complete convolutional neural network can be constructed.
In the embodiment of the invention, the topological structure of the constructed convolutional neural network is as follows:
(1) input layer Input
The number of input layers is 1, and two-dimensional data of Dh × Dl is input.
(2) Convolutional layer
Determining the number of layers of the convolutional layer when constructing the convolutional layer; determining the number of convolution kernels, the size of the convolution kernels and the step length of convolution kernel sliding of each convolution layer; determining whether to add a bias (Nobias); determining whether to adopt a wide convolution operation (to complement 0 to the edge before the convolution operation); before activation of the activation function, it is determined whether to add L2 regularization penalizes the convolution kernel parameters themselves (L2 regularization parameters).
(3) Pooling layer
The construction of the pooling layer comprises the steps of determining the number of layers of the pooling layer; the pooling window size, the step size of the pooling window sliding, the form of the pooling operation (mean pooling, maximum pooling, etc.) is determined for each pooling layer.
(4) Full connection layer
The method comprises the steps of determining the number of layers of the full-connection layer when the full-connection layer is constructed; dropout parameters for each connection layer are determined.
(5) Output layer
The number of output layers is one, and the number of nodes is 1. The output layer outputs the classification label using a logistic function or a normalized exponential function (softmax function).
In an embodiment of the present invention, the activation function of each layer may use a modified Linear Unit (ReLU) function. The learning Algorithm may employ a Back Propagation Algorithm (BPA).
Taking any one of the untested test samples in the test sample set, i.e. the target test sample as an example, the target test sample can be input into the convolutional neural network to obtain an output result. Judging whether the deviation value of the output result and the execution result of the test sample is within a preset range or not; if not, returning to the step of training the initial convolutional neural network by using the training sample set to obtain the trained convolutional neural network; if so, selecting an untested test sample from the test sample set as a target test sample, returning to the step of inputting the target test sample into the convolutional neural network to obtain an output result, and taking the convolutional neural network as the convolutional neural network meeting the preset requirement until all the test samples in the test sample set are tested.
For example, the two-dimensional statement coverage information corresponding to the test sample is input to the convolutional neural network to obtain an output result Y ', the test case execution result corresponding to the test sample is Y, and when | Y' -Y | ≦ τ is satisfied, the deviation value between the output result and the execution result of the test sample is considered to be within the preset range. Otherwise, the deviation value of the output result and the execution result of the test sample is not in the preset range.
S104: and processing the program to be tested according to the convolutional neural network to obtain the suspicious value of each statement in the program to be tested.
After the convolutional neural network is trained, the defect of the program to be tested can be located according to the convolutional neural network. Considering the form of two-dimensional statement coverage information of a test case input during convolutional neural network training, correspondingly, when defect positioning is carried out on a program to be tested, a virtual test case corresponding to each statement in the program to be tested needs to be constructed; converting the one-dimensional statement coverage information of the virtual test case into two-dimensional statement coverage information according to a conversion rule; and inputting the two-dimensional statement coverage information into a convolutional neural network to obtain the suspicious value of each statement of the program to be tested.
When the virtual test case is constructed, a corresponding virtual test case can be constructed for each statement, and when one virtual test case runs in the program to be tested, only one corresponding statement in the program to be tested is called.
Take 6 statements contained in the program to be tested as an example, which are s in sequence1To s6。
Sentence s1Corresponding virtual test case ts1One-dimensional sentence coverage information of Ps' (ts)1)={1,0,0,0,0,0}。
Sentence s2Corresponding virtual test case ts2One-dimensional sentence coverage information of Ps' (ts)2)={0,1,0,0,0,0}。
Sentence s3Corresponding virtual test case ts3One-dimensional sentence coverage information of Ps' (ts)3)={0,0,1,0,0,0}。
Sentence s4Corresponding virtual test case ts4One-dimensional sentence coverage information of Ps' (ts)4)={0,0,0,1,0,0}。
Sentence s5Corresponding virtual test case ts5One-dimensional sentence coverage information of Ps' (ts)5)={0,0,0,0,1,0}。
Sentence s6Corresponding virtual test case ts6One-dimensional sentence coverage information of Ps' (ts)6)={0,0,0,0,0,1}。
(1) The format for converting the one-dimensional statement coverage information of the test case into the two-dimensional statement coverage information by adopting a dense processing mode, namely according to the corresponding relation between the function and the one-dimensional statement coverage information of the test case, is as follows:
sentence s1Virtual test case ts of1Corresponding toInput data to the convolutional neural network:
1 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
sentence s2Virtual test case ts of2Input data of the corresponding convolutional neural network:
0 | 0 | 0 |
1 | 0 | 0 |
0 | 0 | 0 |
sentence s3Virtual test case ts of3Input data of the corresponding convolutional neural network:
0 | 0 | 0 |
0 | 0 | 0 |
1 | 0 | 0 |
sentence s4Virtual test case ts of4Input data of the corresponding convolutional neural network:
0 | 1 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
sentence s5Virtual test case ts of5Input data of the corresponding convolutional neural network:
0 | 0 | 0 |
0 | 1 | 0 |
0 | 0 | 0 |
sentence s6Virtual test case ts of6Input data of the corresponding convolutional neural network:
0 | 0 | 1 |
0 | 0 | 0 |
0 | 0 | 0 |
(2) by adopting a sparse processing mode, namely randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list, the format of the obtained two-dimensional statement coverage information is as follows:
sentence s1Virtual test case ts of1Input data of the corresponding convolutional neural network:
0 | 0 | 0 |
0 | 1 | 0 |
sentence s2Virtual test case ts of2Input data of the corresponding convolutional neural network:
0 | 0 | 0 |
1 | 0 | 0 |
sentence s3Virtual test case ts of3Input data of the corresponding convolutional neural network:
0 | 0 | 1 |
0 | 0 | 0 |
sentence s4Virtual test case ts of4Input data of the corresponding convolutional neural network:
0 | 1 | 0 |
0 | 0 | 0 |
sentence s5Virtual test case ts of5Input data of the corresponding convolutional neural network:
1 | 0 | 0 |
0 | 0 | 0 |
sentence s6Virtual test case ts of6Input data of the corresponding convolutional neural network:
0 | 0 | 0 |
0 | 0 | 1 |
when the suspicious value of each sentence in the program to be tested is determined, which sentences are problem sentences can be determined according to the suspicious value of each sentence, so that the defect positioning is realized.
According to the technical scheme, the preset test case is called to test the program to be tested, and one-dimensional statement coverage information of the test case and an execution result of the test case are generated; converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule; training the initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting the preset requirement; the method has the advantages that the incidence relation between the one-dimensional statement coverage information and the execution result of the test case is fully mined through the convolutional neural network, the accuracy of the convolutional neural network in positioning software defects is effectively improved, and when the software defects of the program to be tested need to be analyzed, the program to be tested can be processed according to the convolutional neural network, so that the suspicious value of each statement in the program to be tested can be obtained. The incidence relation between the one-dimensional statement coverage information of the test case and the execution result is effectively mined based on the convolutional neural network, so that the predicted suspicious value is more accurate.
The suspicious value of each statement output by the convolutional neural network ranges from 0 to 1. In the embodiment of the invention, after the suspicious values of the sentences in the program to be tested are obtained, the sentences in the program to be tested can be arranged according to the descending order of the suspicious values to generate the software defect positioning report table. Taking 6 statements included in the program to be tested introduced in S104 as an example, the corresponding software defect location report table is as follows:
degree of suspicionValue of | Sentence si |
0.93 | s1 |
0.91 | s2 |
0.91 | s3 |
0.76 | s4 |
0.53 | s5 |
0.18 | s6 |
Software defect positioning report table
The software defect positioning report table is obtained by performing descending order arrangement on the suspicious values of the sentences in the program to be tested, so that related personnel can conveniently and visually know the defect condition of the sentences in the program to be tested, and the defect sentences can be quickly positioned and processed.
Fig. 2 is a schematic structural diagram of a software defect locating apparatus based on a convolutional neural network according to an embodiment of the present invention, including a generating unit 21, a transforming unit 22, a training unit 23, and an evaluating unit 24;
the generating unit 21 is configured to invoke a preset test case to test a program to be tested, and generate one-dimensional statement coverage information of the test case and an execution result of the test case;
the conversion unit 22 is configured to convert the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule;
the training unit 23 is configured to train the initial convolutional neural network by using the two-dimensional statement coverage information and the corresponding execution result as sample data, so as to obtain a convolutional neural network meeting a preset requirement;
the evaluation unit 24 is configured to process the program to be tested according to the convolutional neural network to obtain a suspicious value of each statement in the program to be tested.
Optionally, the transformation unit comprises a dense transformant unit and a sparse transformant unit;
the dense conversion module is used for converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to the corresponding relation between the function and the one-dimensional statement coverage information of the test case when the one-dimensional statement coverage information of the test case is dense data;
and the sparse conversion unit is used for randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list to obtain the two-dimensional statement coverage information when the one-dimensional statement coverage information of the test case is sparse data.
Optionally, the training unit includes a dividing subunit, a training subunit, a testing subunit, a judging subunit and a selecting subunit;
the dividing subunit is used for dividing the sample data into a training sample set and a test sample set;
the training subunit is used for training the initial convolutional neural network by utilizing the training sample set to obtain a trained convolutional neural network;
the test subunit is used for inputting the target test sample into the convolutional neural network to obtain an output result; the target test sample is any one of the test samples in the test sample set which are not tested;
the judgment subunit is used for judging whether the deviation value of the output result and the execution result of the test sample is within a preset range; if not, returning to the training subunit; if yes, triggering and selecting the subunit;
and the selecting subunit is used for selecting an untested test sample from the test sample set as a target test sample, returning to the testing subunit, and taking the convolutional neural network as the convolutional neural network meeting the preset requirement until all the test samples in the test sample set are tested.
Optionally, the evaluation unit comprises a construction subunit, a transformation subunit and an output subunit;
the construction subunit is used for constructing virtual test cases corresponding to all the sentences in the program to be tested;
the transformation unit is used for transforming the one-dimensional statement coverage information of the virtual test case into two-dimensional statement coverage information according to a transformation rule;
and the output subunit is used for inputting the two-dimensional statement coverage information into the convolutional neural network so as to obtain the suspicious value of each statement of the program to be tested.
The description of the features in the embodiment corresponding to fig. 2 may refer to the related description of the embodiment corresponding to fig. 1, and is not repeated here.
According to the technical scheme, the preset test case is called to test the program to be tested, and one-dimensional statement coverage information of the test case and an execution result of the test case are generated; in order to adapt to the data format of the convolutional neural network, one-dimensional statement coverage information of the test case needs to be converted into two-dimensional statement coverage information according to a set conversion rule; training the initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting the preset requirement; the method has the advantages that the incidence relation between the one-dimensional statement coverage information and the execution result of the test case is fully mined through the convolutional neural network, the accuracy of the convolutional neural network in positioning software defects is effectively improved, and when the software defects of the program to be tested need to be analyzed, the program to be tested can be processed according to the convolutional neural network, so that the suspicious value of each statement in the program to be tested can be obtained. The incidence relation between the one-dimensional statement coverage information of the test case and the execution result is effectively mined based on the convolutional neural network, so that the predicted suspicious value is more accurate.
Fig. 3 is a schematic structural diagram of a software defect locating apparatus 30 based on a convolutional neural network according to an embodiment of the present invention, including:
a memory 31 for storing a computer program;
a processor 32 for executing a computer program to implement the steps of the software defect localization method based on convolutional neural network as described above.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when being executed by a processor, the computer program realizes the steps of the software defect positioning method based on the convolutional neural network.
The software defect positioning method, device and computer readable storage medium based on the convolutional neural network provided by the embodiment of the invention are described in detail above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Claims (8)
1. A software defect positioning method based on a convolutional neural network is characterized by comprising the following steps:
calling a preset test case to test a program to be tested, and generating one-dimensional statement coverage information of the test case and an execution result of the test case;
converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule;
training an initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting a preset requirement;
processing the program to be tested according to the convolutional neural network to obtain the suspicious value of each statement in the program to be tested;
converting the one-dimensional statement coverage information of the test case into the two-dimensional statement coverage information according to the set conversion rule comprises:
when the one-dimensional statement coverage information of the test case is dense data, converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to the corresponding relation between a function and the one-dimensional statement coverage information of the test case;
and when the one-dimensional statement coverage information of the test case is sparse data, randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list to obtain two-dimensional statement coverage information.
2. The method of claim 1, wherein the training of the initial convolutional neural network with the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting preset requirements comprises:
dividing the sample data into a training sample set and a testing sample set;
training the initial convolutional neural network by using the training sample set to obtain a trained convolutional neural network;
inputting a target test sample into the convolutional neural network to obtain an output result; the target test sample is any one of the test samples in the test sample set which are not tested;
judging whether the deviation value of the output result and the execution result of the test sample is within a preset range or not;
if not, returning to the step of training the initial convolutional neural network by using the training sample set to obtain a trained convolutional neural network;
if so, selecting an untested test sample from the test sample set as a target test sample, returning to the step of inputting the target test sample into the convolutional neural network to obtain an output result, and taking the convolutional neural network as the convolutional neural network meeting the preset requirement until all the test samples in the test sample set are tested.
3. The method according to any one of claims 1-2, wherein the processing the program under test according to the convolutional neural network to obtain the suspicious value of each statement of the program under test comprises:
constructing a virtual test case corresponding to each statement in the program to be tested;
converting the one-dimensional statement coverage information of the virtual test case into two-dimensional statement coverage information according to the conversion rule;
and inputting the two-dimensional statement coverage information into the convolutional neural network to obtain the suspicious value of each statement of the program to be tested.
4. A software defect positioning device based on a convolutional neural network is characterized by comprising a generating unit, a converting unit, a training unit and an evaluating unit;
the generating unit is used for calling a preset test case to test the program to be tested and generating one-dimensional statement coverage information of the test case and an execution result of the test case;
the conversion unit is used for converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to a set conversion rule;
the training unit is used for training an initial convolutional neural network by taking the two-dimensional statement coverage information and the corresponding execution result as sample data to obtain a convolutional neural network meeting a preset requirement;
the evaluation unit is used for processing the program to be tested according to the convolutional neural network so as to obtain the suspicious value of each statement in the program to be tested;
the transformation unit comprises a dense transformation unit and a sparse transformation unit;
the dense conversion module is used for converting the one-dimensional statement coverage information of the test case into two-dimensional statement coverage information according to the corresponding relation between the function and the one-dimensional statement coverage information of the test case when the one-dimensional statement coverage information of the test case is dense data;
the sparse conversion module is used for randomly setting the one-dimensional statement coverage information of the test case in a two-dimensional list to obtain two-dimensional statement coverage information when the one-dimensional statement coverage information of the test case is sparse data.
5. The apparatus of claim 4, wherein the training unit comprises a dividing subunit, a training subunit, a testing subunit, a judging subunit, and a selecting subunit;
the dividing subunit is configured to divide the sample data into a training sample set and a test sample set;
the training subunit is configured to train the initial convolutional neural network by using the training sample set to obtain a trained convolutional neural network;
the test subunit is used for inputting a target test sample into the convolutional neural network to obtain an output result; the target test sample is any one of the test samples in the test sample set which are not tested;
the judging subunit is configured to judge whether a deviation value between the output result and the execution result of the test sample is within a preset range; if not, returning to the training subunit; if yes, triggering the selected subunit;
the selecting subunit is configured to select an untested test sample from the test sample set as a target test sample, and return the test sample to the testing subunit until all test samples in the test sample set are tested, and then use the convolutional neural network as a convolutional neural network meeting a preset requirement.
6. The device according to any one of claims 4 to 5, wherein the evaluation unit comprises a construction subunit, a transformation subunit and an output subunit;
the construction subunit is used for constructing a virtual test case corresponding to each statement in the program to be tested;
the conversion unit is used for converting the one-dimensional statement coverage information of the virtual test case into two-dimensional statement coverage information according to the conversion rule;
and the output subunit is used for inputting the two-dimensional statement coverage information into the convolutional neural network so as to obtain a suspicious value of each statement of the program to be tested.
7. A software defect locating device based on a convolutional neural network is characterized by comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the convolutional neural network-based software defect localization method of any of claims 1 to 3.
8. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the convolutional neural network-based software defect localization method as claimed in any one of claims 1 to 3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910429282.XA CN110232023B (en) | 2019-05-22 | 2019-05-22 | Software defect positioning method, device and medium based on convolutional neural network |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910429282.XA CN110232023B (en) | 2019-05-22 | 2019-05-22 | Software defect positioning method, device and medium based on convolutional neural network |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110232023A CN110232023A (en) | 2019-09-13 |
CN110232023B true CN110232023B (en) | 2021-07-06 |
Family
ID=67860968
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910429282.XA Expired - Fee Related CN110232023B (en) | 2019-05-22 | 2019-05-22 | Software defect positioning method, device and medium based on convolutional neural network |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110232023B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105893256A (en) * | 2016-03-30 | 2016-08-24 | 西北工业大学 | Software failure positioning method based on machine learning algorithm |
CN107330519A (en) * | 2017-06-26 | 2017-11-07 | 西北工业大学 | Fault Locating Method based on deep neural network |
CN108806698A (en) * | 2018-03-15 | 2018-11-13 | 中山大学 | A kind of camouflage audio recognition method based on convolutional neural networks |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA3064771A1 (en) * | 2017-06-01 | 2018-12-06 | Royal Bank Of Canada | System and method for test generation |
-
2019
- 2019-05-22 CN CN201910429282.XA patent/CN110232023B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105893256A (en) * | 2016-03-30 | 2016-08-24 | 西北工业大学 | Software failure positioning method based on machine learning algorithm |
CN107330519A (en) * | 2017-06-26 | 2017-11-07 | 西北工业大学 | Fault Locating Method based on deep neural network |
CN108806698A (en) * | 2018-03-15 | 2018-11-13 | 中山大学 | A kind of camouflage audio recognition method based on convolutional neural networks |
Non-Patent Citations (1)
Title |
---|
"基于程序频谱的动态缺陷定位方法研究";陈翔等;《软件学报》;20150330;第26卷(第2期);第390-412页 * |
Also Published As
Publication number | Publication date |
---|---|
CN110232023A (en) | 2019-09-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Kelly et al. | Bayesian inference for probabilistic risk assessment: A practitioner's guidebook | |
CN105468517B (en) | A kind of mistake of statistics localization method based on Black-box testing Cases yojan | |
Yu et al. | Predicting defect priority based on neural networks | |
CN114925536A (en) | Airborne system PHM testability modeling and diagnosis strategy optimization method and device | |
Grbac et al. | Stability of software defect prediction in relation to levels of data imbalance | |
CN114936158A (en) | Software defect positioning method based on graph convolution neural network | |
TWI570554B (en) | Software test apparatus, software test method and computer program product thereof | |
CN113065279A (en) | Method, device, equipment and storage medium for predicting total organic carbon content | |
CN114036531A (en) | Multi-scale code measurement-based software security vulnerability detection method | |
CN113946983A (en) | Method and device for evaluating weak links of product reliability and computer equipment | |
Perez et al. | A theoretical and empirical analysis of program spectra diagnosability | |
CN110232023B (en) | Software defect positioning method, device and medium based on convolutional neural network | |
CN109086186A (en) | log detection method and device | |
Li et al. | Locating vulnerability in binaries using deep neural networks | |
CN115333973B (en) | Device abnormality detection method, device, computer device, and storage medium | |
CN116578978A (en) | Multidimensional hierarchical hardware Trojan horse assessment method for IP soft core | |
Mesina et al. | Extremely accurate sequential verification of RELAP5-3D | |
CN115408927B (en) | Data processing method and device for predicting rock mass parameters | |
CN108133234B (en) | Sparse subset selection algorithm-based community detection method, device and equipment | |
CN115101135A (en) | Rock physical parameter sensitivity analysis method and device | |
CN115422821A (en) | Data processing method and device for rock mass parameter prediction | |
CN114818296A (en) | Manned space launching quality control method and device | |
CN112329108A (en) | Optimized anti-floating checking calculation method and system for subway station | |
Hatton | Defects, scientific computation and the scientific method | |
Dayman et al. | Characterizing Reactor Operations from Realistic Simulated Environmental Samples: Combining High-Performance Computing and Data Analytics |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20210706 |
|
CF01 | Termination of patent right due to non-payment of annual fee |