# US 9,355,019 B2 · Method for test case reduction based on program behavior slices

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 9,355,019 B2
- Document ID: US9355019B2
- Status: Granted
- Kind: B2
- Application number: 14/761,617
- Filed: 2013-11-07
- Published: 2015-12-17
- Granted: 2016-05-31
- Earliest claimed: 2013-10-14
- Assignees: Xi'an Jiaotong University
- Applicants: Xi'an Jiaotong University
- Inventors: Xiaohong Guan; Qinghua Zheng; Ting Liu; Haijun Wang
- Web page: https://patentgrep.com/patent/US9355019B2

## CPC

- G06F 11/3688: {for test execution, e.g. scheduling of test suites}
- G06F 11/3604: Analysis of software for verifying properties of programs (testing of software G06F11/3668)
- G06F 11/3676: {for coverage analysis}
- G06F 11/3684: {for test design, e.g. generating new test cases}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

The present invention provides a method of test cases reduction based on program behavior slices. In the present invention, during a static analysis stage, analyzing a control flow and an information flow of a program according to input program codes, extracting control dependence and data dependence of the program; calculating potential dependence of the program according to the control dependence and the data dependence of the program; on the basis of the control dependence, the data dependence and the potential dependence, constructing combination dependence of the program; during a dynamic execution stage, according to an execution path and the dependence relation, calculating program behavior slices covered by the path and program behavior slices uncovered by the path, and guiding symbolic execution to generate a path capable of covering new program slices according to the uncovered program behavior slices.

## Claims

### Claim 1

A method of test cases reduction based on program behavior slices, comprising:
S1) analyzing control flow and information flow of a under test program and extracting a control dependence and a data dependence of the under test program, according to the under test program and by using a static program analysis method;
S2) calculating a potential dependence of the under test program, according to the control dependence and the data dependence of the under test program;
S3) constructing a combination dependence of the under test program in a program control flow graph, according to the control dependence, the data dependence and the potential dependence of the under test program;
S4) randomly generating an initial path by using a symbolic execution method, and storing a test case corresponding to the initial path to a valid test suite;
S5) calculating a program behavior slices covered by the new path, wherein the initial path is executed at the first time, and the calculation includes: for each branch node executed by the path, calculating the program behavior slices on the path, wherein, the program behavior slices of anode m on the path contains all nodes conforming to the following characters: the nodes have an interact relation on the path with the node m by the control dependence, the data dependence, the potential dependence, the combination dependence or their transition;
S6) calculating a program behavior slices uncovered by the new path wherein the initial path is executed at the first time, and the calculation includes: according to the dependence relation, calculating all the branches required to be negated on the path and calculating the program behavior slices of the negated branches on the path;
S7) updating the uncovered program behavior slices, including: deleting the program behavior slices covered by the new path and adding program behavior slices uncovered by the new path;
S8) if the uncovered program behavior slices is null, i.e., there are no uncovered program behavior slices, going to Step S10); otherwise, going to Step S9);
S9) selecting one piece of program behavior slices from the uncovered program behavior slices according to breadth first algorithm, guiding symbolic execution to generate a test path, if the test path is valid, storing its corresponding test case to the test suite and going to the Step S5); if no valid path is generated, deleting the selected program behavior slice from the uncovered program behavior slices and going to the Step S8); and
S10) outputting the valid test suite which covers all the program behavior slices of the program.

### Claim 2 (depends on 1)

The method of test cases reduction according to claim 1, wherein, the potential dependence in the Step S2) is defined as follows: when a condition wherein a statement s1 and a statement s2 simultaneously conform to the following requirements, then there exists the potential dependence between the conditional statement s1 and the statement s2: 1) when the conditional statement s1 invokes a branch br, a statement s′1 satisfies with a requirement in which there exists the direct or indirect control dependence between the statement s1 and the statement s′1 through the branch br and there exists the data dependence between the statement s′1 and the statement s2; 2) when the conditional statement s1 invokes a negated branch br′ of the branch br, no statement s′1 satisfies with a requirement in which there exists the direct or indirect control dependence between the statement s1 and the statement s′1 through the branch br′ and there exists the data dependence between the statement s′1 and the statement s2, wherein the control dependence and the data dependence describe an influence on the statement s2 when the statement s1 is executed, while the potential dependence indicates an influence on the statement s2 when the non-execution of the statement s′1 is controlled by the statement s1.

### Claim 3 (depends on 1)

The method of test cases reduction according to claim 1, wherein, the combination dependence in the Step S3) is defined as follows: when a statement s1 and a statement s2 simultaneously conform to the following three requirements, there exists the combination dependence between the statement s1 and the statement s2: 1) there is a path from the statement s1 through the statement s2 to a statement s3; 2) on the path, there exists the dynamic data dependence, the potential dependence or the combination dependence between the statement s1 and the statement s3; 3) on the path, there exists the dynamic control, the data dependence, the potential dependence or the combination dependence between the statement s2 and the statement s3.

### Claim 4 (depends on 1)

The method of test cases reduction according to claim 1, wherein, the step of constructing the combination dependence of the program in the control flow graph in the Step S3) further comprises:
S301) providing each statement of the program as a node and calculating incoming node set and outgoing node set for each node, on the basis of the data flow analysis method;
S302) calculating node pairs flowing in at each node, including: calculating the sum of output node pairs of an immediate previous node to the present node;
S303) calculating node pairs generated at each node, in which nodes flowing in the present node are one-to-one combined to form node pairs with the present node; calculating node pairs killed at each node, in which if either one node of the incoming node pair is redefined by the present node, then the node pair redefined by the present node kills hereby;
S304) calculating node pairs flowing out at each node, including: adding generated node pairs to the incoming node pairs at the present node and then subtracting the node pairs killed hereby; and
S305) calculating the combination dependence, in which for an incoming node pair at a node, if both nodes of the node pair has the control dependence, the data dependence, the potential dependence or the combination dependence with the present node, then it is considered that both nodes of the node pair have the combination dependence.

### Claim 5 (depends on 1)

The method of test cases reduction according to claim 1, wherein, the program behavior slices in the Step S5) is defined as follows: assuming that an execution path ε and a slice criterion node c on the path are given, the program behavior slice of the node c on the path ε contains nodes conforming to the following characters: the nodes have an interact relation with the node c on the path by the control dependence, the data dependence, the potential dependence, the combination dependence or their transition.

### Claim 6 (depends on 1)

The method of test cases reduction according to claim 1, wherein, the uncovered program behavior slice in the Step S6) is defined as follows: assuming a path and a branch bri to be negated on the path are given, the program behavior slice of a branch br′i negated to the branch bri on the path constitutes a piece of uncovered program behavior slice; wherein the uncovered program behavior slice is configured to be calculated as follows:
S601) judging whether the path ε is the initial path, if yes, going to Step S602), otherwise going to Step S603);
S602) negating all branches on the path, generating corresponding program behavior slices, and going to Step S605);
S603) searching the path ε for a node ni corresponding to the last node of the program behavior slices, if the path ε is generated by guide of the program behavior slices;
S604) for an arbitrary branch node bri on the path ε, negating the branch bri and generating the corresponding program behavior slices if there exist the control dependence, the data dependence, the potential dependence, the combination dependence or their transition dependence on the path ε between the nodes ni and the negated branch br′i to the branch bri; and
S605) outputting all the generated program behavior slices as the uncovered program behavior slices on the path.

### Claim 7 (depends on 1)

The method of test cases reduction according to claim 1, wherein, the step of generating the new test path in the Step S9) comprises:
S901) selecting a path behavior slice from the uncovered program behavior slices by using the breadth first algorithm;
S902) calculating program behavior slice condition and deleting the program behavior slice from the uncovered program behavior slices;
S903) guiding symbolic execution by the branch statement condition of the program behavior slice, calculating all paths conforming to the branch statement condition by constraint solution;
S904) judging whether the path is validly executable, if yes, going to Step S905); otherwise going to Step S906);
S905) outputting a path conforming to the program behavior slice condition; and
S906) outputting, including: when no valid execution path is generated, then going to the Step S8),
wherein the program behavior slice condition refers to a set of all the conditional statements in the program behavior slices.
