From 056be99a908f23f78e66278bd560c55fbd02d9df Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Tue, 3 Dec 2024 19:39:56 -0800 Subject: [PATCH] BaseTools/Plugin/HostBasedUnitTestRunner: Set ASAN env vars The environment variable `GTEST_CATCH_EXCEPTION` must be set to `0` for so all exceptions are handled by the address sanitizer and not GoogleTest. This allows stack back trace and other details to be logged by the address sanitizer so the source of the issue identified address sanitizer can be determined. The environment variable `ASAN_OPTIONS` must be set to `detect_leaks=0` to disable memory leak detection. The unit test frameworks may have memory leaks and some firmware code under test use cases may perform a memory allocation without a matching memory free as their expected behavior. Signed-off-by: Michael D Kinney --- .../HostBasedUnitTestRunner/HostBasedUnitTestRunner.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py index b7ed863203af3..c39dae236c9bd 100644 --- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py +++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py @@ -52,6 +52,12 @@ def do_post_build(self, thebuilder): failure_count = 0 + # Do not catch exceptions in gtest so they are handled by address sanitizer + shell_env.set_shell_var('GTEST_CATCH_EXCEPTIONS', '0') + + # Disable address sanitizer memory leak detection + shell_env.set_shell_var('ASAN_OPTIONS', 'detect_leaks=0') + # Set up the reporting type for Cmocka. shell_env.set_shell_var('CMOCKA_MESSAGE_OUTPUT', 'xml')