Skip to content

Commit

Permalink
Disable exception with message test if using memory sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
facug91 authored and sheredom committed Aug 17, 2023
1 parent 2e2fc58 commit 369a57c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/test11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ UTEST(cpp11, Near) {
ASSERT_NEAR(a, b, 0.01f);
}

// GCC stdlib has a sanitizer bug in exceptions!
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#define MEMORY_SANITIZER
#endif
#endif

static int foo(int bar) {
if (bar == 1)
throw std::range_error("bad bar");
Expand All @@ -276,10 +283,12 @@ UTEST(cpp11, Exception) {
ASSERT_EXCEPTION(foo(1), std::range_error);
}

#if !defined(MEMORY_SANITIZER)
UTEST(cpp11, ExceptionWithMessage) {
EXPECT_EXCEPTION_WITH_MESSAGE(foo(1), std::range_error, "bad bar");
ASSERT_EXCEPTION_WITH_MESSAGE(foo(1), std::range_error, "bad bar");
}
#endif

UTEST(cpp11, Todo) { UTEST_SKIP("Not yet implemented!"); }

Expand Down
9 changes: 9 additions & 0 deletions test/test14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ UTEST(cpp14, Near) {
ASSERT_NEAR(a, b, 0.01f);
}

// GCC stdlib has a sanitizer bug in exceptions!
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#define MEMORY_SANITIZER
#endif
#endif

static int foo(int bar) {
if (bar == 1)
throw std::range_error("bad bar");
Expand All @@ -276,10 +283,12 @@ UTEST(cpp14, Exception) {
ASSERT_EXCEPTION(foo(1), std::range_error);
}

#if !defined(MEMORY_SANITIZER)
UTEST(cpp14, ExceptionWithMessage) {
EXPECT_EXCEPTION_WITH_MESSAGE(foo(1), std::range_error, "bad bar");
ASSERT_EXCEPTION_WITH_MESSAGE(foo(1), std::range_error, "bad bar");
}
#endif

UTEST(cpp14, Todo) { UTEST_SKIP("Not yet implemented!"); }

Expand Down
9 changes: 9 additions & 0 deletions test/test17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ UTEST(cpp17, Near) {
ASSERT_NEAR(a, b, 0.01f);
}

// GCC stdlib has a sanitizer bug in exceptions!
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#define MEMORY_SANITIZER
#endif
#endif

static int foo(int bar) {
if (bar == 1)
throw std::range_error("bad bar");
Expand All @@ -276,10 +283,12 @@ UTEST(cpp17, Exception) {
ASSERT_EXCEPTION(foo(1), std::range_error);
}

#if !defined(MEMORY_SANITIZER)
UTEST(cpp17, ExceptionWithMessage) {
EXPECT_EXCEPTION_WITH_MESSAGE(foo(1), std::range_error, "bad bar");
ASSERT_EXCEPTION_WITH_MESSAGE(foo(1), std::range_error, "bad bar");
}
#endif

UTEST(cpp17, Todo) { UTEST_SKIP("Not yet implemented!"); }

Expand Down

0 comments on commit 369a57c

Please sign in to comment.