Main Content

Configure Project for Testing in Polyspace Platform User Interface

You can author, build and run C/C++ tests in the Polyspace Platform user interface. When you build a project in the Polyspace® Platform user interface, Polyspace Test compiles the test code together with your source files into executables that are executed later when you run the tests. This build happens in two steps and requires you to specify a Host Compiler and User Compiler. You specify the host compiler in your Polyspace Platform Settings and use the project configuration to specify the user compiler and related information like compiler flags, include paths and defines.

A Polyspace Platform project configuration consists of these sets of options:

  • Project-specific configuration — Project-wide options

  • Build configuration — Options that specify how to build your code and tests

  • Static analysis configuration — Options specific to static analyses

  • Testing and profiling configuration — Options that specify how to test and profile your code

You can specify sets of distinct build, testing, and static analysis configurations. These sets are configuration variants. A Polyspace Platform project supports multiple variants of build, testing, and static analysis configurations. For each configuration variant, you can choose whether it is part of the project (saved in the .psprjx file) or is saved in an external configuration file (.pscfg) that is referenced by the project. Using external configurations can improve source control managed workflows by allowing you to modularize your project and enables the sharing of single-sourced build, static analysis, and testing configurations across similar projects. You cannot create variants for the project-specific configuration options. The project options apply to all configuration variants and are always saved in the .psprjx project file.

Set Up Configuration

To open your configuration, on the Projects pane, double-click the Configuration node of your project.

Configuration node in project tree

The configuration opens on a separate Configuration pane. The Configuration pane contains these tabs:

  • Project — The options on this tab includes various options that apply to the entire project. These options are relevant to both static analysis and dynamic testing. You cannot create variants for these options.

    For more information on the options, see Project Creation.

  • Build — The options on this tab cover both static analysis and dynamic testing.

    Only a subset of the options on the Target & Compiler node apply to Polyspace Test™. The remaining options on this and other nodes apply only to the static analysis tools, Polyspace Bug Finder™ and Polyspace Code Prover™.

    For more information on the options, see Test Execution in Polyspace Platform User Interface.

  • Static Analysis — The options on this tab do not apply to Polyspace Test. For more information on these options, see:

  • Testing & Profiling — The options on this tab apply only to Polyspace Test. Using these options, you can specify certain aspects of testing and profiling such as code coverage metrics and folders to exclude from profiling.

    For more information on the options, see Code Profiling in Polyspace Platform User Interface.

You can also find individual options on the Configuration pane through search if you know the option name. For instance, if you search for the term Compilation toolchain, you can find two matches on the Build tab corresponding to these two options:

  • Compilation toolchain (Static analysis)

  • Compilation toolchain (Testing)

Note that you can search for options on the Static Analysis Tab by their command-line name in addition to the name that appears in the user interface. For instance, you can search for the option Constraint setup by its command-line equivalent -data-range-specifications. For more information on this option, see Constraint setup (-data-range-specifications) (Polyspace Code Prover).

Searching for the option 'Compilation toolchain' shows two instances on the Build tab of the Configuration pane.

Once you locate an option, you can use contextual help to find more information about an option. Hover on the option to see a tooltip describing the option or click More Help in the tooltip to open the documentation for the option.

Create Configuration Variants

You can create multiple configuration variants for build, testing, or static analysis options for specific goals and switch between them within the same project. For example, you can create different configuration variants to use different compilers, or to check for different code coverage metrics.

To create new configuration variants in your project:

  1. Open your project configuration.

  2. On the Polyspace Platform toolstrip, click New.

    Menu showing options to create a new build configuration, to create a new static analysis configuration, and to create a new testing and profiling configuration

    Select the type of configuration variant you want to create. For example, select New Build Configuration to create a build configuration variant.

  3. Set options as needed. For example, set Compilation toolchain (testing) as MinGW64| CMake/Ninja (64-bit Windows) and select Enable portable word sizes.

  4. Click edit button to rename the configuration variant.

  5. Optionally, add a description for the configuration variant. The description of a build configuration appears in the Environment Information section of test reports, allowing you to identify which configuration variant was used for testing.

Instead of creating a configuration variant from scratch, you can also duplicate an existing configuration variant:

  1. Select the configuration variant that you want to duplicate.

    Drop-down list showing the user-defined build configurations

  2. Select Duplicate on the toolstrip.

To remove a configuration variant, select the variant and then select Delete on the toolstrip.

Switch Between Configuration Variants

Once you have more than one variant in your project, you can switch to a different configuration variant. To switch to a configuration variant:

  1. Select the variant using the drop-down lists in the configuration tabs.

    Drop-down list showing the user-defined build configurations

  2. To use the selected variant as part of the active configuration, select Make Active on the toolstrip.

The configuration variant that is currently active has a green Active label on the top right. All other variants have a gray Inactive label in the same location. External configurations that are saved in a .pscfg file that is referenced by the project have a blue External label next to the Active or Inactive label.

You can select different configuration variants when running your Polyspace Test project at the command line using the polyspace-test command. See polyspace-test -build or polyspace-test -run.

Share and Reuse Configuration Variants

There are two ways to share or reuse configuration variants across projects:

  • To share a single-sourced configuration variant across similar projects, use external configurations. An external configuration is a build, static analysis, or testing and profiling configuration that you save in a .pscfg file and link to one or more projects by reference. To use the shared configuration in another project, import the .pscfg file as an external configuration. When you make changes to that external configuration file, all projects that reference it inherit those changes.

  • To reuse a copy of a configuration variant, export a copy of the configuration to a .pscfg file and then import a copy of that file into another project. In this workflow, the imported configuration is saved as a part of the .psprjx project file. Any modifications you make to the configuration variant in one project do not impact other projects.

In a continuous integration workflow, submit the .pscfg configuration files to a version control system as you would with other text files. Before submission, compare and merge your version of a configuration with the version in the repository using the diff/merge tool. For more details on the diff/merge tool, see Compare and Merge Polyspace Platform Projects and Configurations Before Submission to Source Control.

Use External Configurations to Improve Sharing and Version Control Workflows

To create a modular project or share single-sourced configuration variants across multiple projects, use external configurations. For more information about working with external configurations, see Modularize Project by Converting Configurations to External Configurations in Polyspace Platform User Interface.

Import and Export Copies of Configuration Variants

To reuse a copy of a configuration variant across projects, export a copy of the configuration variant to a .pscfg file and then import a copy of the .pscfg file into another project. To compare different versions of a configuration file, use the diff/merge tool. For more information, see Compare and Merge Polyspace Platform Projects and Configurations Before Submission to Source Control.

Export Copy of Configuration Variant.  To export a copy of a specific configuration variant from your project:

  1. Open your project configuration.

  2. Navigate to the tab from which you want to export the configuration:

    • Build — Export a build configuration variant

    • Static Analysis — Export a static analysis configuration variant

    • Testing & Profiling — Export a testing and profiling configuration variant

  3. On the Polyspace Platform toolstrip, click Export to export a copy of the currently selected configuration as a .pscfg file.

    Menu showing options to export the current configuration to a file, to export active configurations to files, and to export all configurations to files

  4. Specify a filename and location and click Save.

To export a copy of all active configurations as .pscfg files, select Export Active Configurations. Alternatively, you can export copies of all configuration variants in your project by selecting Export All Configurations.

Import Copy of Configuration Variant.  To import a copy of one or more configuration variants into your project, click Import and select one or more Polyspace configuration files. This imports a copy of all the configurations you select and saves those copies in the .psprjx project file. To use one of the imported configuration variants, select it from the drop-down list and click Make Active in the toolstrip.

To import a configuration variant by referencing an external configuration file, see Import External Configuration.

See Also

|

Topics