IP Library Granted Patent US 12,277,486
Granted Patent B2
US 12,277,486 · App. 17/407,752 · Granted Apr 15, 2025

Defect location method and device based on coverage information

Inventors: Lu Zhang (Beijing, CN); Yiling Lou (Beijing, CN); Qihao Zhu (Beijing, CN); Jinhao Dong (Beijing, CN); Zeyu Sun (Beijing, CN); Dan Hao (Beijing, CN)
Assignee: Peking University
G06N3/04G06N20/00
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,277,486
App. No.
17/407,752
Granted
Apr 15, 2025
Kind
B2
Abstract

The present disclosure discloses a defect location method and device based on coverage information, the method including: characterizing program structure information and test case coverage information of a target program in a graph to obtain a graph-characterized structure; generating a node attribute sequence and an adjacency matrix based on the graph-characterized structure; and inputting the node attribute sequence and the adjacency matrix to a trained graph neural network model, so that the graph neural network model outputs a suspicious degree list of the target program based on the node attribute sequence and the adjacency matrix. Through the graph-based unified information characterization, the coverage information can be saved without loss and compression, and the structure information may also be considered, thereby improving the accuracy of defect location.

Claims (33)

1. A defect location method based on coverage information, the method comprising:

characterizing program structure information and test case coverage information of a target program in a graph to obtain a graph-characterized structure;

generating a node attribute sequence and an adjacency matrix based on the graph-characterized structure; and

inputting the node attribute sequence and the adjacency matrix to a trained graph neural network model, so that the graph neural network model outputs a suspicious degree list of the target program based on the node attribute sequence and the adjacency matrix,

wherein the characterizing program structure information and the test case coverage information of the target program in the graph to obtain the graph-characterized structure comprises:

obtaining an abstract syntax tree structure of each function in the target program as the program structure information of the target program, wherein the abstract syntax tree structure comprises a plurality of program nodes and attribute information of each program node;

using each test case in the test case coverage information as an independent test node; and

generating the graph-characterized structure based on the abstract syntax tree structure of each function, and a coverage relationship between each test node in the test case coverage information and each program node;

wherein the graph neural network model outputting the suspicious degree list of the target program based on the node attribute sequence and the adjacency matrix comprises:

converting the node attribute sequence into a vector sequence through an embedding layer in the graph neural network model and outputting the vector sequence to a graph neural network layer in the graph neural network model;

obtaining, by the graph neural network layer, a state value of the program node and a state value of the test node based on the vector sequence and the adjacency matrix, and outputting them to an output layer in the graph neural network model by the graph neural network layer; and

obtaining, by the output layer, the suspicious degree of each function in the target program based on the state value of the program node and the state value of the test node, and generating, by the output layer, the suspicious degree list of each function in an order of suspicious degree from high to low.

2. The defect location method according to claim 1 , wherein the generating the node attribute sequence and the adjacency matrix based on the graph-characterized structure comprises:

generating the node attribute sequence based on the attribute information of the program node contained in the graph-characterized structure and the attribute information of the test node, wherein the attribute information of the test node is the attribute indicating that the test case passed the test or the attribute indicating that the test case failed the test; and

generating the adjacency matrix based on the coverage relationship between the program node contained in the graph-characterized structure and the program node, and the coverage relationship between the program node and the test node.

3. The defect location method according to claim 1 , wherein the graph neural network layer comprises a plurality of sub-layers; and

wherein a first sub-layer of the graph neural network layer obtains the state value of the program node and the state value of the test node based on the vector sequence and the adjacency matrix, and starting from a second sub-layer, each sub-layer updates the state value of the program node and the state value of the test node based on the output of the previous sub-layer and the adjacency matrix.

4. A defect location device based on coverage information, the device comprising:

a graph-characterized module, which is configured to characterize program structure information and test case coverage information of a target program in a graph to obtain a graph-characterized structure;

a model input generation module, which is configured to generate a node attribute sequence and an adjacency matrix based on the graph-characterized structure; and

a defect location module, which is configured to input the node attribute sequence and the adjacency matrix to a trained graph neural network model, so that the graph neural network model outputs a suspicious degree list of the target program based on the node attribute sequence and the adjacency matrix,

wherein the graph-characterized module is specifically configured to:

obtain an abstract syntax tree structure of each function in the target program as the program structure information of the target program, wherein the abstract syntax tree structure comprises a plurality of program nodes and attribute information of each program node;

use each test case in the test case coverage information as an independent test node; and

generate the graph-characterized structure based on the abstract syntax tree structure of each function, and a coverage relationship between each test node in the test case coverage information and each program node;

wherein the defect location module is specifically configured to:

convert the node attribute sequence into a vector sequence through an embedding layer in the graph neural network model and output the vector sequence to a graph neural network layer in the graph neural network model;

enable the graph neural network layer to obtain a state value of the program node and a state value of the test node based on the vector sequence and the adjacency matrix, and output them to an output layer in the graph neural network model; and

enable the output layer to obtain the suspicious degree of each function in the target program based on the state value of the program node and the state value of the test node, and generate the suspicious degree list of each function in an order of suspicious degree from high to low.

5. The defect location device according to claim 4 , wherein the model input generation module is specifically configured to:

generate the node attribute sequence based on the attribute information of the program node contained in the graph-characterized structure and the attribute information of the test node, wherein the attribute information of the test node is the attribute indicating that the test case passed the test or the attribute indicating that the test case failed the test; and

generate the adjacency matrix based on the coverage relationship between the program node contained in the graph-characterized structure and the program node, and the coverage relationship between the program node and the test node.

6. The defect location device according to claim 4 , wherein the graph neural network layer comprises a plurality of sub-layers; a first sub-layer of the graph neural network layer obtains the state value of the program node and the state value of the test node based on the vector sequence and the adjacency matrix, and starting from a second sub-layer, each sub-layer updates the state value of the program node and the state value of the test node based on the output of the previous sub-layer and the adjacency matrix.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 20, 2021
From: ZHANG, LU; LOU, YILING; ZHU, QIHAO; DONG, JINHAO; SUN, ZEYU; HAO, DAN
To: PEKING UNIVERSITY
Reel/Frame 057241/0874 →
Priority Claims (1)
CN 202110616324.8 · Jun 2, 2021 · national
Continuity (1)
Related Publication 20220391663A1 · Dec 8, 2022
References Cited (5)
US 20150378874A1 · Prasad · 2015 [cited by examiner]
CN 106445801A · 2017 [cited by examiner]
CN 109471793A · 2019 [cited by examiner]
CN 111831541A · 2020 [cited by examiner]
CN 112965894A · 2021 [cited by examiner]