Skip to content

Commit

Permalink
pw_unit_test: Silence ASAN error in TestInfo
Browse files Browse the repository at this point in the history
Fix: b/218900279
Change-Id: I8d73c69dc3165e3a784fd70f35031b051987a57b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/185654
Commit-Queue: Taylor Cramer <[email protected]>
Reviewed-by: Alexei Frolov <[email protected]>
  • Loading branch information
cramertj authored and CQ Bot Account committed Dec 20, 2023
1 parent 741fdc6 commit 36bf818
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,12 @@ inline void SetTestSuitesToRun(span<std::string_view> test_suites) {
test_suite_name##_##test_name##_Test, \
parent_class)

#if PW_HAVE_ATTRIBUTE(no_sanitizer)
#define PW_NO_SANITIZER(...) __attribute__((no_sanitizer(__VA_ARGS__)))
#else
#define PW_NO_SANITIZER(...)
#endif

#define _PW_TEST_CLASS(suite, name, class_name, parent_class) \
class class_name final : public parent_class { \
private: \
Expand All @@ -788,6 +794,10 @@ inline void SetTestSuitesToRun(span<std::string_view> test_suites) {
\
extern "C" { \
\
/* Silence ASAN to avoid errors in the initialization order checker */ \
/* caused by the intentional use of dynamic initializers which modify */ \
/* other globals */ \
PW_NO_SANITIZER("address") \
/* Declare the TestInfo as non-const since const variables do not work */ \
/* with the PW_UNIT_TEST_LINK_FILE_CONTAINING_TEST macro. */ \
/* NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) */ \
Expand Down

0 comments on commit 36bf818

Please sign in to comment.