# US 12,222,833 B2 · Method and device for determining coverage in HIL testing, and storage medium

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

- Number: US 12,222,833 B2
- Document ID: US12222833B2
- Status: Granted
- Kind: B2
- Application number: 18/186,122
- Filed: 2023-03-17
- Published: 2023-09-28
- Granted: 2025-02-11
- Earliest claimed: 2022-03-24
- Assignees: Sungrow Power Supply Co., Ltd.
- Applicants: Sungrow Power Supply Co., Ltd.
- Inventors: Cunhao Gong
- Web page: https://patentgrep.com/patent/US12222833B2

## CPC

- G06F 11/27: Built-in tests
- G06F 11/3676: {for coverage analysis}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method and a device for detecting coverage in HIL testing, and a computer-readable storage medium are. The method includes: acquiring an HIL test case and performing HIL testing on a controller based on the HIL test case; for each of functions in code of the controller, detecting a preset mark of the function and acquiring statistical data about the detected preset mark during the HIL testing; and determining coverage of the HIL test case on the functions based on the statistical data about the preset marks. Both the determination of execution and functionality of the function in the code based on the HIL test case as well as the determination of the coverage of the HIL test case based on the execution of the function in the code are performed during the HIL testing.

## Claims

### Claim 1

A method for determining coverage in HIL testing, comprising:
acquiring a Hardware in Loop (HIL) test case and performing HIL testing on a controller based on the HIL test case;
for each of functions in code of the controller, detecting a preset mark of the function and acquiring statistical data about the detected preset mark during the HIL testing; and
determining coverage of the HIL test case on the functions based on the statistical data about the preset marks.

### Claim 2 (depends on 1)

The method for determining coverage in HIL testing according to claim 1, wherein the preset mark comprises at least one of a function status bit and a function execution counter, and
wherein the method for determining coverage in HIL testing further comprises: for each of the functions in code of the controller, adding a preset mark to the function before the performing HIL testing on a controller based on the HIL test case.

### Claim 3 (depends on 1)

The method for determining coverage in HIL testing according to claim 1, further comprising:
before the determining coverage of the HIL test case on the functions based on statistical data about the preset marks,
acquiring a first function sum of all the functions in the code; and
acquiring a second function sum of functions whose function status bits and/or function execution counters subjected to a change during the HIL testing.

### Claim 4 (depends on 3)

The method for determining coverage in HIL testing according to claim 3, wherein the determining coverage of the HIL test case on the functions based on statistical data about the preset marks comprises:
determining a ratio of the second function sum to the first function sum as the coverage.

### Claim 5 (depends on 1)

The method for determining coverage in HIL testing according to claim 1, further comprising:
after the determining coverage of the HIL test case on the functions based on statistical data about the preset marks,
acquiring a software testing report and an HIL testing report of the HIL test case of the controller.

### Claim 6 (depends on 5)

The method for determining coverage in HIL testing according to claim 5, further comprising:
after acquiring a software testing report and an HIL testing report of the HIL test case of the controller,
modifying at least one of the code of the controller and the HIL test case based on the software testing report and the HIL testing report when the coverage is less than 100%.

### Claim 7 (depends on 6)

The method for determining coverage in HIL testing according to claim 6, wherein the modifying at least one of the code of the controller and the HIL test case based on the software testing report and the HIL testing report comprises:
determining an idle function whose function status bit and function execution counter remain unchanged during the HIL testing;
determining a cause of the idle function based on the software testing report and the HIL testing report;
modifying the code of the controller based on the cause; and/or
modifying the HIL test case based on the cause.

### Claim 8 (depends on 7)

The method for determining coverage in HIL testing according to claim 7, wherein the modifying the code of the controller based on the cause comprises:
acquiring a current version of the code of the controller; and
deleting the idle function from the code if the idle function in the current version is unnecessary for all HIL test cases.

### Claim 9 (depends on 7)

The method for determining coverage in HIL testing according to claim 7, wherein the modifying the HIL test case based on the cause comprises:
writing another HIL test case to replace the HIL test case so as to test the idle function if the idle function is essential to all HIL test cases and fails to be tested.

### Claim 10 (depends on 9)

The method for determining coverage in HIL testing according to claim 9, further comprising:
after the modifying at least one of the code of the controller and the HIL test case based on the software testing report and the HIL testing report,
returning to the performing HIL testing on a controller until the coverage is equal to 100%.

### Claim 11 (depends on 1)

A device for determining coverage in HIL testing, comprising:
a memory;
a processor; and
a computer program stored in the memory and executable by the processor, wherein the computer program is for implementing the method for determining coverage in HIL testing according to claim 1.

### Claim 12 (depends on 1)

A non-transitory computer-readable storage medium storing a computer program that, when being executed by a processor, implements the method for determining coverage in HIL testing according to claim 1.
