CN113568831B - Self-supervision deep learning type defect positioning method based on metamorphic test - Google Patents

Self-supervision deep learning type defect positioning method based on metamorphic test Download PDF

Info

Publication number
CN113568831B
CN113568831B CN202110852911.7A CN202110852911A CN113568831B CN 113568831 B CN113568831 B CN 113568831B CN 202110852911 A CN202110852911 A CN 202110852911A CN 113568831 B CN113568831 B CN 113568831B
Authority
CN
China
Prior art keywords
test
test case
coverage
mtg
metamorphic
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.)
Active
Application number
CN202110852911.7A
Other languages
Chinese (zh)
Other versions
CN113568831A (en
Inventor
胡安林
付凌峰
雷晏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing University
Original Assignee
Chongqing University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing University filed Critical Chongqing University
Priority to CN202110852911.7A priority Critical patent/CN113568831B/en
Publication of CN113568831A publication Critical patent/CN113568831A/en
Application granted granted Critical
Publication of CN113568831B publication Critical patent/CN113568831B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Abstract

The invention discloses a self-supervision deep learning type defect positioning method based on metamorphic test, which comprises the steps of firstly constructing metamorphic relation, generating source test cases and follow-up test cases on the basis of a given test case set without test predictors, then collecting coverage information and test output, carrying out aggregation and merging on the former, carrying out metamorphic relation verification on the latter to obtain a test result of total coverage information in each metamorphic relation group, integrating the test result into a coverage matrix and a violation vector, inputting the coverage matrix and the violation vector into a deep neural network model for training, learning the model, finally finishing prediction of suspicious values of codes by the model, and sequencing codes of a defect program according to the suspicious values to finish defect positioning. The method overcomes the limitation of deep learning type defect positioning, can be applied to the situation of test prediction missing, realizes the defect positioning oriented to the label-free data set in a self-supervision mode, and remarkably expands the application range.

Description

Self-supervision deep learning type defect positioning method based on metamorphic test
Technical Field
The invention relates to the field of defect positioning, in particular to self-supervision deep learning type defect positioning for a label-free data set.
Background
Software, a pure abstract knowledge product with a high degree of inherent complexity, is unavoidably error-free. In spite of the large amount of manpower and material resources put into practice in an effort to reduce the vulnerability of the software, the BUG is inevitably present in all kinds of software having a large scale. Thus, debugging also becomes a critical part throughout the software development and maintenance process, and does require a lot of labor and considerable time. To alleviate this burden, the academia has devised a number of techniques for automatic defect localization to help developers find BUGs more efficiently. In recent researches in this field, deep-Learning-based Fault Localization (DLFL) has gained much attention by virtue of its excellent localization effect. The DLFL takes the popular supervised deep learning model as the kernel, can effectively identify and digest patterns hidden in program execution information, and further utilizes the learned patterns to evaluate suspicious values of each line of sentences, which represents the responsibility of each line of sentences to program failure. Therefore, DLFL not only gives better effect, but also has stronger generalization capability than some other leading edge defect localization methods (e.g., spectrum-based defect localization).
Fig. 1 shows the basic flow of DLFL. Given a target program (i.e., defect-located object, defect-containing program) P containing N lines of code, a program containing M test cases t 1 ,t 2 ,…,t M ]Test case set of (a) and test prophetic [ o ] that must be prepared before DLFL begins 1 ,o 2 ,…,o M ]Wherein o i Store P at t i The expected output of the upper run. In the batch execution (batch execution), all test cases are input one by one to the target program for execution. Test case t i Is taken to and corresponds to the execution output of test prophetic o i Comparing to obtain the execution result y i To indicate whether the execution of the program has failed. At the same time, the runtime information concerning which statements (the term "statement" is used to represent a line of code in the present invention) have been executed is collected and summarized by the relevant tool to obtain x i Leaving for subsequent investigation. Next, DLFL uses matching pairs of execution results (i.e., pass or fail) and runtime information (i.e., statement overlays), (x i ,y i ) I e {1,2, …, M }, taking the former as a label and the latter as a sample, internalizing the relationship between the sample and the label by means of a deep learning network, training the model. Still further, DLFL evaluates the suspicious value of each line statement (i.e., the likelihood that the line code contains BUG) using a trained model, calculates [ s ] 1 ,s 2 ,…s N ]Wherein s is i The likelihood that the ith statement contains a defect is measured. In the last step, DLFL sorts all sentences from big to small according to suspicious values, and outputs a ranking list [ l ] of all sentences 1 ,l 2 ,…,l N ]Wherein l i Pointing to the code line number where the i-th suspicious statement is located.
However, as noted by the dashed box in FIG. 1, the label is a requirement that the DLFL be operational. In other words, supervised learning neural networks internal to DLFL require large scale tagged data sets. This fact allows DLFL to be applied only to those cases where test predictions are readily available. Without the tag, the deep learning model cannot learn which samples will cause program failure and what samples will not cause program failure, and thus cannot learn the association between runtime information and program behavior. In fact, the problem of test foreword missing is often present in practical work, such as numerical calculation type software and machine learning algorithms. Often, accurate or precise test languages are not available at all, or are costly, although possible. This pre-requisite for supervised learning then makes such an efficient technique impractical or impractical in many scenarios.
Disclosure of Invention
In view of the above problems in the prior art, an object of the present invention is to: the problem of applicability of deep learning type defect positioning on unlabeled data sets is solved, so that the method can be applied to the situation that the data sets lack labels.
In order to solve the technical problems, the invention adopts the following technical scheme: a self-supervision deep learning type defect positioning method based on metamorphic test comprises the following steps:
s101: constructing an metamorphic relation MR of the target program P according to priori knowledge;
s102: acquiring a test case set t, and picking all common M' group source test cases S= { S from the test case set t according to the MR requirement 1 ,s 2 ,…,s M′ (s is therein i ={s i1 ,s i2 … } represents the i-th set of source test cases, s ij Representation s i The j-th test case in the list is used for each source test case group s i Generating a corresponding subsequent test case group f for MR i ={f i1 ,f i2 …, where a set of corresponding source test cases and subsequent test cases are considered as the smallest test unit, i.e., an metamorphic test group MTG, the test case contained in the ith MTG is s i ∪f i
S103: all test cases in each MTG are input into the target program P one by one for execution, and execution output of each source test case and subsequent test cases in each MTG is collected
Figure BDA0003183013950000021
Sentence coverage matrix during execution>
Figure BDA0003183013950000022
Figure BDA0003183013950000023
Indicating the coverage obtained by executing the j-th source test case in the i-th set of source test case sets,/->
Figure BDA0003183013950000024
Representing a coverage vector obtained by executing a j-th test case in the i-th subsequent test case group; if it is to->
Figure BDA0003183013950000025
Or->
Figure BDA0003183013950000026
Unified use->
Figure BDA0003183013950000027
Representing, then the element therein->
Figure BDA0003183013950000028
Indicating whether the kth sentence is covered in the execution of test case c, covering +.>
Figure BDA0003183013950000029
Taking 1, uncovered->
Figure BDA00031830139500000210
0, where k has a value in the range of [1, N]N is the total number of defective program code statements;
s104: for each MTG, test case set s i ∪f i And corresponding execution output o i Using MR as a parameter to perform inspection to judge whether the MR is violated or not, and obtaining the test result of the MTG
Figure BDA0003183013950000031
Finally, a violation vector consisting of M' line test results is obtained>
Figure BDA0003183013950000032
Here m= { m 1 ,m 2 ,…,m M′ And represents all M' MTGs, M i Represents the ith MTG;
s105: coverage matrix for each MTG
Figure BDA0003183013950000033
Conversion to obtain and violate vector y (m) Aligned coverage matrix X (m)
S106: coverage matrix X obtained using S105 (m) And S104, the violation vector y (m) Respectively training a DLFL model as a sample and a label to obtain a trained model F;
s107: for the target program P, the following n×n identity matrix X is constructed as an auxiliary coverage matrix:
Figure BDA0003183013950000034
each row represents the coverage condition of one virtual test case on N sentences, and i virtual test cases only cover the ith sentence;
s108: inputting the auxiliary coverage matrix X into a model F to obtain suspicious value vectors
Figure BDA0003183013950000035
The suspicious value of each line of the N lines of code containing the defective program P is +.>
Figure BDA0003183013950000036
As an improvement, the coverage matrix of each MTG is set in S105
Figure BDA0003183013950000037
Conversion to obtain and violate vector y (m) Aligned coverage matrix X (m) The following formula is used:
Figure BDA0003183013950000038
Figure BDA0003183013950000039
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA00031830139500000310
indicating whether the kth sentence is covered in the execution of test case c; will s i ∪f i The coverage condition of each test case in the kth sentence is logically or operated to obtain the total coverage condition of the ith MTG in the sentence +.>
Figure BDA00031830139500000311
The coverage conditions of all N sentences form coverage vectors under the MTG
Figure BDA00031830139500000312
Finally, all M 'coverage vectors form a coverage matrix X of M' ×N (m)
Compared with the prior art, the invention has at least the following advantages:
the method of the invention uses the metamorphic relation to replace the test case to describe the expected behavior of the program, and on the other hand, the method defines the metamorphic label by checking whether the predefined metamorphic relation is violated. By adjusting the two aspects, the deep learning type defect positioning can work normally on the original unlabeled data set.
According to the method, the DLFL method is expanded from supervised learning to self-supervised learning by combining with metamorphic testing, so that a labeled data set is no longer a necessary condition for applying the DLFL.
The method of the invention uses the metamorphic relation to replace the test case to describe the expected behavior of the program, and on the other hand, defines the metamorphic tag by checking whether the predefined metamorphic relation is violated. By adjusting the two aspects, the deep learning type defect positioning can work normally on the original unlabeled data set.
Drawings
Fig. 1 is a workflow of DLFL.
Fig. 2 is a coverage matrix (samples) and failure vectors (labels).
Fig. 3 is a deep learning model of DLFL.
Fig. 4 is a secondary coverage matrix.
Fig. 5 is a basic flow chart of the method of the present invention.
Detailed Description
The present invention will be described in further detail below.
The DLFL is a model for learning a localization model capable of recognizing a statement potentially responsible for a program failure by using an artificial intelligence neural network including a plurality of hidden layers. Specifically, the DLFL takes as input information collected from executing test case sets, then learns complex nonlinear relationships between statement behavior and program failures using a neural network, and after training a model, the trained model is used to evaluate suspicious values for each line of statements containing defects, resulting in a sorted list of all statements in descending order of suspicious values. This section will only show the necessary details in this process.
The information collected from the execution of each test case is divided into two parts, runtime information and execution results, more precisely, overlay information (i.e., whether it is overlaid) and test results (i.e., whether it is dead).
After the program has completed a complete execution on a test case, those statements that have been executed at least once are said to be covered by the test case, and those that have not been executed are said to be uncovered. The covered state of all statements constitutes a binary vector, where a 1 means the covered state and a 0 means covered.
The test results indicate whether the program is running correctly. Typically, the test results are obtained by comparing the program output with test predictions that match the test case. If the two are not identical, the failure is called, and if the two are identical, the passing is considered. For the purpose of establishing a correlation between a defect statement and a failure result, the present invention indicates failure by 1 and passes by 0.
In summary, a target program containing N rows of sentences, and a test case set containing M test cases, can generate coverage vectors and test results as shown in FIG. 2, wherein x ij =[test caseicoversj-th statement],y i =[test case i results in failure]。[·]Called Ai Fosen brackets, which is essentially a function of the value range {0,1} and takes 1 if the condition in the brackets is satisfied and takes 0 if it is not satisfied). All coverage vectors constitute a coverage matrix (i.e., training samples) and all test results constitute failure vectors (i.e., training labels).
Fig. 3 mainly presents the deep learning process in DLFL. As illustrated in the figures, the present invention will introduce three representative DLFL techniques, which are also used in this experiment. These are CNN-FL using convolutional neural network, RNN-FL using recurrent neural network, and MLP-FL using multi-layer perceptron, respectively. These three neural networks have the same interface, i.e. they all have an input layer with N nodes and an output layer with only 1 node. During the training process, they all read in sample inputs row by row from the coverage matrix, updating the network weights so that the loss of difference between the output of the network and the labels in the failure vector is minimized. Thus, complex nonlinear relationships between coverage information and test results can be learned. The DLFL can then generate a model that is trained, i.e., a probabilistic-based classifier. Given an arbitrary coverage vector, it can predict how likely the coverage situation will cause program failure.
To determine suspicious values using the trained model, the DLFL first needs to construct an auxiliary coverage matrix as a test set. Fig. 4 shows the structure of this auxiliary coverage matrix. The system consists of coverage information of N virtual test cases, wherein each test case covers a unique line of sentences. By sending it to the trained model for prediction, the likelihood of any single line statement causing program failure can be calculated, i.e., how likely each line statement, once covered, will cause program failure. This probability assessment is essentially equivalent to the suspicious value of the statement containing the defect. Therefore, the prediction of the auxiliary coverage matrix by the model is taken as a suspicious value vector, and the defect degree of each row of sentences is reflected. Finally, the DLFL sorts all sentences according to the suspicious values, and a sentence list to be debugged, which is sorted according to the priority, is generated.
The metamorphic test (Metamorphic Testing, MT for short) is a practical solution to the problem of missing predictions for tests in the software testing field. How to apply MT to determine if the function of the program is functioning properly under a specific input in the event of a test prediction loss.
First, a program and a test case are given. The goal is to check the functional implementation of the program to determine if it is at least able to function properly for a given single test case. In the metamorphic test, it is first necessary to identify at least one MR, an attribute of the program, a necessary basis for functional integrity. In the MT process, several test cases associated with each other may be required, each of which plays a different role in the MR. Some of them are source test cases, which are provided by the original test case set; the remainder is the subsequent (follow-up) test cases, which are generated during the MT process. Taking a given single test case as a source test case, a subsequent test case can be generated according to the association between different roles defined in the MR. If the input and output of these test cases reveal a violation of the MR, then a conclusion can be drawn that the program failed, otherwise the program passed. Because the source test case and the subsequent test case always exist and are used in one entity, they are collectively referred to as a metamorphic test group (Metamorphic Testing Group, abbreviated as MTG). Supplementary explanation is a bit: one MTG may have multiple source test cases inside it, as long as MR needs.
A self-supervision deep learning type defect positioning method based on metamorphic test comprises the following steps:
s101: constructing an metamorphic relation MR of the target program P according to priori knowledge; the metamorphic relationship MR described herein is constructed by those skilled in the art from a priori knowledge of the target procedure, and is accomplished without the need for inventive effort, and for ease of understanding, several rules are presented herein that will be followed by those skilled in the art in constructing MR:
the metamorphic relationship MR described herein is constructed by those skilled in the art from a priori knowledge of the target procedure and is often only subject to specific analysis. In general, in order to be able to construct an actually effective MR, the following principles need to be followed:
a) Correctness. The MR must reflect the correct behavior of the program function, in other words, if the program function is implemented correctly, it must exhibit the properties that are prescribed in the MR.
b) And subsequent test cases are easy to generate. The metamorphic test technology is introduced to solve the problem of missing test predictions at low cost, and if the complexity of the process of generating the subsequent test cases based on MR is too high, even if the problem can be solved finally, the goal of low cost cannot be achieved, and even the problem cannot be solved.
c) MR with multiple variable elements or complex expression is preferentially selected. In general, the more complex the MR's manifestation, the more stringent it's specifications for the functional behavior of the program, and thus the higher the error detection capability, the more likely it is to expose the defects of the program.
d) Preference is given to MR which can produce the only subsequent test case. This criterion requires that no random variables exist in the MR so that once the source test case is determined, the subsequent test case can be uniquely determined. The role of this criterion is to simplify the process of subsequent MR verification, which is advantageous for automation.
MR with a wide application range is preferentially selected. Source test cases acceptable for different MRs are different. If a MR can only generate subsequent test cases in a few source test case configurations, then the data that can be generated by it is very small and therefore of low practical value.
S102: firstly, a test case set t is obtained, wherein each test case is an input acceptable by a target program P, a storage form is a text file, and data with generalization can be analyzed from the text file when MR related operation is carried out [ the process belongs to the prior art, and the description is omitted here. Then, according to the MR requirement, all the common M' group source test cases S= { S are selected from the test case set t 1 ,s 2 ,…,s M′ (s is therein i ={s i1 ,s i2 … } represents the i-th set of source test cases, s ij Representation s i The j-th test case in the list is used for each source test case group s i Generating a corresponding subsequent test case group f for MR i ={f i1 ,f i2 …, where a set of corresponding source test cases and subsequent test cases are considered as the smallest test unit, i.e., an metamorphic test group MTG, the test case contained in the ith MTG is s i ∪f i
Here, each source test case set S is illustrated in S102 i Generating a corresponding subsequent test case group f for MR i ={f i1 ,f i2 … the procedure is as follows:
taking the max defect program for maximum value as an example, let MR be expressed as max (a, b) +max (c, d)>-max (-b, -a) -max (-d, -c) and where a noteqb, where the terms to the left of the equation constitute the set of source test cases { (a, b), (c, d) }, the terms to the right of the equation constitute { (-b, -a), (-d, -c) } of the set of subsequent test cases, the MR requirement for the source test cases is a noteqb. A source test case group s meeting the requirements is selected i = { (2, 5), (3, 7) }, to obtain the corresponding subsequent test case group, s needs to be first i Substituting the MR expression to obtain max (2, 5) +max (3, 7)>-max(-b,-a)-max(-d, -c). Then, a=2, b=5, c=3, d=7 can be obtained according to the mapping relation between each variable and the source test case in the formula. Substituting the values of these variables into the equation, max (2, 5) +max (3, 7)>-max (-5, -2) -max (-7, -3), the subsequent test case group f contained on the right side of the equation can be obtained i ={(-5,-2),(-7,-3)}。
S103: all test cases in each MTG are input into the target program P one by one for execution, and execution output of each source test case and subsequent test cases in each MTG is collected
Figure BDA0003183013950000071
Sentence coverage matrix during execution>
Figure BDA0003183013950000072
Figure BDA0003183013950000073
Indicating the coverage obtained by executing the j-th source test case in the i-th set of source test case sets,/->
Figure BDA0003183013950000074
Representing a coverage vector obtained by executing a j-th test case in the i-th subsequent test case group; if it is to->
Figure BDA0003183013950000075
Or->
Figure BDA0003183013950000076
Unified use->
Figure BDA0003183013950000077
Representing, then the element therein->
Figure BDA0003183013950000078
Indicating whether the kth sentence is covered in the execution of test case c, covering +.>
Figure BDA0003183013950000079
Taking 1, uncovered->
Figure BDA00031830139500000710
0, where k has a value in the range of [1, N]N is the total number of defective program code statements. []Called Ai Fosen brackets, which is essentially a function of the value range {0,1} and takes 1 if the condition in the brackets is satisfied and takes 0 if it is not satisfied).
Acquisition execution output o in the present invention i Sum sentence coverage matrix
Figure BDA00031830139500000712
The method of (1) is as follows: the method for collecting and executing output comprises two steps, wherein the first step is that the program output is redirected, the content of the program output to stdout is redirected to a file to obtain the original output, and the second step is that useful data in the original output is tidied. The method of collecting the coverage matrix of sentences consists of two steps as well, the first step is to collect the original coverage information of the program running by using a coverage tool such as Emma, GCOV, jaCoCo, and the second step is to sort out the useful data in the original coverage information, and the sentences get the coverage matrix.
Here, by way of example, test case set S in S102 i ∪f i And corresponding execution output o i The procedure for examination using MR as a parameter was as follows: continuing the example above based on the defect program max, existing s i ={(2,5),(3,7)},f i = { (-5, -2), (-7, -3) }, discussed below in two cases, showing two results possible with MR examination.
a)
Figure BDA00031830139500000711
O is set to i Substituting MR expression max (a, b) +max (c, d)>-max (-b, -a) -max (-d, -c), yielding 5+7>- (-2) - (-3), further simplifying the obtainable 12>5, the true proposition, states that the original expression is at o i Is established, and it is concluded that the MTG of group i does not violate MR.
b)
Figure BDA0003183013950000081
O is set to i Substituting MR expression max (a, b) +max (c, d)>-max (-b, -a) -max (-d, -c), yielding 5+3>- (-5) - (-7), further simplifying the availability of 8>12, a false proposition, explaining that the original expression is at o i Is not true, and it is concluded that the MTG of group i violates MR.
S104: for each MTG, test case set s i ∪f i And corresponding execution output o i Using MR as a parameter to perform inspection to judge whether the MR is violated or not, and obtaining the test result of the MTG
Figure BDA0003183013950000082
Finally, a violation vector consisting of M' line test results is obtained>
Figure BDA0003183013950000083
Here m= { m 1 ,m 2 ,…,m M′ And represents all M' MTGs, M i Represents the ith MTG.
S105: coverage matrix for each MTG
Figure BDA0003183013950000084
Conversion to obtain and violate vector y (m) Aligned coverage matrix X (m)
The following formula is specifically used:
Figure BDA0003183013950000085
Figure BDA0003183013950000086
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA0003183013950000087
indicating whether the kth sentence is covered in the execution of the test case c (see definition in S103); will s i ∪f i The coverage condition of each test case in the kth sentence is logically or operated to obtain the total coverage condition of the ith MTG in the sentence +.>
Figure BDA0003183013950000088
The coverage of all N sentences constitutes the coverage vector +.>
Figure BDA0003183013950000089
Finally, all M 'coverage vectors form a coverage matrix X of M' ×N (m)
S106: coverage matrix X obtained using S105 (m) And S104, the violation vector y (m) Respectively training a DLFL model as a sample and a label to obtain a trained model F;
s107: for the target program P, constructing the following N X N identity matrix X as an auxiliary coverage matrix
Figure BDA00031830139500000810
Wherein each row represents the coverage of one virtual test case on N sentences, and i virtual test cases only cover the ith sentence. So configured, the next step is to independently evaluate the relative magnitude of each row of statements responsible for violating MR by means of the matrix exploiting the non-linear relationship learned by model F.
S108: inputting the auxiliary coverage matrix X into a model F to obtain suspicious value vectors
Figure BDA0003183013950000091
The suspicious value of each line of the N lines of code containing the defective program P is +.>
Figure BDA0003183013950000092
Example 1: assuming that the program under test is sqrt (x), its function is to output its square root for arbitrary input x, furthermore assume a given measurementThe test case is x=2. In this simple scenario, the test language deficiency problem is apparent, because, on the one hand
Figure BDA0003183013950000093
The exact value of (a) is difficult to obtain by manual calculation, on the other hand, the existing calculator cannot be relied on, and after all, the exact function of the prescription provided by the calculator cannot be confirmed. Therefore, it is necessary to resort to metamorphic testing. It can be seen that the mathematical properties of many square roots include this term, namely +.>
Figure BDA0003183013950000094
It is now used as a strip MR. Then, according to the MR requirement, in addition to the source test case of x=2, a random number y needs to be generated as one subsequent test case, say y=7, and then another subsequent test case is defined, where z=x·y=14. It is then now possible to determine whether the implementation of the target program is correct by simply comparing the product of sqrt (2) and sqrt (7) with the sqrt (14). If the two are not equal, the program fails, otherwise, the program passes.
Input: the defective program P consisting of n=12 lines of codes is as follows, and the function of the program is to output the maximum value of two real numbers. Wherein line 5 is the actual location of the defect;
Figure BDA0003183013950000095
test case set t= { t composed of m=2 test cases 1 ,t 2 Use case inputs and expected outputs are shown in the following table.
Numbering device Input device Expected output
t
1 2 2 2
t 2 3 1 3
And (3) outputting: suspicious values for each of N lines of code of defect program P
Figure BDA0003183013950000101
S101: from the domain knowledge related to the procedure, MR is constructed: the two numbers input are exchanged for the position, the maximum value is unchanged. The functional interface of the original program is denoted as max (x, y) →z, i.e. two real numbers x and y are input, and the calling program max (x, y) gets the maximum value z of the two. Then MR may be expressed as max (x, y) =max (y, x).
S102: according to MR requirement, all M' =2 groups of source test cases S= { S are selected from the original test case set t 1 ,s 2 (s is therein 1 ={s 11 },s 11 =(2,2),s 2 ={s 21 },s 21 = (3, 1). And use each source test case set s i Generating corresponding subsequent test case groups for MR to obtain f 1 ={(2,2)},f 2 = { (1, 3) }. A set of related source test cases and subsequent test cases are considered as the smallest test unit, namely, an metamorphic test group (MTG for short), the test cases contained in the 1 st MTG are { (2, 2), (2, 2) }, and the test cases contained in the 2 nd MTG are { (3, 1), (1, 3) }.
S103: all test cases are input into P one by one for execution, and the execution output and execution process of each source test case and subsequent test case in each MTG are collectedThe sentence coverage matrix in (a) is respectively obtained
Figure BDA0003183013950000102
Figure BDA0003183013950000103
And->
Figure BDA0003183013950000104
The detailed values are as follows.
o 1 ={2,2}
o 2 ={1,3}
Figure BDA0003183013950000105
Figure BDA0003183013950000106
S104: for each MTG, test case set s i ∪f i And corresponding test output o i Using MR as a parameter to perform inspection to judge whether the MR is violated or not, and obtaining the test result of the MTG
Figure BDA0003183013950000107
Finally get violation vector->
Figure BDA0003183013950000108
Specific deduction procedures and results are as follows.
Figure BDA0003183013950000109
Figure BDA0003183013950000111
S105: for each MTG, according to the existing coverage matrix
Figure BDA0003183013950000112
The following conversion is performed
Figure BDA0003183013950000113
The final result is the violation vector y (m) Aligned coverage matrix
Figure BDA0003183013950000114
The detailed values are as follows.
Figure BDA0003183013950000115
S106: learning the following model using deep neural networks
F:X (m) →y (m)
And obtaining a trained model F.
In this example, a multiple regression linear model y=f (X) =x·w without bias was used, and model weights were learned as follows.
w=[0 0 0 0 1 0 0 0 0 0 0 0] T
S107: constructing an auxiliary coverage matrix as a test set as follows
Figure BDA0003183013950000116
S108: the auxiliary coverage matrix X is input into a model F to obtain suspicious value vectors
Figure BDA0003183013950000117
The suspicious value of each of the N lines of code containing defective program P, i.e +.>
Figure BDA0003183013950000118
Specific deduction procedures and results are as follows.
Figure BDA0003183013950000119
It can be seen that the suspicious value corresponding to the line 5 code is 1, the rest codes are 0, and in fact, the line 5 code is just the defect, so the defect positioning is successful.
Finally, it is noted that the above embodiments are only for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made thereto without departing from the spirit and scope of the technical solution of the present invention, which is intended to be covered by the scope of the claims of the present invention.

Claims (2)

1. The self-supervision deep learning type defect positioning method based on metamorphic test is characterized by comprising the following steps of: the method comprises the following steps:
s101: constructing an metamorphic relation MR of the target program P according to priori knowledge;
s102: acquiring a test case set t, and picking all common M' group source test cases S= { S from the test case set t according to the MR requirement 1 ,s 2 ,…,s M′ (s is therein i ={s i1 ,s i2 … } represents the i-th set of source test cases, s ij Representation s i The j-th test case in the list is used for each source test case group s i Generating a corresponding subsequent test case group f for MR i ={f i1 ,f i2 …, where a set of corresponding source test cases and subsequent test cases are considered as the smallest test unit, i.e., an metamorphic test group MTG, the test case contained in the ith MTG is s i ∪f i
S103: all test cases in each MTG are input into the target program P one by one for execution, and execution output of each source test case and subsequent test cases in each MTG is collected
Figure FDA0004254925740000011
Sentence coverage matrix during execution>
Figure FDA0004254925740000012
Figure FDA0004254925740000013
Figure FDA0004254925740000014
Representing an overlay vector obtained by executing a j-th source test case in the i-th set of source test case sets,/->
Figure FDA0004254925740000015
Representing a coverage vector obtained by executing a j-th test case in the i-th subsequent test case group; if it is to->
Figure FDA0004254925740000016
Or->
Figure FDA0004254925740000017
Unified use->
Figure FDA0004254925740000018
Representing, then the element therein->
Figure FDA0004254925740000019
Indicating whether the kth sentence is covered in the execution of test case c, covering +.>
Figure FDA00042549257400000110
Taking 1, uncovered->
Figure FDA00042549257400000111
0, where k has a value in the range of [1, N]N is the total number of defective program code statements;
s104: for each ofMTG, test case group s i ∪f i And corresponding execution output o i Using MR as a parameter to perform inspection to judge whether the MR is violated or not, and obtaining the test result of the MTG
Figure FDA00042549257400000112
Figure FDA00042549257400000113
Finally, a violation vector consisting of M' line test results is obtained>
Figure FDA00042549257400000114
Figure FDA00042549257400000115
Here m= { m 1 ,m 2 ,…,m M′ And represents all M' MTGs, M i Represents the ith MTG;
s105: coverage matrix for each MTG
Figure FDA00042549257400000116
Conversion to obtain and violate vector y (m) Aligned coverage matrix X (m)
S106: coverage matrix X obtained using S105 (m) And S104, the violation vector y (m) Respectively training unbiased multiple regression linear models as a sample and a label to obtain a trained model F;
s107: for the target program P, the following n×n identity matrix X is constructed as an auxiliary coverage matrix:
Figure FDA0004254925740000021
each row represents the coverage condition of one virtual test case on N sentences, and i virtual test cases only cover the ith sentence;
s108: the auxiliary coverage matrix is formedObtaining suspicious value vector by X input model F
Figure FDA0004254925740000022
The suspicious value of each line of the N lines of code containing the defective program P is +.>
Figure FDA0004254925740000023
2. The self-supervised deep learning defect localization method based on metamorphic testing of claim 1, wherein: the coverage matrix of each MTG is used in the S105
Figure FDA0004254925740000024
Conversion to obtain and violate vector y (m) Aligned coverage matrix X (m) The following formula is used:
Figure FDA0004254925740000025
Figure FDA0004254925740000026
wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure FDA0004254925740000027
indicating whether the kth sentence is covered in the execution of the test case c; will s i ∪f i The coverage condition of each test case in the kth sentence is logically or operated to obtain the total coverage condition of the ith MTG in the sentence +.>
Figure FDA0004254925740000028
The coverage of all N sentences constitutes the coverage vector +.>
Figure FDA0004254925740000029
Finally, all M 'coverage vectors form a coverage matrix X of M' ×N (m)
CN202110852911.7A 2021-07-27 2021-07-27 Self-supervision deep learning type defect positioning method based on metamorphic test Active CN113568831B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110852911.7A CN113568831B (en) 2021-07-27 2021-07-27 Self-supervision deep learning type defect positioning method based on metamorphic test

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110852911.7A CN113568831B (en) 2021-07-27 2021-07-27 Self-supervision deep learning type defect positioning method based on metamorphic test

Publications (2)

Publication Number Publication Date
CN113568831A CN113568831A (en) 2021-10-29
CN113568831B true CN113568831B (en) 2023-07-04

Family

ID=78168117

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110852911.7A Active CN113568831B (en) 2021-07-27 2021-07-27 Self-supervision deep learning type defect positioning method based on metamorphic test

Country Status (1)

Country Link
CN (1) CN113568831B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572462A (en) * 2014-12-31 2015-04-29 中国人民解放军理工大学 Method for generating metamorphic test case based on adaptive random strategy
CN104598381A (en) * 2015-01-26 2015-05-06 中国人民解放军理工大学 Positioning method for failure test instance in metamorphic testing
CN104750608A (en) * 2015-03-25 2015-07-01 南京大学 Automatic error locating method based on dynamic symbol operation in procedure
CN112199295A (en) * 2020-10-29 2021-01-08 北京信息科技大学 Deep neural network defect positioning method and system based on frequency spectrum

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10642723B1 (en) * 2019-02-05 2020-05-05 Bank Of America Corporation System for metamorphic relationship based code testing using mutant generators

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572462A (en) * 2014-12-31 2015-04-29 中国人民解放军理工大学 Method for generating metamorphic test case based on adaptive random strategy
CN104598381A (en) * 2015-01-26 2015-05-06 中国人民解放军理工大学 Positioning method for failure test instance in metamorphic testing
CN104750608A (en) * 2015-03-25 2015-07-01 南京大学 Automatic error locating method based on dynamic symbol operation in procedure
CN112199295A (en) * 2020-10-29 2021-01-08 北京信息科技大学 Deep neural network defect positioning method and system based on frequency spectrum

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Adaptive metamorphic testing with contextual bandits";Helge Spieker 等;《Journal of Systems and Software》;第165卷;第1-8页 *
"增强上下文的错误定位技术";张卓 等;《软件学报》;第266-281页 *
"蜕变测试在机器学习领域的应用";潘娅 等;《西安邮电大学学报》;第81-89页 *

Also Published As

Publication number Publication date
CN113568831A (en) 2021-10-29

Similar Documents

Publication Publication Date Title
CN111259394B (en) Fine-grained source code vulnerability detection method based on graph neural network
Balci Guidelines for successful simulation studies
US20210287109A1 (en) Analyzing test result failures using artificial intelligence models
CN106201871A (en) Based on the Software Defects Predict Methods that cost-sensitive is semi-supervised
Yang et al. Revisiting neuron coverage metrics and quality of deep neural networks
US20220300820A1 (en) Ann-based program testing method, testing system and application
Kadry A new proposed technique to improve software regression testing cost
Wong et al. Using an RBF neural network to locate program bugs
CN111240975A (en) Artificial intelligence system risk detection method, device, computer equipment and medium
Yang et al. A lightweight fault localization approach based on xgboost
CN113568831B (en) Self-supervision deep learning type defect positioning method based on metamorphic test
Kaur et al. A clustering algorithm for software fault prediction
CN111581086A (en) Hybrid software error positioning method and system based on RankNet
Mulla et al. Role of Machine Learning & Artificial Intelligence Techniques in Software Testing
Mohamad Machine learning empowered software prediction system
Aho et al. IVVES (Industrial-Grade Verification and Validation of Evolving Systems).
Kundu et al. Selection and classification of common factors affecting the maintainability on the basis of common criteria
CN111737131B (en) Code error positioning method based on probability alignment
Choi et al. Just-in-Time Defect Prediction for Self-Driving Software via a Deep Learning Model
Sirshar et al. A Framework for Software Defect Management Process in Software Quality Assurance
CN113434408B (en) Unit test case sequencing method based on test prediction
Kasai et al. Fault-prone module prediction using a prediction model and manual inspection
Odeh Software Source Code: Theoretical Analyzing and Practical Reviewing Model
Goel et al. Investigating of high and low impact faults in object-oriented projects
Du et al. A Novel Graph Neural Network-Based Automated Fault Localization Technique for Novice Programs

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