Increase coverage of custom C code integration in S function
1 view (last 30 days)
Show older comments
I have a C code program that i have integrated in a S function block in a simulink environment. After analyzing the coverage of the S function block, the decision coverage = 50% and statement coverage = 79%.
I want to increase the coverage of the C program code. Do i need to create test condition in the source code itself or will i be able to get test cases using the Simulink test and Simulink design verifier ?
Note: The C program do not take any sort of inputs.
Thank you in advance.
2 Comments
Answers (1)
Antoine Requet
on 21 Feb 2020
Hello Rohit,
Simulink Design Verifier should be able to generate test cases for S-functions. Depending on how your S-function is compiled, you may have to recompile it to enable support for Design Verifier:
- If you have compiled your S-function with the legacy_code tool, you should set the supportCoverageAndDesignVerifier option to true
- If your S-function is defined in an S-function builder block, you should check the box "Enable Support for Design Verifier" in the "Build Info" tab
- If your S-function is compiled with mex or slcovmex, you should compile it with slcovmex with the -sldv option.
However, I am seeing that you mentioned that the C program does not take any sort of inputs. If that means that your S-function does not have inputs, then it may not be possible to generate additional tests for extending the coverage, since the tests are based on the inputs of the model.
2 Comments
Antoine Requet
on 26 Feb 2020
Hello Rohit,
If your S-function does not have inputs or parameters at all, then Simulink Design Verifier cannot generate additional test cases for extending the coverage of the S-function as-is: the test cases are defined by input values, so no test case can be provided without inputs.
However, depending on your S-function and your objectives, it may still be possible to use design verifier to extend the coverage (but it would require a bit more work) :
- In the case where your S-function does not have inputs, but is accepting parameters, you may be able to use the Design Verifier parameter configuration to extend the coverage by varying the parameters.
- If the coverage is missing because of "hidden" inputs that are not exposed to Simulink, you could modify your S-function to expose them as input or parameter so that they are visible to Simulink. That way, test cases could be generated.
See Also
Categories
Find more on Best Practices for Simulink Design Verifier Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!