Skip to content

Commit

Permalink
Detect enabled GCC/Clang sanitizers
Browse files Browse the repository at this point in the history
Occasionally we want tests to take advantage of sanitizers, or work around
them.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
  • Loading branch information
gilles-peskine-arm committed Nov 22, 2023
1 parent b9c7058 commit c3a9bdb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/include/test/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
#include MBEDTLS_CONFIG_FILE
#endif

#if defined(__SANITIZE_ADDRESS__) /* gcc -fsanitize=address */
# define MBEDTLS_TEST_HAVE_ASAN
#endif
#if defined(__has_feature)
# if __has_feature(address_sanitizer) /* clang -fsanitize=address */
# define MBEDTLS_TEST_HAVE_ASAN
# endif
# if __has_feature(memory_sanitizer) /* clang -fsanitize=memory */
# define MBEDTLS_TEST_HAVE_MSAN
# endif
# if __has_feature(thread_sanitizer) /* clang -fsanitize=thread */
# define MBEDTLS_TEST_HAVE_TSAN
# endif
#endif

#if defined(MBEDTLS_THREADING_C) && defined(MBEDTLS_THREADING_PTHREAD) && \
defined(MBEDTLS_TEST_HOOKS)
#define MBEDTLS_TEST_MUTEX_USAGE
Expand Down

0 comments on commit c3a9bdb

Please sign in to comment.