polyspace-test -generate
R2026b(System Command) Generate test registration function from a set of Polyspace Test C/C++ test files
Since R2023b
Syntax
Description
The system command polyspace-test -generate generates a test registration function for the C/C++ xUnit tests provided in test files.
polyspace-test -generate -registration generates a file -results-dir <resultsFolder> -filename <regFile> -test-sources <testFiles> [options]<regFile> with a test registration function for the tests specified in <testFiles>.
polyspace-test -generate -registration -main generates a file -results-dir <resultsFolder> -filename <regFile> -test-sources <testFiles> [options]<regFile> with a test registration function and a main function for the tests specified in <testFiles>.
Examples
Input Arguments
Limitations
The -generate -registration command uses regular expressions to detect test macros, such as PST_SIMPLE_TEST, PST_SIMPLE_TEST_BODY, or PST_TEST, in the specified test files, and then generates the registration function. The test detection has the following limitations:
The test detection does not account for block comments, inline comments, or strings that resemble test macros. If your test files contain commented-out or string-enclosed macros, the command incorrectly registers them as actual tests.
The test detection does not recognize macros with multiple parameters where the arguments span multiple lines. For instance, if you split the arguments to
PST_TEST(across two lines, the command does not detect the test.suite,name)If you create your own macros for test definition using
#define-s like the following:The test detection does count invocations of your macros as tests.#define MY_TEST PST_TEST
If you add your xUnit tests to a Polyspace Platform project, the test registration function is automatically generated at build time. The test registration via Polyspace Platform projects performs a static analysis of your test code and avoids the above limitations.
Version History
Introduced in R2023b