Contenu principal

Changes to Self-Managed Build Workflows in Polyspace Test in R2026b

R2026b

Starting in R2026b, for self-managed builds, you can compile a single file, pstest.c, to obtain all definitions required to use Polyspace® Test™. Prior to this release, you had to compile a file pstunit.c for xUnit API macro definitions and psprofile.c for source code profiling.

For specific workflows, you can selectively exclude parts of pstest.c by defining specific macros at compile time. For instance, when compiling xUnit tests on host with no requirements for source code profiling, define PSTEST_RUNTIME_WITHOUT_PROFILING as 1 at compile time. This excludes the profiling portion of the file pstest.c from compilation.

This topic lists some of the updates you need to make in your build scripts to accommodate this change.

Common Build Tasks for Host-Based Execution

The following sections shows the updates you need for some common build tasks on a host machine. The list uses gcc as compile command in shell scripts.

Compiling xUnit Tests Only

If your previous compile command was the following:

# Set paths
PSTUNIT_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstunit.c
PSTUNIT_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include

# Compile sources, tests and Polyspace Test files
gcc src.c tests.c $PSTUNIT_SOURCE -I $PSTUNIT_INCLUDE
You can retain the overall structure of these commands and simply replace pstunit.c with pstest.c. Alternatively, if you are not interested in source code profiling, you can replace with:
# Set paths
PSTEST_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstest.c
PSTEST_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include

# Compile sources, tests and Polyspace Test files
gcc src.c tests.c $PSTEST_SOURCE -I $PSTEST_INCLUDE -D PSTEST_RUNTIME_WITHOUT_PROFILING=1

A diff view of a pre-R2026b and R2026b script is given below.

Host build script diff showing PSTUNIT paths replaced by PSTEST paths with PSTEST_RUNTIME_WITHOUT_PROFILING compile flag added

Source Code Profiling

Suppose your previous source code instrumentation and compile commands were the following. After instrumenting sources and compiling the instrumented sources and tests, you linked the objects to a precompiled library containing the definitions of profiling macros (available only for specific compilers).

# Set paths
PSTUNIT_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstunit.c
PSTUNIT_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include
PSPROFILE_LIB=POLYSPACEROOT/polyspace/psprofile/lib/glnxa64/static/libmwpsprofile_cli_runtime.a

# Instrument sources, and compile instrumented sources
polyspace-code-profiler -instrument -instrum-dir instrums -- gcc -c src.c

# Compile tests and Polyspace Test files
gcc -c tests.c -I $PSTUNIT_INCLUDE
gcc -c $PSTUNIT_SOURCE  # Leads to pstunit.o

# Link objects with precompiled library
gcc src.o tests.o pstunit.o $PSPROFILE_LIB
You can make the following modifications to continue source code profiling using the precompiled library:
# Set paths
PSTEST_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstest.c
PSTEST_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include
PSTEST_LIB=POLYSPACEROOT/polyspace/pstest/runtime/lib/glnxa64/static/libmwpstest_runtime.a

# Instrument sources and compile instrumented sources
polyspace-code-profiler -instrument -instrum-dir instrums -- gcc -c src.c

# Compile tests and Polyspace Test files
gcc -c tests.c -I $PSTEST_INCLUDE
gcc -c $PSTEST_SOURCE -D PSTEST_RUNTIME_AS_STATIC_LIBRARY=1 # Leads to pstest.o

# Link objects with precompiled library
gcc src.o tests.o pstest.o $PSTEST_LIB

A diff view of a pre-R2026b and R2026b script is given below.

Host profiling script diff showing PSTUNIT and PSPROFILE paths replaced by PSTEST paths with PSTEST_RUNTIME_AS_STATIC_LIBRARY flag

Common Build Tasks for Target-Based Execution

The following list shows the updates you need for some common build tasks on a target.

In workflows for on-target builds, you need to define a configuration file and refer to the configuration file by defining a compile-time macro (you can also follow this strategy for source code profiling on hosts if the precompiled libraries do not work for you). The list uses the dcc command, which runs the Wind River® Diab compiler, as compile command in shell scripts and uses -D PST_USER_CONFIG (previously PST_USER_CONFIG_FILE) to indicate the configuration file use.

Compiling xUnit Tests Only

Suppose your previous compile command was the following:

# Set paths
PSTUNIT_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstunit.c
PSTUNIT_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include
PSPROFILE_INCLUDE=POLYSPACEROOT/polyspace/psprofile/include
CONFIG_INCLUDE=# Add folder containing configuration file, pstunit_config.h
CONFIG_SOURCE=# Add path to file config.c containing definitions of functions declared in pstunit_config.h

# Compile sources, tests, Polyspace Test files and configuration files
dcc -c src.c 
dcc -c tests.c -I $PSTUNIT_INCLUDE
dcc -c $PSTUNIT_SOURCE -D PST_USER_CONFIG_FILE -I $CONFIG_INCLUDE # Leads to pstunit.o
dcc -c $CONFIG_SOURCE -I $CONFIG_INCLUDE -I $PSPROFILE_INCLUDE # Leads to config.o, PSPROFILE_INCLUDE needed for streaming functions

# Link objects
dcc src.o tests.o pstunit.o config.o

You can make the following modifications:

# Set paths
PSTEST_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstest.c
PSTEST_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include
PSPROFILE_INCLUDE=POLYSPACEROOT/polyspace/psprofile/include
CONFIG_INCLUDE=# Add folder containing configuration file, pstest_config.h
CONFIG_SOURCE=# Add path to file config.c containing definitions of functions declared in pstest_config.h

# Compile sources, tests, Polyspace Test files and configuration files
dcc -c src.c 
dcc -c tests.c -I $PSTEST_INCLUDE
dcc -c $PSTEST_SOURCE -D PSTEST_RUNTIME_WITHOUT_PROFILING=1 -D PST_USER_CONFIG -I $CONFIG_INCLUDE # Leads to pstest.o
dcc -c $CONFIG_SOURCE -I $CONFIG_INCLUDE -I $PSPROFILE_INCLUDE # Leads to config.o, PSPROFILE_INCLUDE needed for streaming functions

# Link objects
dcc src.o tests.o pstest.o config.o

A diff view of a pre-R2026b and R2026b script is given below.

Target build script diff showing PSTUNIT paths replaced by PSTEST paths with PSTEST_RUNTIME_WITHOUT_PROFILING and PST_USER_CONFIG flags

Source Code Profiling

Suppose your previous source code instrumentation and compile commands were the following:

# Set paths
PSTUNIT_SOURCE=POLYSPACEROOT/polyspace/pstest/pstunit/src/pstunit.c
PSTUNIT_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include
PSPROFILE_SOURCE=POLYSPACEROOT/polyspace/psprofile/src/psprofile.c
PSPROFILE_INCLUDE=POLYSPACEROOT/polyspace/psprofile/include
CONFIG_INCLUDE=# Add folder containing configuration file, pstunit_config.h and psprofile_config.h
CONFIG_SOURCE=# Add path to file config.c containing definitions of functions declared in pstunit_config.h and psprofile_config.h

# Instrument sources and compile instrumented sources
polyspace-code-profiler -instrument -instrum-dir instrums -- dcc -c src.c

# Compile tests, Polyspace Test files and configuration files
dcc -c tests.c -I $PSTUNIT_INCLUDE
dcc -c $PSTUNIT_SOURCE -D PST_USER_CONFIG_FILE -I $CONFIG_INCLUDE # Leads to pstunit.o
dcc -c $PSPROFILE_SOURCE -D PST_USER_CONFIG_FILE -I $CONFIG_INCLUDE # Leads to psprofile.o
dcc -c $CONFIG_SOURCE -I $CONFIG_INCLUDE -I $PSPROFILE_INCLUDE # Leads to config.o, PSPROFILE_INCLUDE needed for streaming functions

# Link objects
dcc src.o tests.o pstunit.o psprofile.o config.o
You can make the following modifications:
# Set paths
PSTEST_SOURCE= POLYSPACEROOT/polyspace/pstest/pstunit/src/pstest.c
PSTEST_INCLUDE=POLYSPACEROOT/polyspace/pstest/pstunit/include
PSPROFILE_INCLUDE=POLYSPACEROOT/polyspace/psprofile/include
CONFIG_INCLUDE=# Add folder containing configuration file, pstest_config.h
CONFIG_SOURCE=# Add path to file config.c containing definitions of functions declared in pstest_config.h

# Instrument sources and compile instrumented sources
polyspace-code-profiler -instrument -instrum-dir instrums -- dcc -c src.c

# Compile tests, Polyspace Test files and configuration files
dcc -c tests.c -I $PSTEST_INCLUDE
dcc -c $PSTEST_SOURCE -D PST_USER_CONFIG -I $CONFIG_INCLUDE # Leads to pstest.o
dcc -c $CONFIG_SOURCE -I $CONFIG_INCLUDE -I $PSPROFILE_INCLUDE # Leads to config.o, PSPROFILE_INCLUDE needed for streaming functions

# Link objects
dcc src.o tests.o pstest.o config.o

A diff view of a pre-R2026b and R2026b script is given below.

Target profiling script diff showing PSTUNIT and PSPROFILE sources consolidated into single PSTEST source with PST_USER_CONFIG flag