Main Content

polyspace-test -build

(System Command) Build sources and tests in a Polyspace Platform project

Since R2023b

Description

The system command polyspace-test -build builds the sources and tests in a Polyspace® Platform project.

polyspace-test -build -project <projectFile> [options] builds the sources and tests in a Polyspace Platform project file <projectFile>.

example

polyspace-test -build -project <projectFile> -profiling-mode coverage [-cov-metric-level <coverageLevel>] [options] builds the sources and tests in <projectFile> for code coverage calculation. When you run the tests later, besides test results, code coverage results are also generated.

polyspace-test -build -project <projectFile> -profiling-mode execution-profile [options] builds the sources and tests in <projectFile> for execution profiling. When you run the tests later, besides test results, results on execution time are also generated.

polyspace-test -build -project <projectFile> -profiling-mode stack-profile [options] builds the sources and tests in <projectFile> for memory profiling. When you run the tests later, besides test results, results on memory use are also generated.

polyspace-test -build -project <projectFile> -profiling-mode sanitizer [options] builds the sources and tests in <projectFile> for code sanitizer profiling. When you run the tests later, run-time errors that were caught by the sanitizer are reported as test failures. In addition, a sanitizer profiling results set is generated to show expressions that were instrumented for sanitizer profiling.

polyspace-test -build -project <projectFile> -enable-debugger [options] builds the sources and tests in <projectFile> in debug mode. In this mode, breakpoints are associated with specific places in the test code before the test code is built. Later, when you run tests in the project, instead of normal execution, the tests open in a debugger at those breakpoints. For more information on supported debuggers, see Debug Test Failures from Polyspace Platform User Interface.

polyspace-test -build -options-file <optionsFile> builds a project using the options specified in <optionsFile>.

Examples

collapse all

Automate the building and running of the tests in a project file projectName.psprjx by using the polyspace-test command.

For an example of creating a project and adding sources and tests, see Write C/C++ Unit Tests in Polyspace Platform User Interface.

  1. Build a test executable to run all the tests included in a project file projectName.psprjx.

    polyspace-test -build -project projectName.psprjx

    The command generates the test executable and other artifacts and stores them in folder polyspace_artifacts.

  2. Run the tests and generate a results file.

    polyspace-test -run -project projectName.psprjx -results-dir resultsFolder

    The command runs all the tests and generates a .pstestr results file which is stored in the folder resultsFolder. When you use the -run command, if a test executable does not already exist, the software builds the tests and then runs them.

  3. Generate an XML report to capture a snapshot of the testing status.

    polyspace-test -report -report-dir reportFolder -xml resultsFolder
    The generated report is stored in a subfolder of the reportFolder folder.

Input Arguments

collapse all

Path to the Polyspace Platform project file (.psprjx file) that contains the tests that you want to build. polyspace-test uses the build and test configurations specified in the project unless you override the configurations. You can specify the file path as an absolute path or as a path relative to your working directory.

Example: -project "../project/myTestProject.psprjx"

Example: -project "C:\Users\jsmith\project\myTestProject.psprjx"

Code coverage specified as one of these values:

  • statement: The project is built for code profiling with only statement coverage enabled. See Statement Coverage.

  • decision — The project is built for code profiling with statement and decision coverage enabled. See Decision Coverage.

  • condition/decision — The project is built for code profiling with statement, decision and condition coverage enabled. See Condition Coverage.

  • mcdc — The project is built for code profiling with statement, decision, condition and MC/DC coverage enabled. See Modified Condition/Decision Coverage (MCDC) Coverage.

Example: -cov-metric-level decision

Path to text file containing options to use with the polyspace-test -build command. The file must contain one option per line.

Build Options

OptionDescription
-build-dir <buildFolderPath>

Specify a path <buildFolderPath> where Polyspace Test™ stores the build artifacts. You can specify an absolute path or a path relative to your working directory.

By default, Polyspace stores the build artifacts in the project artifacts folder, specified using the configuration option Artifacts directory.

-enable-portable-word-sizes

Use this option to compile your code on a host computer while retaining the word sizes of the target processor on which the code is intended to run.

For example, if your code runs on a 16-bit processor, the size of an integer is 16 bits. You can emulate this processor on a 64-bit host machine (where the size of an integer is 64 bits) by enabling this option.

-refresh-sourcesUse this option to update the content of a folder that is already added to the project before project build (in case source or test files were added to or removed from that folder).
-force-rebuild

Use this option to force full build of all sources in the project.

  • If you do not use this option, the project build takes previous build information into account and builds only those sources that changed since the previous build.

  • If you use this option, any existing build artifacts are removed before the project is built.

Project Override Options

OptionDescription
-build-config <configName>Specify the name of a build configuration variant to use instead of the current active build configuration of the project. For more information on configuration variants, see Create Configuration Variants.
-test-config <configName>Specify the name of a test configuration variant to use instead of the current active test configuration of the project. For more information on configuration variants, see Create Configuration Variants.
-var <var=value>Assign a value to variable var instead of the value specified in the project.
-board <targetName>

Specify the board to use instead of the board used in the active build configuration of the project.

-toolchain <toolchainName>

Specify the toolchain to use instead of the toolchain specified in the active build configuration of the project.

Version History

Introduced in R2023b