A Software Fault Localization Method Based on Network Spectrum
By constructing a network spectrum and using graph neural networks for fault localization, the problem of failure propagation between software entities in existing technologies is solved, achieving more efficient and accurate software fault localization and improving software reliability and usability.
Patent Information
- Application Number
- CN202111573144.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-21
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2041-12-21
AI Technical Summary
Existing software fault location methods based on program spectrum fail to effectively consider the fault propagation relationship between software entities, resulting in a high false alarm rate and insufficient utilization of the overall structural information of the software network.
A software network is built using reverse engineering. The network spectrum is constructed by combining program spectrum and test case information. Fault location is performed using graph neural network. The network structure and test case information are represented by adjacency matrix and feature matrix.
This enables more accurate software fault location, improves the efficiency and accuracy of fault location, and enhances the reliability and usability of the software.
Smart Images

Figure CN114253853B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of software reliability and software testing technology, and in particular to a software fault location method based on network spectrum. Background Technology
[0002] With the rapid development of computer technology, software functions are becoming increasingly powerful, and the scale and complexity of software are also increasing dramatically. To reduce losses caused by software failures, fault location and troubleshooting to ensure software quality and reliability have become extremely important. As complex software systems increase dramatically in scale and complexity, traditional fault location techniques (such as program logging, assertions, breakpoints, and analysis) are no longer effective. Therefore, many automated or semi-automated software fault location methods have been proposed. Among these methods, program spectrum-based fault location is arguably the most classic. This type of method involves capturing software test case execution information to construct an information matrix based on test case coverage information (success or failure), i.e., a program spectrum. Then, a suspicion value is assigned to each program entity (which can be a statement, function module, or other software unit of different granularities) using a suspicion value calculation formula. The entities are then ranked based on their suspicion values; the higher the ranking, the more likely a fault exists. In other words, the idea behind this type of method is that if a program entity is always covered by failed test cases but not by successful test cases, then that entity is considered suspicious. A significant limitation of program spectrum-based software fault location methods is that they do not consider the correlation between program entities. Different program entities are isolated from each other, but in reality, software faults can propagate through control flow or data flow. Therefore, after obtaining the entity with the highest suspicion, it is not possible to determine whether the fault originated from that entity or whether that entity merely propagated the error that originated from the predecessor entity. Thus, fault location methods that do not consider the fault propagation effect may produce a high false alarm rate in some cases.
[0003] Meanwhile, complex software systems can be decomposed into a collection of software entities (such as functions and classes), and the expected functions are achieved through the interaction of these entities. If we consider software entities as nodes and the relationships between entities as edges, then the software structure essentially manifests as an interconnected complex network topology. Furthermore, as the scale of software continues to increase, this "networking" trend becomes increasingly apparent, and these complex software systems become another important type of social network: software networks. Based on this, the latest research focuses on using methods from complex network theory to conduct a more abstract and quantitative analysis of the software fault propagation process, thereby improving traditional fault location methods based on fault propagation, especially improving the calculation method of suspicion level. This type of method has achieved some improvement, but research is still not in-depth. A software network itself is a high-level abstraction of software from a holistic perspective; the abstract form is an interconnected network, that is, a graph. When we establish a software network with software modules as nodes and the logical relationships between modules as edges, fault location at the software module level is essentially classifying nodes on the network structure, or in other words, on the graph. Categories include states such as "faulty" and "normal."
[0004] Existing software fault location methods based on program spectrum calculate suspicion level using test case coverage information, but they do not consider the propagation relationship of faults between software entities. Furthermore, research on improved fault location methods based on complex network theory to quantitatively analyze fault propagation through software networks is still insufficient, and these methods do not combine software test information with the overall structural information of the software network for fault location. Summary of the Invention
[0005] The purpose of this invention is to provide a software fault location method based on network spectrum to solve the above-mentioned problems.
[0006] The present invention solves the technical problem by adopting the following technical solution:
[0007] A software fault location method based on network spectrum includes the following steps:
[0008] Step 1: Collect the source code of the software to be tested;
[0009] Step 2: Establish a software network based on reverse engineering;
[0010] Step 3: Design and execute software test cases, record their coverage information and execution results, and establish a module-level program spectrum;
[0011] Step 4: Based on the software network established by program spectrum expansion, establish a network spectrum containing program spectrum information;
[0012] Step 5: Based on path similarity analysis, the network spectrum size is reduced to achieve feature dimensionality reduction;
[0013] Step 6: Based on the reduced network spectrum, construct the feature matrix and the adjacency matrix representing the software network structure;
[0014] Step 7: Based on the adjacency matrix and feature matrix, use a graph neural network to locate software faults.
[0015] Furthermore, in step 1, the source code of the software under test is collected, and the construction method is as follows:
[0016] Obtain the source code files of the software to be tested.
[0017] Furthermore, in step 2, a software network is built based on reverse engineering. The construction method is as follows:
[0018] Based on the concept of reverse engineering, starting from the software source code, we analyze the software source code to obtain the software module set V = {v1, v2, ..., v...} n} and its logical relation set E = {e1,e2,…,e m}, thereby establishing a software network G, where software modules are software entities at different levels, such as functions, classes, and methods.
[0019] Furthermore, depending on the selected module, G employs networks of different granularities, such as function call networks, class dependency networks, or method call networks.
[0020] Furthermore, in step 3, software test cases are designed and executed, their coverage information and execution results are recorded, and a module-level program spectrum is established. The construction method is as follows:
[0021] The system automatically generates k test cases for the software under test and executes all test cases. Based on the module categories of the software network, it establishes corresponding module-level program spectra (MP) based on the test case execution information.
[0022] This test case spectrum contains the coverage of each software module for each test case, as well as the execution results of the test cases themselves. Therefore, it includes four scenarios: UF (not covered by failed test cases), US (not covered by successful test cases), CF (covered by failed test cases), and CS (covered by successful test cases). It will target module v... i The number of the four types of test cases mentioned above is denoted as N. UF (v i ), N US (v i ), N CF (v i ) and N CS (v i If N ), then N UF (vi )+N US (v i )+N CF (v i )+N CS (v i The module-level program spectrum (MP) is constructed from the test case coverage information of n modules (k × n), with each element in the program spectrum having a value of N. UF (v i ), N US (v i ), N CF (v i ) and N CS (v i One of them.
[0023] Furthermore, in step 4, based on the software network established by program spectrum extension, a network spectrum containing program spectrum information is constructed. The construction method is as follows:
[0024] Based on the established module-level program spectrum MP, the program spectrum targeting module v will be further refined. i The information of k test cases is used as nodes v in the software network G. i The attributes of the extended software network are known as the network spectrum NP.
[0025] Furthermore, in step 5, based on path similarity analysis, the network spectral size is reduced to achieve feature dimensionality reduction. The construction method is as follows:
[0026] A path similarity analysis method is used to analyze all network paths, retaining only those with low similarity, thereby reducing the size of the network spectrum. The reduced network spectrum is denoted as NP'. Each node in NP' contains k' test cases, where k' ≤ k. The number of test cases represents the dimension of the node features, thus achieving feature dimensionality reduction.
[0027] Furthermore, in step 6, based on the reduced network spectrum, a feature matrix and an adjacency matrix representing the software network structure are constructed. The construction method is as follows: based on the network spectrum NP', an adjacency matrix A of the network is established to represent the network structure, and a feature matrix X representing the features of all nodes in the network is established. This feature matrix X is composed of the features of each node.
[0028] Furthermore, in step 7, a graph neural network is used for software fault localization based on the adjacency matrix and the feature matrix. The construction method is as follows:
[0029] Using the adjacency matrix A and the feature matrix X as input, a graph neural network is used to classify all nodes into two categories: faulty and normal, thereby achieving module-level software fault localization.
[0030] Beneficial effects:
[0031] The advantages of this invention compared to existing technologies are as follows: Existing software fault location methods based on program spectrum treat entities as isolated when calculating the suspiciousness of software entities based on test case coverage information, failing to consider the propagation effect of software faults based on the relationships between entities. Furthermore, methods that improve program spectrum fault location methods by establishing software networks based on complex network theory to achieve quantitative analysis of fault propagation are still not deeply researched and do not fully utilize the overall information of the software network. Therefore, this invention draws on complex network theory, program spectrum fault location methods, and graph deep learning methods, combining program spectrum and software network to establish a network spectrum. Then, based on the network spectrum, a network adjacency matrix and a feature matrix are established. These adjacency matrices and feature matrices are then directly used as inputs to perform fault location using a graph neural network. The adjacency matrix is essentially another representation of the network structure, completely representing the overall network structure, and therefore inherently contains possible fault propagation effects. Simultaneously, the feature matrix contains information such as test case coverage and execution results. This invention integrates and innovates existing software network and program spectrum fault location methods, providing a software fault location technology based on network spectrum. Attached Figure Description
[0032] Figure 1 This is a flowchart illustrating the overall steps of the method described in this invention;
[0033] Figure 2 This is a schematic diagram of the module-level program spectrum obtained based on test case execution information;
[0034] Figure 3 A diagram illustrating a method for constructing a network spectrum that integrates software network and program spectrum information;
[0035] Figure 4 This is a schematic diagram of software fault localization based on network spectrum and graph neural network. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0037] Reference Appendix Figure 1 This invention discloses a software fault location method based on network spectrum, comprising the following steps:
[0038] Step 1: Collect the source code of the software to be tested. The construction method is as follows:
[0039] Obtain the source code files of the software to be tested.
[0040] Step 2: Establish a software network based on reverse engineering. The construction method is as follows:
[0041] Based on the concept of reverse engineering, starting from the software source code, static analysis tools such as Understand and Doxygen are used to analyze the software source code and obtain the software module set V = {v1, v2, ..., v}. n} and its logical relation set E = {e1,e2,…,e m The text data here refers to software modules, which can be software entities at different levels such as functions, classes, and methods, typically determined by the software type and the actual fault location requirements. For example, in C language software, the functional entity is a function, which relies on function calls to achieve the expected function; therefore, its main software module is the function. Alternatively, if the goal is simply to locate the file where the fault lies, the file can be used as the main module to build the required file call network model. After obtaining the data containing software modules and their logical relationships, the data is parsed, and modeling tools such as NetworkX are used to build the software network G. Depending on the selected modules, G can be a network of different granularities, such as a function call network, a class dependency network, or a file call network.
[0042] Step 3: Design and execute software test cases, record their coverage information and execution results, and establish a module-level program spectrum. The construction method is as follows:
[0043] First, k test cases for the software under test are generated manually or automatically using evolutionary testing, and all test cases are executed. During execution, the modules covered by each test case are recorded, along with the success or failure result. For each module, test case coverage and execution success result in four scenarios for test case coverage information: not covered by failed test cases (UF), not covered by successful test cases (US), covered by failed test cases (CF), and covered by successful test cases (CS). This will be applied to module v. i The number of the four types of test cases mentioned above is denoted as N. UF (v i ), N US (v i ), N CF (v i ) and N CS (v i If N ), then N UF (v i )+N US (v i)+N CF (v i )+N CS (v i = k. Finally, the recorded test case coverage information of the n modules constitutes the module-level program spectrum MP of this patent, with a dimension of k×n, and each element in the program spectrum has a value of N. UF (v i ), N US (v i ), N CF (v i ) and N CS (v i One of them, such as Figure 2 The program spectrum MP is shown. The modules in the program spectrum and the modules (i.e., nodes) of the software network are strictly corresponding. If the module of the software network is a function, then when constructing the program spectrum, a program spectrum for the function should be created.
[0044] Step 4: Based on the software network established by program spectrum extension, construct a network spectrum containing program spectrum information. The construction method is as follows:
[0045] Based on the established module-level program spectrum MP, the program spectrum targeting module v will be further refined. i The information of k test cases is used as nodes v in the software network G. i The attributes of these nodes, when extended, form the network spectrum (NP). Essentially, an NP is a network with node attributes, such as... Figure 3 As shown in the network spectrum NP, each node in the network contains its corresponding test case information as an attribute. Therefore, NP contains all the information about both the software network and the program spectrum.
[0046] Step 5: Based on path similarity analysis, the network spectrum size is reduced to achieve feature dimensionality reduction. The construction method is as follows:
[0047] In software testing, the number of tests is typically large, and the number of test cases represents the number of network spectral node attributes, which are also features used for subsequent fault localization. On the one hand, an excessive number of features increases the localization cost; on the other hand, similar or highly correlated features may exist, negatively impacting the performance of subsequent localization algorithms. Therefore, feature dimensionality reduction is necessary to reduce the number of features while ensuring that the feature attributes are relatively independent.
[0048] Each test case covers different modules. Since the modules are connected by edges, the coverage of each test case constitutes a network path. Path similarity analysis is used to analyze all network paths, retaining only those with low similarity to reduce the size of the network spectrum. Alternatively, a path can be treated as a vector, and cosine similarity analysis can be used to quantify the similarity between paths. For paths with excessively high similarity, only one path is retained, thus reducing the number of paths. The reduced network spectrum is denoted as NP', where each node in NP' contains k' test cases, and k' ≤ k. Since the number of test cases represents the dimensionality of the node features, feature dimensionality reduction is achieved through network spectrum reduction.
[0049] Step 6: Based on the reduced network spectrum, construct the feature matrix and the adjacency matrix representing the software network structure. The construction method is as follows:
[0050] The network spectrum itself contains two parts: one is the network representing the overall software structure, and the other is the node attributes representing the test case execution information. To meet the data format requirements for subsequent fault localization, firstly, an adjacency matrix A is established based on the network spectrum NP' to represent the network structure. Simultaneously, a feature matrix X representing the characteristics of all nodes in the network is established. This feature matrix X is composed of the characteristics of each node, such as... Figure 3 The adjacency matrix and feature matrix are shown. If the number of software network modules is n, and the number of reduced test cases is k', then A = A n×n X = X n×k' .
[0051] Step 7: Based on the adjacency matrix and feature matrix, a graph neural network is used for software fault localization. The construction method is as follows:
[0052] Using the adjacency matrix A and the feature matrix X as input, a graph neural network is used for module-level software fault localization, such as... Figure 4 As shown. Specifically, the input and output information for fault localization based on graph neural networks is as follows:
[0053] ① Input layer: It consists of two parts, the graph structure and the feature of each node, namely the adjacency matrix A and the feature matrix X established in step 6.
[0054] ② Hidden layer: The model is built using computational modules such as sampling operators, convolution / loop operators and pooling operators. The feature representation of the nodes is transformed by feature aggregation, and corresponding activation functions (such as modified linear unit ReLU) and loss functions (such as cross-entropy loss function) are designed.
[0055] ③ Output layer: The fault location of this patent is essentially a node binary classification problem based on network spectrum. The output of the graph neural network is the prediction of the node category, including faulty and normal. Thus, the module-level fault location of the software is realized.
[0056] This invention first establishes a software network at the module level (software entities such as functions, classes, methods, and statements) as an abstract representation of the software under test. Simultaneously, it collects test case coverage information obtained from software testing, constructs a program spectrum for each software module, and expands the established software network based on the program spectrum information, building a network spectrum containing program spectrum information. Finally, based on the network spectrum, a graph neural network is used to achieve node-level classification, i.e., module-level software fault location. Using this technique, the overall structure of the software network and test case information can be fully utilized to achieve accurate module-level software fault location.
[0057] This invention is limited to using a specific type of graph neural network. As long as the adjacency matrix and feature matrix are obtained based on the construction of the network spectrum, different types of graph neural networks, such as semi-supervised and unsupervised, can be used to perform fault prediction tasks.
[0058] The above steps complete the construction of a network spectrum-based software fault location technology. This technology first establishes the software network and program spectrum of the software under test, then merges the two information to construct the network spectrum. After reducing the network spectrum, an adjacency matrix representing the network structure and a feature matrix representing test case execution information are established. Finally, a graph neural network is used for software fault location. This technology fully utilizes the overall structural information of the software and the test case execution information to achieve accurate fault location.
[0059] This invention integrates a program spectrum containing test case execution information and a software network representing the overall software structure. It comprehensively considers the interconnected coupling relationships between software modules from the perspective of the overall software structure while fully utilizing information obtained from software testing. This invention is applicable to solving the problem of software fault location in complex software, helping software engineers quickly locate software faults, thereby improving software reliability and enabling high practical application value.
[0060] This fault location technology is constructed based on complex network theory, program spectrum fault location method and graph neural network method, forming a relatively practical software fault location technology based on network spectrum.
[0061] The advantages of this invention compared to existing technologies are as follows: Existing software fault location methods based on program spectrum treat entities as isolated when calculating the suspiciousness of software entities based on test case coverage information, failing to consider the propagation effect of software faults based on the relationships between entities. Furthermore, methods that improve program spectrum fault location methods by establishing software networks based on complex network theory to achieve quantitative analysis of fault propagation are still not deeply researched and do not fully utilize the overall information of the software network. Therefore, this invention draws on complex network theory, program spectrum fault location methods, and graph deep learning methods, combining program spectrum and software network to establish a network spectrum. Then, based on the network spectrum, a network adjacency matrix and a feature matrix are established. These adjacency matrices and feature matrices are then directly used as inputs to perform fault location using a graph neural network. The adjacency matrix is essentially another representation of the network structure, completely representing the overall network structure, and therefore inherently contains possible fault propagation effects. Simultaneously, the feature matrix contains information such as test case coverage and execution results. This invention integrates and innovates existing software network and program spectrum fault location methods, providing a software fault location technology based on network spectrum.
[0062] The testing technology of this invention is constructed based on complex network theory and graph deep learning methods, forming a software fault location technology based on network spectrum. While improving the efficiency and accuracy of software fault location, it also aims to improve the reliability, security and availability of software.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A network spectrum based software fault localization method, characterized in that, Comprising the following steps: Step 1, collect the software source code to be tested; Step 2, establish a software network based on reverse engineering, the construction method is as follows: Based on the reverse engineering thought, the software module set is obtained by analyzing the software source code from the software source code and the logical relationship set , so as to establish the software network G , and the software module is a software entity at different levels of functions, classes and methods Step 3, design software test cases and execute, record its coverage information and execution results, establish module level program spectrum, the construction method is as follows: Automated generation of software under test k Each test case is assigned and executed. Based on the module categories of the established software network, a corresponding module-level program spectrum is created based on the test case execution information. MP ; The procedure spectrum contains the coverage of each test case for each software module and the execution result of the test case itself, so it contains four cases: not covered by failed test cases UF , not covered by successful test cases US , covered by failed test cases CF , and covered by successful test cases CS ; the above-mentioned four test case numbers for module v i are recorded as N UF ( v i ), N US ( v i ), N CF ( v i ) and N CS ( v i ), respectively ; the module-level procedure spectrum MP is composed of n test case coverage information of k modules, with a dimension of , and each element in the procedure spectrum has a value of one of N UF ( v i ), N US ( v i ), N CF ( v i ) and N CS ( v i ) Step 4, based on the program spectrum expansion of the software network, establish a network spectrum containing program spectrum information; Step 5, based on path similarity analysis, the scale of network spectrum is reduced, and the feature dimension reduction is realized, the construction method is as follows: The path similarity analysis method is used to analyze all network paths, only the network paths with low similarity are reserved, the network spectrum is reduced, and the reduced network spectrum is recorded as ; Each node contains test cases, and The number of test cases represents the dimensionality of the node features, and the feature dimensionality is reduced. Step 6, based on the reduced network spectrum, construct a feature matrix and an adjacency matrix representing the software network structure, the construction method is: based on the network spectrum establish the adjacency matrix of the network A represent the network structure, and establish a feature matrix representing the characteristics of all nodes of the network X , the feature matrix X is composed of the characteristics of each node; Step 7, based on the adjacency matrix and the feature matrix, the software fault location is carried out using the graph neural network, the construction method is as follows: Take the adjacency matrix A and the feature matrix X as input, use the graph neural network to carry out module level software fault location, the information of the fault location based on the graph neural network in the input and output aspects is as follows: ① Input layer: including two parts, graph structure and feature of each node, namely adjacency matrix A and feature matrix X established in step 6; ② Hidden layer: use sampling operator, convolution / cycle operator and pooling operator and other calculation modules to build model, transform the feature representation of nodes through feature aggregation, and design corresponding activation function and loss function; ③ Output layer: the output of the graph neural network is the prediction of node category, including fault and normal two kinds, thus the module level fault location of software is realized; Step 4, based on the program spectrum expansion of the software network, establish a network spectrum containing program spectrum information, the construction method is as follows: Based on the established module-level program spectrum MP , targeting the module v i of k Each test case information serves as a software network. G Middle node v i The attributes of the extended software network are called the network spectrum. NP .
2. The network spectrum-based software fault localization method of claim 1, wherein, Step 1, collect the software source code to be tested, the construction method is as follows: Get the source program file of the software to be tested.
3. The network spectrum-based software fault localization method of claim 2, wherein, Depending on the different selected module, G Different granularity networks are adopted, such as function call network, class dependency network or method call network.
Citation Information
Patent Citations
Defect positioning method based on context awareness
CN112965894A