[Bf-blender-cvs] [e7c1a32a780] master: Tests: disable ASAN when discovering tests

Sybren A. Stüvel noreply at git.blender.org
Thu Jul 16 17:50:42 CEST 2020


Commit: e7c1a32a7806977beb74f5d20c965949162b12b5
Author: Sybren A. Stüvel
Date:   Thu Jul 16 17:22:58 2020 +0200
Branches: master
https://developer.blender.org/rBe7c1a32a7806977beb74f5d20c965949162b12b5

Tests: disable ASAN when discovering tests

CMake, when it's configuring the project, runs the `blender_test` test
runner (if it exists from a previous build) to discover which tests it
contains. At this time none of the tests themselves are run, so it's not
that useful to run ASAN and have it break things when there are memory
leaks.

This commit disables ASAN by injecting `ASAN_OPTIONS="detect_leaks=0"` in
the environment variables.

It is not enough to use `set(ENV{ASAN_OPTIONS} "detect_leaks=0")` in
`tests/gtests/runner/CMakeLists.txt`, as it wouldn't be passed to the child
process.

===================================================================

A	tests/gtests/runner/BlenderAddTests.cmake
M	tests/gtests/runner/CMakeLists.txt

===================================================================

diff --git a/tests/gtests/runner/BlenderAddTests.cmake b/tests/gtests/runner/BlenderAddTests.cmake
new file mode 100644
index 00000000000..c4f5c8aba8a
--- /dev/null
+++ b/tests/gtests/runner/BlenderAddTests.cmake
@@ -0,0 +1,3 @@
+# Disable ASAN leak detection when trying to discover tests.
+set(ENV{ASAN_OPTIONS} "detect_leaks=0")
+include(GoogleTestAddTests)
diff --git a/tests/gtests/runner/CMakeLists.txt b/tests/gtests/runner/CMakeLists.txt
index 7f28ede9ae9..4da0bce09a4 100644
--- a/tests/gtests/runner/CMakeLists.txt
+++ b/tests/gtests/runner/CMakeLists.txt
@@ -60,6 +60,11 @@ setup_liblinks(blender_test)
 # exposes those tests individually to the ctest runner.
 # See https://cmake.org/cmake/help/v3.18/module/GoogleTest.html
 include(GoogleTest)
+
+set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT
+  ${CMAKE_CURRENT_LIST_DIR}/BlenderAddTests.cmake
+)
+
 gtest_discover_tests(blender_test
   # So that unit tests know where to find files:
   EXTRA_ARGS



More information about the Bf-blender-cvs mailing list