Contenuto principale

Run C/C++ Tests on Target in Polyspace Platform User Interface

In the context of test execution in Polyspace® Test™, the word target refers to embedded systems with specific processor architecture, cross-compilation tools, and channels for communication with a host computer.

You can run both graphical and xUnit tests added to a Polyspace Platform project on a custom target. The steps to execute tests on targets are similar to the steps to execute tests on a host computer. However, you must perform a one-time setup to register your target in the Polyspace Platform user interface. Registering a target involves writing a custom target registration file that defines one or more of the following:

  • Toolchain – Cross-compiler, build tool, and so on.

  • Board and processor – Board/processor name, data type support, timer functions, and so on.

  • Communication specifics – Channel, protocol, and so on.

This steps below outline the workflow for test execution on targets in the Polyspace Platform user interface. For a simple example using this workflow, see Get Started with C/C++ Test Execution on Target.

Overview

If you were to run tests on a target outside the Polyspace Platform user interface, you would typically perform these steps:

  1. Build a test executable for the target using a cross-compiler.

  2. Establish communication with the target.

  3. Run the test executable on the target and retrieve test results.

  4. Convert the test results to a human-readable format.

In the Polyspace Platform user interface, once you have registered your target, these steps are automatically managed during test execution. To execute tests on a target board, you follow the same steps as if you were executing the tests on your host computer.

Write Target Registration File

A target registration file is a MATLAB® code file that defines a target using classes from the Target Framework MATLAB API.

Although the target registration file uses MATLAB code, you can author the file in any text editor. You do not need an installation of MATLAB to author this file or use the file later for target registration in Polyspace Test. However, the editors in MATLAB or MATLAB Online provide better support for authoring the file with features such as syntax highlighting and code completions.

For more information on creating this file, see:

For an example file, see Get Started with C/C++ Test Execution on Target.

Note that if your target comprises of only a toolchain for host execution, instead of authoring a MATLAB code file, you can also enter toolchain information in an app in the Polyspace Platform user and register the toolchain in the app. For more information, see Toolchain.

Register Target in Polyspace Platform User Interface

To register a target using the previously authored target registration file:

  1. On the Polyspace Platform toolstrip, select Mange Boards button in the Prepare section, and then select Manage Boards.

    Alternatively, on the Polyspace Platform toolstrip, select Settings. On the Testing & Profiling tab, select Manage Boards.

  2. In the Manage Boards window, select Register a target.

  3. Navigate to the target registration file and select the file. If your registration file is valid, your target appears in the list of target boards.

You can override some properties related to your target connection without having to create an entirely new target and registering the new target. On the Manage Boards window, click the Configure board connection icon next to the target name. Modify the connection to the board as needed. For instance, you can change the parity of the serial connection to the board.

Configure board connection properties such as baud rate, parity and port.

To unregister the target, follow similar steps.

  1. On the Polyspace Platform toolstrip, select Mange Boards button in the Prepare section, and then select Manage Boards.

  2. In the Manage Boards window, select Unregister a target.

  3. Navigate to the target unregistration file and select the file. If your file for unregistering the target is valid, your target is removed from the list of target boards.

Select Target in Project Configuration

After registering a target, you can select the target from any project in the Polyspace Platform user interface:

  1. Double-click the Configuration node of your project to open the project configuration.

  2. On the Build tab, select Target & Compiler and then from the Target board name (Testing) list, select the previously registered target. For more information on this option, see Target board name (Testing).

    If your target registration file defines a processor and toolchain, these configuration options have the values defined in your target registration file:

  3. Select Test Connection.

    This action builds and runs a simple test on the target that you registered and confirms whether the connection is successful. The action is equivalent to running -check All with the command polyspace-test -check-target-package.

Override Toolchain Options in Configuration (Optional)

Sometimes, to emulate your command-line build in a particular project, you might want to define compiler flags, build flags, and other such flags that are different from those defined in your target registration file. Instead of registering a new target with the updated flags and using the new target in the project, you can simply add these flags as an override to an existing target in your project configuration. During project build, these flags override the equivalent flags defined in your toolchain registration file.

To add custom toolchain flags:

  1. Open your project configuration.

  2. Select your toolchain from the Compilation toolchain (Testing) list. Click Settings icon next to the option.

  3. Select Enable toolchain customization. The Configure toolchain options window shows the default command-line flags. Modify the flags as necessary to emulate your command-line build.

    Typical options for a CMake based toolchain

Build and Run Tests on Target

Once you configure your project with your target, you can run tests on the target:

  1. Build your project by clicking Build Project in the toolstrip. Polyspace Test builds a test executable appropriate for your target.

  2. Run the tests by clicking Run Tests in the toolstrip. Polyspace Test executes the test executable on the target and gathers the test results.

The test results on target appear on the Results pane. From this pane, you can open a dashboard with an overview of passing and failing tests, or the complete list of tests with their pass/fail status. See Review C/C++ Test Execution Results.

See Also

| |

Topics