Skip to content

Commit

Permalink
asan: fix for clang not successfully ignoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Jul 18, 2024
1 parent e0a1cd4 commit bc9f057
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/unit-tests/test_udev_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
#include <poll.h>
#include <sys/sysmacros.h>

#if defined(__has_feature)
# if __has_feature(address_sanitizer) // for clang
# define __SANITIZE_ADDRESS__ // GCC already sets this
# endif
#endif

namespace mtf=mir_test_framework;

namespace
Expand Down Expand Up @@ -318,7 +324,10 @@ typedef UdevWrapperTest UdevWrapperDeathTest;

TEST_F(UdevWrapperDeathTest, DereferencingEndReturnsInvalidObject)
{
#if !defined(__SANITIZE_ADDRESS__)
#if defined(__SANITIZE_ADDRESS__)
(void)udev_environment;
(void)KilledByInvalidMemoryAccess;
#else
::testing::FLAGS_gtest_death_test_style = "threadsafe";
udev_environment.add_device("drm", "control64D", NULL, {}, {});
udev_environment.add_device("drm", "card1", NULL, {}, {});
Expand Down Expand Up @@ -355,9 +364,7 @@ TEST_F(UdevWrapperTest, MemberDereferenceWorks)

TEST_F(UdevWrapperDeathTest, MemberDereferenceOfEndDies)
{
#if defined(__SANITIZE_ADDRESS__)
(void)KilledByInvalidMemoryAccess;
#else
#if !defined(__SANITIZE_ADDRESS__)
::testing::FLAGS_gtest_death_test_style = "threadsafe";
udev_environment.add_device("drm", "control64D", NULL, {}, {});
udev_environment.add_device("drm", "card1", NULL, {}, {});
Expand Down

0 comments on commit bc9f057

Please sign in to comment.