Target Language Compiler    

TLC Coverage

The example in the last section used the debugger to detect a problem in one section of the TLC file. Since it is conceivable that a test model does not cover all possible cases, there is a technique that traces the untested cases, the TLC coverage option.

Using the TLC Coverage Option

The TLC coverage option provides an easier way to ascertain that the different code parts (not paths) in your code are exercised. To initiate TLC coverage generation, select Start TLC coverage when generating code from the TLC debugging category of the Real-Time Workshop pane of the Simulation Parameters dialog box. You can also initiate TLC coverage from the command line switch -dn in the System target file field, but this is not recommended.

When you initiate TLC coverage, the Target Language Compiler produces a .log file for every target file (*.tlc) used. These .log files are placed in the Real-Time Workshop created project directory for the model. The .log file contains usage (count) information regarding how many times it encounters each line during execution. Each line includes the number of times it is encountered followed by a colon and followed by the code.

Example .log File

The .log file for gain.tlc is gain.log. It is shown here when used with the simple_log test model in matlabroot/toolbox/rtw/rtwdemos/tlctutorial/tlcdebug/. This file is located in work_directory/simple_log_grt_rtw/gain.log:

Analyzing the Results

This structure makes it easy to identify branches not taken and to develop new tests that can exercise unused portions of the target files.

Looking at the gain.log file, you can see that the code has not been tested with InlineParameters off and some cases with InlineParameters have not been exercised. Using this log as a reference and creating models to exercise unexecuted lines, you can make sure that your code is more robust.


  TLC Debugger Command Summary TLC Profiler