An automated functional defect location method for software product lines

Through an automated functional defect location method that combines spectrum error location and uncertainty reasoning algorithms, the accuracy and efficiency issues of functional error location in software product lines are solved, fast and accurate defect location is achieved, and labor costs are reduced.

CN118503135BActive Publication Date: 2024-10-29SOUTH CHINA UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410931424.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-10-29
Estimated Expiration
2044-07-12

AI Technical Summary

Technical Problem

Existing technologies have shortcomings in locating functional errors in software product lines. In particular, spectrum-based fault location methods cannot accurately identify bugs that only appear under specific feature combinations, resulting in reduced location accuracy, and when all potential features are considered Maintenance process is inefficient.

Method used

The automated functional defect location method is used, combined with spectrum error location technology and uncertainty reasoning algorithm, to achieve more accurate and efficient location of software product line defects by calculating suspicious values ​​of code blocks and information theory technology.

Benefits of technology

It achieves fast and accurate positioning of software product line defects, reduces the positioning complexity under the influence of feature interaction, saves the time consumption of feature layer misalignment positioning, and improves positioning accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503135B_ABST
    Figure CN118503135B_ABST
Patent Text Reader

Abstract

The present invention discloses an automated functional defect location method for a software product line, and relates to the technical field of software debugging and analysis. The present invention combines and applies SBFL technology, machine learning algorithms, data mining technology, information theory technology, etc., and uses the detection granularity of code blocks to perform probability distribution from three perspectives: prediction, actual operation, and correlation. In combination with an uncertain reasoning algorithm, the suspicious value of the code block is calculated, and suspicious statements are quickly screened. On this basis, a more accurate evaluation of suspicious statements is achieved from three granularities: global, local, and code blocks, and finally more efficient and accurate error location is achieved. Among them, the code block directly corresponds to the internal feature interaction, which greatly improves the efficiency of the feature interaction search. For program statements that are more likely to cause software errors, no manual interaction is required to quickly find and locate them, and complete the maintenance of the software product line system, effectively reducing the labor cost of maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software debugging and analysis, and in particular to an automatic functional defect locating method for a software product line. Background Art

[0002] A software product line is a collection of software-intensive systems with a set of manageable common features that meet specific market or mission requirements and are developed from a common set of core assets in a predefined manner. Compared with traditional independent development, zero-based development, or random development models, the software product line approach can significantly improve production efficiency and economic benefits. Therefore, the software product line is a development technology that can achieve efficient development and personalized customization of software. Many large software, such as Linux and SQLite3, are developed based on software product line technology.

[0003] Different functions of a software product line can be abstracted into different features. Users can generate software products that meet their needs by turning on or off the corresponding features. Although software product lines can effectively improve the efficiency of software development, their maintenance difficulty is higher and more complex than conventional development models. The main reason is that bugs in software product lines are variable, that is, incorrect statements will not cause all products to fail, and bugs will only appear when some features interact. Software failures may cause major problems in software development, resulting in errors, crashes, and data loss. In order to ensure the reliability of software, it is necessary to locate these variable bugs. However, as the scale of software grows, the potential feature interactions grow exponentially, and the difficulty of locating the corresponding bugs also rises sharply. How to efficiently and automatically achieve defect location in software product lines is of great significance.

[0004] The existing technology for defect location in software product lines has the following deficiencies:

[0005] (1) Compared with the non-functional error location of software product lines, the functional error location technology for software product lines is relatively scarce.

[0006] (2) Common single-system software fault localization techniques ignore the impact of feature interactions, such as spectrum-based fault localization. Spectrum-based fault localization (SBFL) is a widely used fault localization method in software systems. SBFL works by collecting program spectra, which is a set of program entities and the number of times they are executed during program execution. SBFL locates the defect location in the software by collecting program coverage information and execution results.

[0007] Since SBFL identifies defects based on general program execution patterns without considering the specific situations of feature interactions in software product lines, it may not be able to accurately identify bugs that only appear under specific feature combinations, resulting in reduced accuracy of defect identification. SBFL has poor performance when directly applied to defect location in software product lines.

[0008] (3) When locating feature interactions that contain erroneous sentences, if all potential features are fully considered, the maintenance process will be too inefficient.

[0009] Therefore, there is an urgent need to provide an automated functional defect location method for a software product line to solve the above technical problems. Summary of the invention

[0010] In view of the problems existing in the prior art, the present invention provides an automated functional defect location method for a software product line, which is based on spectrum error location technology and combines uncertainty reasoning algorithms and information theory technology to achieve more accurate and efficient location of defects and loopholes in software product lines.

[0011] The technical solution of the present invention is achieved in this way:

[0012] The present invention provides an automated functional defect location method for a software product line, which is applied to software that has not passed the test, wherein the software includes a feature library and at least several products, the feature library includes several features, the products include several functions, and several of the features are applied in the functions; after the product is tested using a test case, test data is generated; the test data includes a program spectrum file; the test case includes a passed case and a failed case; the program spectrum file records the execution of each statement in the program, including whether it is executed, and the number of executions, etc. The method includes the following steps:

[0013] T1. Analyze the internal feature structure of all functions, and represent the internal code of the function with code blocks; construct a code block space, and store the code blocks in the code block space;

[0014] Software product line is a development technology that abstracts part of the functions of a software system into features. Users can select the features (functions) they want to generate the product (a software system) they want.

[0015] Multiple products in the same software product line share a feature set.

[0016] Different features may control the implementation of different situations in the same function. A function consists of one feature or multiple features, that is, multiple features (functions) work together to achieve a process / goal.

[0017] T2. Calculate the suspicious value of the code block, including the prediction suspicious value, the operation suspicious value and the correlation suspicious value;

[0018] The predicted suspicious value is to calculate the probability of the code block causing the corresponding product to fail, that is, to calculate the posterior probability of the code block and to perform probability distribution on the posterior probability; the calculation of the posterior probability is:

[0019]

[0020] Wherein, b represents a code block; N(b) represents the number of times b is called and executed in all product tests; N(b, failed) represents the number of times b is called and executed in products that failed the test; p(failed|b) represents the probability that b causes a product to fail the test; p(b) represents the probability that b is called and executed in all product tests; p(failed) represents the probability of occurrence of products that failed the test in all products; p(b|failed) is the posterior probability;

[0021] The suspicious running value is to calculate the probability of the code block being called in the product, that is, to count the number of all the code blocks that are called and executed, which is m; then in the test, the suspicious running value of the code block that is called and executed is 1 / m; the suspicious running value of the code block that is not called and executed is 0;

[0022] The correlation suspicious value is to calculate the influence factor between the code block and the test result of the product, that is: construct a relationship pair between the selection vector and the test result vector of each code block, calculate the correlation value between each code block and the test result based on the relationship pair, and perform a general distribution on the correlation value; the components of the selection vector represent the selection status of each product for the same code block; wherein 0 represents that the product does not select the current code block, and 1 represents that the product selects the current code block; the components of the test result vector represent the pass status of each product in the test; wherein 0 represents that the product passes the current test, and 1 represents that the product fails the current test; the selection vector and the test result vector are represented by Vb and R respectively; then the calculation of the correlation value is:

[0023]

[0024] Among them, H(Vb) represents the entropy of Vb; H(R) represents the entropy of R; H(Vb|R) represents the entropy of Vb when R is known; the test results include pass and fail; the prediction suspicious value, operation suspicious value and correlation suspicious value are all decimal values ​​between [0,1].

[0025] Entropy is information entropy. In information theory, information entropy is a measure of the uncertainty or disorder of information. The information entropy of a vector can be defined as the sum of the information entropies of each component in the vector.

[0026] The calculations of H(Vb), H(R) and H(Vb|R) are:

[0027]

[0028] Where v represents the component of Vb, r represents the component of R; p(·) represents the probability of taking a certain component in the vector; p(v|r) represents the probability of taking v when r is known;

[0029] In this scheme, the Softmax function is used to assign probabilities to the selected vectors; a vector or a set of real numbers is converted into a probability distribution so that the value of each element is between 0 and 1, and the sum of all elements is 1; for a given vector Z = [z1, z2, ..., z n ],z i is the i-th component of vector Z; then the Softmax value of is:

[0030]

[0031] Among them, i is 1, 2,…, n.

[0032] In the calculation of the predicted suspicious value, the posterior probability of each code block is obtained to form a vector, which is calculated through the Softmax function to obtain the predicted suspicious value of each code block; in the calculation of the correlation suspicious value, the correlation suspicious value of each code block is also calculated based on the vector composed of the correlation values.

[0033] Collecting a number of the prediction suspicious values, the operation suspicious values ​​and the correlation suspicious values ​​respectively, to obtain three suspicious vectors, namely a first suspicious vector, a second suspicious vector and a third suspicious vector;

[0034] T3. Calculate a unique suspicious vector based on the three suspicious vectors; each bit parameter of the unique suspicious vector is a unique suspicious value; one code block corresponds to one unique suspicious value; calculate the conflict factor between the first suspicious vector and the second suspicious vector;

[0035] Wherein, the first suspicious vector is represented as The second suspicious vector is expressed as p represents a suspicious value, e represents the number of suspicious values ​​in the suspicious vector, i∈[1,e], j∈[1,e];

[0036] Then the calculation method of the conflict factor cf is:

[0037]

[0038] If the conflict factor is greater than a preset first threshold, the first suspicious vector and the third suspicious vector are merged by using an uncertain reasoning algorithm to obtain the unique suspicious vector; otherwise, the first suspicious vector and the second suspicious vector are normalized by using an uncertain reasoning algorithm to obtain the unique suspicious vector;

[0039] The uncertain reasoning algorithm adopts the DS fusion algorithm. The uncertain reasoning algorithm is a logical and mathematical method for processing uncertain information. Common uncertain reasoning algorithms include Bayesian reasoning, evidence theory (Dempster-Shafer theory), decision trees, etc. Using the uncertain reasoning algorithm, it is possible to integrate information from multiple data sources or parameters to provide a more comprehensive and accurate evaluation of the target. The calculation process is:

[0040] Assume E x1 represents the first suspicious vector, E y1 represents the second suspicious vector or the third suspicious vector; E x1 and E y1 Calculate the fusion to get the new vector E new1 ;

[0041] but

[0042] in, Represents the vector E x1 The i-th component in Represents the vector E y1 The i-th component in Represents the vector E new1 The i-th component in ;

[0043] T4, filtering the code blocks, wherein the only suspicious value of the filtered code blocks is less than the preset target value, and the remaining code blocks are suspicious code blocks; locating the executed program statements in the suspicious code blocks through the program spectrum file as suspicious statements; further including the location information of the suspicious statements; saving the suspicious statements and their location information to obtain a suspicious statement set;

[0044] T5. Use SBFL technology to perform global evaluation, local evaluation and block evaluation on each suspicious statement in the suspicious statement set; SBFL technology is Spectrum-based Fault Localization, SBFL, that is, defect localization technology based on program spectrum.

[0045] The global evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by the global evaluation of the product to obtain a first evaluation value; a plurality of first evaluation values ​​form a first evaluation vector;

[0046] The local evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by the unit test of the product to obtain a second evaluation value; a plurality of second evaluation values ​​form a second evaluation vector;

[0047] The block evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by testing the code block to obtain a third evaluation value; a plurality of third evaluation values ​​are formed into a third evaluation vector;

[0048] T6, merging the first evaluation vector and the second evaluation vector into a fourth evaluation vector; calculating a final vector according to the third evaluation vector and the fourth evaluation vector, specifically: calculating the Manhattan distance between the third evaluation vector and the fourth evaluation vector, if the Manhattan distance is greater than a preset second threshold, the third evaluation vector is the final vector, otherwise, using an uncertain reasoning algorithm to fuse the third evaluation vector and the fourth evaluation vector to obtain the final vector;

[0049] The fusion process is:

[0050] Assume E x2 represents the third evaluation vector, E y2 represents the fourth evaluation vector; E x2 and E y2 Calculate the fusion to get the new vector E new2 ;

[0051] but

[0052] in, Represents the vector E x2 The i-th component in Represents the vector E y2 The i-th component in Represents the vector E new2 md represents the Manhattan distance between the third evaluation vector and the fourth evaluation vector;

[0053] Each value of the final vector is a final evaluation value, and each final evaluation value corresponds to a suspicious statement;

[0054] T7. Sort the suspicious statements according to the final evaluation value, and select the top K suspicious statements for output; wherein K is a preset positive integer value.

[0055] Suspicious value refers to the quantitative representation of the possibility that a code block or program statement will cause a software product to fail the test. This solution uses the detection strength of code blocks, combined with the calculation of three suspicious values ​​and an uncertain reasoning algorithm, to achieve rapid error location without considering the complete and potential feature interaction space. It locates from the internal feature interaction, saving a lot of time for misaligned location of the feature layer. At the same time, the present invention performs automatic error location based on the test results, while considering the suspicious evaluation values ​​of each suspicious statement at three granularities: global, local and code block, to obtain more accurate evaluation results, solving the technical problem of SBFL having the same suspicious value for program statements in the same path, while achieving the effects of efficient and high-precision positioning and effectively reducing labor costs.

[0056] As a further optimization of the above solution, in step T5, the calculation method of the first evaluation value / the second evaluation value is:

[0057]

[0058] Wherein, Suspiciousness(s) represents the first evaluation value / the second evaluation value; s represents the suspicious statement; Indicates the number of times the suspicious statement passes the test in the global evaluation / the local evaluation; Indicates the number of times the suspicious statement fails the test in the global evaluation or the local evaluation.

[0059] The suspicion of a statement is determined based on the number of times it is executed in passed and failed tests; when a suspicious statement is executed more times in failed tests and less times in passed tests, it means that the statement is more suspicious.

[0060] The first evaluation value / the second evaluation value may also be calculated by selecting any other SBFL calculation rule.

[0061] As a further optimization of the above solution, the calculation method of the third evaluation value is:

[0062] For a plurality of the suspicious statements in the same code block, the only suspicious value of the code block is the third evaluation value of the first suspicious statement;

[0063] Taking the third evaluation value of the first suspicious statement as a reference, a preset constant is added in sequence to obtain the third evaluation values ​​of other suspicious statements;

[0064] The preset constant is a positive number or a negative number.

[0065] As a further optimization of the above solution, the calculation method of the fourth evaluation vector is: y=aX+(1-a)Y;

[0066] Wherein, y represents the fourth evaluation vector; X represents the first evaluation vector, Y represents the second evaluation vector; and a is a pre-set decimal, representing a weight constant.

[0067] As a further optimization of the above solution, the positioning information is the row number of the corresponding feature of the suspicious sentence in the feature library.

[0068] Compared with the prior art, the present invention achieves the following beneficial effects:

[0069] The present invention provides an automated functional defect location method for a software product line. Through the detection granularity of code blocks, combined with the calculation of three suspicious values ​​and an uncertain reasoning algorithm, rapid error location is achieved, and there is no need to consider the complete and potential feature interaction space. Positioning is performed from the internal feature interaction, saving a lot of time consumption for misaligned positioning of feature layers. At the same time, the present invention performs automated error location based on test results, and considers the suspicious evaluation values ​​of each suspicious statement at three granularities of global, local and code blocks at the same time, so as to obtain more accurate evaluation results, solve the technical problem that SBFL program statements under the same path have the same suspicious value, and at the same time achieves the effects of efficient positioning and high-precision positioning, and effectively reduces labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 It is a flowchart of an automated functional defect location method for a software product line provided by an embodiment of the present invention;

[0071] Figure 2 is a schematic diagram of a process of calculating a unique suspicious vector provided by an embodiment of the present invention;

[0072] Figure 3 is a schematic diagram of a process for calculating a final vector provided by an embodiment of the present invention;

[0073] Figure 4 It is a schematic diagram of constructing a relationship pair provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solution and advantages of the present invention more clear, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0075] like Figures 1 to 4 As shown, this embodiment provides an automated functional defect location method for a software product line, which is applied to software that has not passed the test, wherein the software includes a feature library and at least several products, the feature library includes several features, the product includes several functions, and several features are applied in the function;

[0076] After testing the product using the test case, test data is generated; the test data includes a program spectrum file; the test case includes a passed test case and a failed test case; the program spectrum file records the execution of each statement in the program, including whether it is executed and the number of executions, etc. The method includes the following steps:

[0077] T1. Analyze the internal features of all functions and use code blocks to represent the internal code of the function; build a code block space and store the code blocks in the code block space; the code block space records the code blocks in the form of a hash table;

[0078] Software product line is a development technology that abstracts part of the functions of a software system into features. Users can select the features (functions) they want to generate the product (a software system) they want.

[0079] Multiple products in the same software product line share a feature set.

[0080] Different features may control the implementation of different situations in the same function. A function consists of one feature or multiple features, that is, multiple features (functions) work together to achieve a process / goal.

[0081] T2, calculate the suspicious values ​​of the code block, including prediction suspicious values, operation suspicious values ​​and correlation suspicious values;

[0082] Predicting suspicious values ​​means calculating the probability of a code block causing the corresponding product to fail;

[0083] In this embodiment, the calculation of the predicted suspicious value is to calculate the posterior probability of the code block and perform probability distribution on the posterior probability; the calculation of the posterior probability is:

[0084]

[0085] Where N(·) represents the number of times the event occurs; b represents a code block; N(b) represents the number of times b is called and executed in all product tests; N(b, failed) represents the number of times b is called and executed in products that fail the test; p(failed|b) represents the probability that b causes a product to fail the test; p(b) represents the probability that b is called and executed in all product tests; p(failed) represents the probability of a product that fails the test in all products; p(b|failed) is the posterior probability;

[0086] The operation suspicious value is to calculate the probability of a code block being called in the product; the calculation of the operation suspicious value is: count the number of all code blocks that are called and executed, which is m; then in the test, the operation suspicious value of the code block that is called and executed is 1 / m; the operation suspicious value of the code block that is not called and executed is 0.

[0087] When running suspicious value calculations, you can select existing program analysis tools, such as Javalang, to analyze and record the functions executed by unit tests. First, for each unit test that failed, obtain its Abstract Syntax Code (AST). Based on the AST, all executed functions can be analyzed, including constructors, ordinary functions of product lines, and functions in try blocks. It should be noted that non-product line functions are not recorded, such as functions in the test framework such as "asserTrue", "asserFalse", and "asserEquals". In addition, repeated functions only need to be recorded once. Then, the corresponding code block is obtained according to the hash table obtained in T1. Since the constructor is frequently executed, the probability of all executed functions is evenly distributed, that is, all executed code blocks have the same suspicious probability.

[0088] The correlation suspicious value is the impact factor between the calculated code block and the test result of the product; the test results include pass and fail; the prediction suspicious value, operation suspicious value and correlation suspicious value are all decimal values ​​between [0,1].

[0089] In this embodiment, the calculation of the correlation suspicious value is as follows: constructing a relationship pair between the selection vector and the test result vector of each code block, calculating the correlation value of each code block and the test result based on the relationship pair, and performing a general distribution on the correlation value; the components of the selection vector represent the selection status of each product for the same code block; wherein 0 represents that the product has not selected the current code block, and 1 represents that the product has selected the current code block; the components of the test result vector represent the pass status of each product in the test; wherein 0 represents that the product has passed the current test, and 1 represents that the product has not passed the current test;

[0090] The selection vector and the test result vector are denoted as Vb and R respectively;

[0091] For ease of understanding, Figure 4A simple example is given in , which contains m products and k code blocks, and R represents the test result vector of the product. Taking the b1 code block as an example, according to its selection in each product, its selection vector is [1,0,1,1]. Correspondingly, the R vector can be determined according to the test results of each product, that is, [1,0,0,1], where 1 means pass and 0 means fail. Therefore, a two-dimensional relationship pair can be obtained as [[1,0,1,1],[1,0,0,1]].

[0092] The calculation of the correlation value is:

[0093]

[0094] Among them, H(Vb) represents the entropy of Vb; H(R) represents the entropy of R; H(Vb|R) represents the entropy of Vb when R is known. The correlation method used here is the symmetric uncertainty method. SU(Vb, R) is the degree to which the code block Vb affects the test failure.

[0095] Entropy is information entropy. In information theory, information entropy is a measure of the uncertainty or disorder of information. The information entropy of a vector can be defined as the sum of the information entropies of each component in the vector.

[0096] The calculations of H(Vb), H(R) and H(Vb|R) are:

[0097]

[0098] Where v represents the component of Vb, r represents the component of R; p(·) represents the probability of taking a certain component in the vector; p(v|r) represents the probability of taking v when r is known;

[0099] In this scheme, the Softmax function is used to assign probabilities to the selected vectors; a vector or a set of real numbers is converted into a probability distribution so that the value of each element is between 0 and 1, and the sum of all elements is 1; for a given vector Z = [z1, z2, …, z n ],z i is the i-th component of vector Z; then the Softmax value of is:

[0100]

[0101] Among them, i is 1, 2,…, n.

[0102] In the calculation of the predicted suspicious value, the posterior probability of each code block is obtained to form a vector, which is calculated through the Softmax function to obtain the predicted suspicious value of each code block; in the calculation of the correlation suspicious value, the correlation suspicious value of each code block is also calculated based on the vector composed of the correlation values.

[0103] A plurality of prediction suspicious values, operation suspicious values ​​and correlation suspicious values ​​are collected respectively to obtain three suspicious vectors, namely, a first suspicious vector, a second suspicious vector and a third suspicious vector;

[0104] T3. Calculate a unique suspicious vector based on the three suspicious vectors; each bit parameter of the unique suspicious vector is a unique suspicious value; one code block corresponds to one unique suspicious value;

[0105] Specifically, the conflict factor of the first suspicious vector and the second suspicious vector is calculated; the conflict factor represents the credibility of the synthesis between the multi-source evidences, and its value is between 0 and 1. The closer to 1, the greater the conflict between the evidences.

[0106] Among them, let the first suspicious vector be expressed as The second suspicious vector is expressed as p represents a suspicious value, e represents the number of suspicious values ​​in the suspicious vector, i∈[1,e], j∈[1,e];

[0107] Then the calculation method of the conflict factor cf is:

[0108]

[0109] If the conflict factor is greater than a preset first threshold, such as greater than 0.95, it indicates that the first suspicious vector and the second suspicious vector conflict with each other; then the first suspicious vector and the third suspicious vector are merged by using an uncertain reasoning algorithm to obtain a unique suspicious vector;

[0110] Otherwise, the first suspicious vector and the second suspicious vector are normalized by using an uncertain reasoning algorithm to obtain a unique suspicious vector.

[0111] In this embodiment, the uncertain reasoning algorithm adopts the DS fusion algorithm; the calculation process is:

[0112] Assume E x1 represents the first suspicious vector, E y1 represents the second suspicious vector or the third suspicious vector; E x1 and E y1 Calculate the fusion to get the new vector E new1 ;

[0113] but

[0114] in, Represents the vector E x1 The i-th component in Represents the vector E y1 The i-th component in Represents the vector E new1 The i-th component in ;

[0115] Uncertain reasoning algorithms are logical and mathematical methods for processing uncertain information. Common uncertain reasoning algorithms include Bayesian reasoning, evidence theory (Dempster-Shafer theory), decision trees, etc. Using uncertain reasoning algorithms, it is possible to integrate information from multiple data sources or parameters to provide a more comprehensive and accurate evaluation of the target.

[0116] T4, filtering the code blocks, wherein the only suspicious value of the filtered code blocks is less than the preset target value, and the remaining code blocks are suspicious code blocks; locating the executed program statements in the suspicious code blocks through the program spectrum file as suspicious statements;

[0117] It also includes the location information of the suspicious statement; in this embodiment, the location information is the row number of the corresponding feature of the suspicious statement in the feature library;

[0118] Suspicious statements and their location information are saved to obtain a suspicious statement set.

[0119] Specifically, in step T41, if Python's xml.etree.ElementTree library is selected to analyze the program spectrum, ElementTree can abstract the program spectrum (saved in XML format) into an element tree. Get the element with tag "line" under the "project" node, which indicates the execution of the program statement. In order to obtain the executed statement in the suspicious block, the corresponding function can be found through the "signature" attribute. Since only specific lines in "line" have the "signature" attribute, a Boolean variable is set to determine whether it is the execution function of the suspicious function.

[0120] T42. Next, since there may be error counts in the program spectrum information, it is necessary to determine whether each statement has a "truecount" attribute. If there is a "truecount" attribute, it means that the statement is error counted. When a statement is error counted, determine whether the value of its "truecount" attribute is greater than 0. If there is no error count, determine whether the value of its "count" attribute is greater than 0. Statements that meet the above conditions will have their corresponding line numbers in the product recorded.

[0121] T43, map the suspicious statements in each product to the corresponding statements under the feature. It is also based on the program spectrum information, but the difference is that in this step, the program spectrum of the entire product is analyzed, while the program spectrum under the unit test is analyzed in T42. Use the ElementTree library to parse the program spectrum into an element tree, get the "line" node under the "project" node, and if it is a program statement obtained in T42, use "featureClass" and "featureLineNum" to get the features and corresponding line numbers of the statement, and save them in a dictionary in the format of (feature.number of lines).

[0122] T5. Use SBFL technology to perform global evaluation, local evaluation and block evaluation on each suspicious statement in the suspicious statement set; SBFL technology is Spectrum-based Fault Localization, SBFL, which is a defect localization technology based on program spectrum.

[0123] The global evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by the global evaluation of the product to obtain a first evaluation value; multiple first evaluation values ​​are formed into a first evaluation vector;

[0124] The local evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by the unit test of the product to obtain a second evaluation value; multiple second evaluation values ​​are formed into a second evaluation vector;

[0125] In this embodiment, the calculation method of the first evaluation value / the second evaluation value is:

[0126]

[0127] Wherein, Suspiciousness(s) represents the first evaluation value / second evaluation value; s represents a suspicious statement;

[0128] Indicates the number of times the suspicious statement passes the test in the global evaluation / local evaluation; Indicates the number of times a suspicious statement fails a test in global evaluation or local evaluation.

[0129] The suspicion of a statement is determined based on the number of times it is executed in passed and failed tests; when a suspicious statement is executed more times in failed tests and less times in passed tests, it means that the statement is more suspicious.

[0130] The block evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by testing the code block to obtain a third evaluation value; in this embodiment, the calculation method of the third evaluation value is:

[0131] For several suspicious statements in the same code block, the only suspicious value of the code block is the third evaluation value of the first suspicious statement;

[0132] Taking the third evaluation value of the first suspicious statement as a reference, a preset constant is added in sequence to obtain the third evaluation values ​​of other suspicious statements; the preset constant is a positive number or a negative number; and a plurality of third evaluation values ​​form a third evaluation vector.

[0133] That is, the suspicious value of the first suspicious statement in the code block is assigned to the suspicious value of the code block, and each subsequent suspicious statement calculates its suspicious value by decrementing or adding a very small constant.

[0134] T6. Combine the first evaluation vector and the second evaluation vector into a fourth evaluation vector. In this embodiment, the fourth evaluation vector is calculated as follows: y=aX+(1-a)Y;

[0135] Wherein, y represents the fourth evaluation vector; X represents the first evaluation vector, Y represents the second evaluation vector; and a is a pre-set decimal, representing a weight constant.

[0136] Calculate a final vector according to the third evaluation vector and the fourth evaluation vector; each value of the final vector is a final evaluation value, and each final evaluation value corresponds to a suspicious statement;

[0137] Specifically, the Manhattan distance between the third evaluation vector and the fourth evaluation vector is calculated first; the Manhattan distance between two vectors is calculated using the L1 norm, which is the sum of the absolute values ​​of the differences in each dimension.

[0138] If the Manhattan distance is greater than the preset second threshold, the third evaluation vector is the final vector;

[0139] Otherwise, the third evaluation vector and the fourth evaluation vector are fused to obtain the final vector using the uncertain reasoning algorithm. The uncertain reasoning algorithm here also uses the DS fusion algorithm, that is:

[0140] Assume E x2 represents the third evaluation vector, E y2 represents the fourth evaluation vector; E x2 and E y2 Calculate the fusion to get the new vector E new2 ;

[0141] but

[0142] in, Represents the vector E x2 The i-th component in Represents the vector E y2 The i-th component in Represents the vector Enew2 The i-th component in ; md represents the Manhattan distance between the third evaluation vector and the fourth evaluation vector.

[0143] T7. Sort the suspicious statements according to the final evaluation value, and select the top K suspicious statements for output; where K is a preset positive integer value.

[0144] Suspicious value refers to the quantitative representation of the possibility that a code block or program statement will cause a software product to fail the test. This solution uses the detection strength of code blocks, combined with the calculation of three suspicious values ​​and an uncertain reasoning algorithm, to achieve rapid error location without considering the complete and potential feature interaction space. It locates from the internal feature interaction, saving a lot of time for misaligned location of the feature layer. At the same time, the present invention performs automatic error location based on the test results, while considering the suspicious evaluation values ​​of each suspicious statement at three granularities: global, local and code block, to obtain more accurate evaluation results, solving the technical problem of SBFL having the same suspicious value for program statements in the same path, while achieving the effects of efficient and high-precision positioning and effectively reducing labor costs.

[0145] According to the disclosure and teaching of the above description, those skilled in the art to which the present invention belongs may also make changes and modifications to the above embodiments. Therefore, the present invention is not limited to the specific embodiments disclosed and described above, and some modifications and changes to the present invention should also fall within the scope of protection of the claims of the present invention. In addition, although some specific terms are used in this specification, these terms are only for the convenience of description and do not constitute any limitation to the present invention.

Claims

1. An automated functional defect location method for a software product line, applied to software that has not passed a test, wherein the software comprises a feature library and at least a plurality of products, wherein the feature library comprises a plurality of features, wherein the products comprise a plurality of functions, wherein the plurality of features are applied in the functions; after the products are tested using test cases, test data is generated; the test data comprises a program spectrum file; and the test cases comprise a passed test case and a failed test case; It is characterized in that The steps include: T1. Analyze the internal feature structure of all functions, and represent the internal code of the function with code blocks; construct a code block space, and store the code blocks in the code block space; T2. Calculate the suspicious value of the code block, including the prediction suspicious value, the operation suspicious value and the correlation suspicious value; The predicted suspicious value is to calculate the probability of the code block causing the corresponding product to fail, that is, to calculate the posterior probability of the code block and to perform probability distribution on the posterior probability; the calculation of the posterior probability is: Wherein, b represents a code block; N(b) represents the number of times b is called and executed in all product tests; N(b, failed) represents the number of times b is called and executed in products that failed the test; p(failed|b) represents the probability that b causes a product to fail the test; p(b) represents the probability that b is called and executed in all product tests; p(failed) represents the probability of occurrence of products that failed the test in all products; p(b|failed) is the posterior probability; The suspicious running value is to calculate the probability of the code block being called in the product, that is, to count the number of all the code blocks that are called and executed, which is m; then in the test, the suspicious running value of the code block that is called and executed is 1 / m; the suspicious running value of the code block that is not called and executed is 0; The correlation suspicious value is to calculate the influence factor between the code block and the test result of the product, that is: construct a relationship pair between the selection vector and the test result vector of each code block, calculate the correlation value between each code block and the test result based on the relationship pair, and perform a general distribution on the correlation value; the components of the selection vector represent the selection status of each product for the same code block; the components of the test result vector represent the passing status of each product in the test; the selection vector and the test result vector are represented as Vb and R respectively; then the calculation of the correlation value is: Wherein, H(Vb) represents the entropy of Vb; H(R) represents the entropy of R; H(Vb|R) represents the entropy of Vb when R is known; the test results include pass and fail; Collecting a number of the prediction suspicious values, the operation suspicious values ​​and the correlation suspicious values ​​respectively, to obtain three suspicious vectors, namely a first suspicious vector, a second suspicious vector and a third suspicious vector; T3. Calculate a unique suspicious vector based on the three suspicious vectors; each bit parameter of the unique suspicious vector is a unique suspicious value; one code block corresponds to one unique suspicious value; calculate the conflict factor between the first suspicious vector and the second suspicious vector; Wherein, the first suspicious vector is represented as The second suspicious vector is expressed as p represents a suspicious value, e represents the number of suspicious values ​​in the suspicious vector, i∈[1,e], j∈[1,e]; Then the calculation method of the conflict factor cf is: If the conflict factor is greater than a preset first threshold, the first suspicious vector and the third suspicious vector are merged by using an uncertain reasoning algorithm to obtain the unique suspicious vector; otherwise, the first suspicious vector and the second suspicious vector are normalized by using an uncertain reasoning algorithm to obtain the unique suspicious vector; The uncertain reasoning algorithm adopts the DS fusion algorithm, and the calculation process is: Assume E x1 represents the first suspicious vector, E y1 represents the second suspicious vector or the third suspicious vector; E x1 and E y1 Calculate the fusion to get the new vector E new1 ; but in, Represents the vector E x1 The i-th component in Represents the vector E y1 The i-th component in Represents the vector E new1 The i-th component in ; T4, filtering the code blocks, wherein the only suspicious value of the filtered code blocks is less than the preset target value, and the remaining code blocks are suspicious code blocks; locating the executed program statements in the suspicious code blocks through the program spectrum file as suspicious statements; further including the location information of the suspicious statements; saving the suspicious statements and their location information to obtain a suspicious statement set; T5, using SBFL technology to perform global evaluation, local evaluation and block evaluation on each suspicious statement in the suspicious statement set; The global evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by the global evaluation of the product to obtain a first evaluation value; a plurality of first evaluation values ​​form a first evaluation vector; The local evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by the unit test of the product to obtain a second evaluation value; a plurality of second evaluation values ​​form a second evaluation vector; The block evaluation is to calculate the suspicious value of the suspicious statement based on the test data obtained by testing the code block to obtain a third evaluation value; a plurality of third evaluation values ​​are formed into a third evaluation vector; T6, merging the first evaluation vector and the second evaluation vector into a fourth evaluation vector; calculating a final vector according to the third evaluation vector and the fourth evaluation vector, specifically: calculating the Manhattan distance between the third evaluation vector and the fourth evaluation vector, if the Manhattan distance is greater than a preset second threshold, the third evaluation vector is the final vector, otherwise, using an uncertain reasoning algorithm to fuse the third evaluation vector and the fourth evaluation vector to obtain the final vector; The fusion process is: Assume E x2 represents the third evaluation vector, E y2 represents the fourth evaluation vector; E x2 and E y2 Calculate the fusion to get the new vector E new2 ; but in, Represents the vector E x2 The i-th component in Represents the vector E y2 The i-th component in Represents the vector E new2 md represents the Manhattan distance between the third evaluation vector and the fourth evaluation vector; Each value of the final vector is a final evaluation value, and each final evaluation value corresponds to a suspicious statement; T7. Sort the suspicious statements according to the final evaluation value, and select the top K suspicious statements for output; wherein K is a preset positive integer value.

2. The method for locating functional defects in a software product line according to claim 1, It is characterized in that In step T5, the first evaluation value / the second evaluation value is calculated as follows: Wherein, Suspiciousness(s) represents the first evaluation value / the second evaluation value; s represents the suspicious statement; Indicates the number of times the suspicious statement passes the test in the global evaluation / the local evaluation; Indicates the number of times the suspicious statement fails the test in the global evaluation or the local evaluation.

3. The method for locating functional defects in a software product line according to claim 1, It is characterized in that The calculation method of the third evaluation value is: For a plurality of the suspicious statements in the same code block, the only suspicious value of the code block is the third evaluation value of the first suspicious statement; Taking the third evaluation value of the first suspicious statement as a reference, a preset constant is added in sequence to obtain the third evaluation values ​​of other suspicious statements; The preset constant is a positive number or a negative number.

4. The method for locating functional defects in a software product line according to claim 1, It is characterized in that The calculation method of the fourth evaluation vector is: y=aX+(1-a)Y; Wherein, y represents the fourth evaluation vector; X represents the first evaluation vector, Y represents the second evaluation vector; and a is a pre-set decimal, representing a weight constant.

5. The method for locating functional defects in a software product line according to claim 1, It is characterized in that The location information is the row number of the corresponding feature of the suspicious sentence in the feature library.

Citation Information

Patent Citations

  • GIS insulation defect fault positioning method based on SOA-FNN algorithm

    CN114660448A