Achieving 100% Cumulative Code Coverage

<< Click to Display Table of Contents >>

Navigation:  eTPU Development Tool (ASH WARE, Inc.) >

Achieving 100% Cumulative Code Coverage

Previous pageReturn to chapter overviewNext page

Example Download

Overview

It is critical to test your code, but how thorough are the tests? This case study achieves 100% code coverage. Specifically, a simple, 'MeasurePeriod' function is tested.

How to Run

1.Unzip the downloaded file into a directory

2.Open a DOS console window and navigate to that directory

3.Run file, "TEST.BAT" Note that you may need to edit it a bit to adjust some paths in order to get it to run.

Did it work?

If it worked, you will see a "success" message.

If it failed, a "failed" message will appear.

What did it do?

A series of five tests were run. These tested the following four things:

Basic Operation

Timeout

Fault Detection

Corner Cases

Falling Edge Detection

At the beginning of each test, the cumulative coverage of all previous tests was loaded using the script file below (or similar.)

load_cumulative_file_coverage("MeasurePeriod.c", "02_FaultDetection.CoverageData");

At the end of each test, the following scripts (more or less) were run.

save_cumulative_file_coverage("MeasurePeriod.c", "03_CornerCases.CoverageData");

At the very end of (only) the very LAST test, the following script was run.

// Verify 100% instruction, 100% branch, 100% entry coverage!

verify_file_coverage_ex("MeasurePeriod.c", 100, 100, 100);