Achieve Missing Coverage in Generated Code of RLS
This example shows you how to use Simulink® Design Verifier™ to generate test cases that achieve full coverage. If you simulate a harness of a reusable library subsystem (RLS) in the software-in-the-loop (SIL) simulation mode, then coverage of the generated code of the RLS is reported. Using Simulink® Test Manager™, you can easily achieve full coverage by using the following steps:
Generate the top-model code before invoking simulation on the harness of the RLS. Before generating the code, you need to set up the code generation target environment. For more information on how to set up the code generation environment, see Generate Test Cases for a Reusable Library Subsystem. After code generation, open the test file.
Open the test file.
orig = Simulink.fileGenControl('get','CodeGenFolderStructure'); Simulink.fileGenControl('set','CodeGenFolderStructure', Simulink.filegen.CodeGenFolderStructure.TargetEnvironmentSubfolder) ; model = 'mRLS'; load_system('mRLS'); slbuild('mRLS'); testFile = 'dTest_TopOffCoverage_Controller.mldatx'; sltest.testmanager.load(testFile); sltest.testmanager.view;
### Unable to find Simulink cache file "mRLS.slxc". No new subsystem code was generated for library 'mRLS'.
2. Simulate the test file and observe the coverage value.

3. Click Add Tests for Missing Coverage as coverage of the generated code for the RLS is not 100%.

This workflow invokes Simulink® Design Verifier™ to generate additional testcases.

New test cases are added to the test file.

4. Simulate the overall test file and check if you now have full coverage for the generated code for the RLS.
