Polyspace Test xUnit tests fails to compile: fatal error: gtest/gtest.h

11 vues (au cours des 30 derniers jours)
Dan George
Dan George le 14 Avr 2024
Réponse apportée : David Jaffry le 12 Nov 2025 à 12:49
What parameter controls the C++ include file search path for my gtest test file?
Creating the project file with the python interface, I used (full python program listing attached):
buildConf.ExternalTestsBuildOptions.IncludePaths.add("/nix/store/pqyrsjax8n0wb4dxap66pf6ix6qdz34a-gtest-1.12.1-dev/include/")
This command attempts to build and run the test (mkproj.py attached):
python mkproj.py
That path does not seem to be included into the command line that compiles my test program:
### Building Polyspace Test xUnit tests
### Building for host
### Building 'testbin_sil'
### Using toolchain: GNU gcc/g++ | gmake (64-bit Linux)
...
g++ -c -fwrapv -fPIC -O0 -DPSTEST_BUILD -DPST_USER_CONFIG_FILE -DPST_MAX_NB_PARAMS=31 -I/home/dgeorge/ws/fsw_drivers/cadence_spi -I/home/dgeorge/ws/fsw_drivers/cadence_spi/include -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/extern/include -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/toolbox/polyspace/pstest/services/driver/host/c -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/polyspace/pstest/pstunit/include -I/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/polyspace/pstest/pstunit/src -o "pstunit.o" "/nix/store/33r3mf9k7h9f81pybwbhkqzbf9cycg3s-polyspace-installation-R2024a/polyspace/pstest/pstunit/src/pstunit.cpp"
/home/dgeorge/ws/fsw_drivers/cadence_spi/test_cadence_spi.cpp:6:10: fatal error: gtest/gtest.h: No such file or directory
6 | #include <gtest/gtest.h>
| ^~~~~~~~~~~~~~
Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.
Project file snippet (project file attached):
"ExternalTestsOptions": {
"content": {
"IncludePaths": {
"content": {
"IncludePaths": [
{
"content": {
"Path": {
"content": {
"Value": "/nix/store/pqyrsjax8n0wb4dxap66pf6ix6qdz34a-gtest-1.12.1-dev/include"
Directory contents:
$ ls /nix/store/pqyrsjax8n0wb4dxap66pf6ix6qdz34a-gtest-1.12.1-dev/include/gtest
gtest-assertion-result.h gtest-matchers.h gtest-param-test.h gtest-spi.h gtest-typed-test.h gtest_pred_impl.h internal
gtest-death-test.h gtest-message.h gtest-printers.h gtest-test-part.h gtest.h gtest_prod.h
  1 commentaire
Dan George
Dan George le 14 Avr 2024
The "workaround" is to put it into the plain buildConfig.IncludePaths. Perhaps this is not a workaround and is the proper placement.
What is the intended purpose of ExternalTestsBuildOptions?

Connectez-vous pour commenter.

Réponses (1)

David Jaffry
David Jaffry le 12 Nov 2025 à 12:49
Hello,
The main issue was actually adding the GTest test under "Polyspace xUnit Test" instead of "External Test Files".
The ExternalTestsBuildOptions setting is specifically intended to support external xUnit test frameworks—such as GTest—in addition to the Polyspace xUnit Test Framework. This allows you to integrate and run tests from other frameworks within the Polyspace environment. You can find more details in the documentation here:
Let me know if you need further clarification!

Produits


Version

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by