Set sanitizer environment variables before launching catkin tests

asked 2022-02-10 03:25:44 -0500

mwilliams gravatar image

Hi everyone!

I'm trying to run unit tests using the catkin_add_gmock CMake function and with gcc's address/undefined behaviour/leak or thread santizers enabled. Due to errors detected by the sanitizers in third party code I have a suppression file to suppress these errors.

To pass the suppression file to the sanitizers, I have to define certain environment variables such as ASAN_OPTIONS, TSAN_OPTIONS etc.

I can of course define these environment variable before running the tests , for example

export TSAN_OPTIONS="suppressions=tsan_suppressions"
catkin_make run_tests_foo

but I would really like these variables to be declared automatically when doing the catkin_make run_tests_foo command, and so I have tried to set the environment variables in CMake. But I cannot find a way of injecting these environment variables before running catkin tests.

Does anyone know if this is possible?

I'm using ROS Melodic on Ubuntu 18.04 with cmake 3.18.0 and gcc 7.5.0.

edit retag flag offensive close merge delete