diff --git a/compiler-rt/lib/gwp_asan/tests/harness.h b/compiler-rt/lib/gwp_asan/tests/harness.h --- a/compiler-rt/lib/gwp_asan/tests/harness.h +++ b/compiler-rt/lib/gwp_asan/tests/harness.h @@ -15,6 +15,13 @@ #define ZXTEST_USE_STREAMABLE_MACROS #include namespace testing = zxtest; +// zxtest defines a different ASSERT_DEATH, taking a lambda and an error message +// if death didn't occur, versus gtest taking a statement and a string to search +// for in the dying process. zxtest doesn't define an EXPECT_DEATH, so we use +// that in the tests below (which works as intended for gtest), and we define +// EXPECT_DEATH as a wrapper for zxtest's ASSERT_DEATH. Note that zxtest drops +// the functionality for checking for a particular message in death. +#define EXPECT_DEATH(X, Y) ASSERT_DEATH(([&] { X; }), "") #else #include "gtest/gtest.h" #endif diff --git a/compiler-rt/lib/gwp_asan/tests/never_allocated.cpp b/compiler-rt/lib/gwp_asan/tests/never_allocated.cpp --- a/compiler-rt/lib/gwp_asan/tests/never_allocated.cpp +++ b/compiler-rt/lib/gwp_asan/tests/never_allocated.cpp @@ -25,7 +25,7 @@ // in the posix crash handler. char *volatile NeverAllocatedPtr = static_cast(Ptr) + 0x3000; if (!Recoverable) { - ASSERT_DEATH(*NeverAllocatedPtr = 0, DeathNeedle); + EXPECT_DEATH(*NeverAllocatedPtr = 0, DeathNeedle); return; }