summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaslyn Tonelli <caslyn@google.com>2023-04-19 02:32:12 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-19 02:32:12 +0000
commite25d098ba5558facba64107f9383466ed0a52848 (patch)
tree2b94fc60a93247d1e8b0239e1811e739ca0402b1
parent4f51f2b289dbba3ee1d4b0afd7524b3d1cd58b61 (diff)
parente7ec6a33615d70282018c886be5f3793fca6e665 (diff)
downloadgwp_asan-e25d098ba5558facba64107f9383466ed0a52848.tar.gz
[gwp_asan] Employ EXPECT_DEATH for zxtest compatibility am: 343a3e1fbc am: 3d67343ede am: e282e18bc8 am: e7ec6a3361
Original change: https://android-review.googlesource.com/c/platform/external/gwp_asan/+/2544985 Change-Id: Ia883d4134b5a5e3f26d64b0e64d6bb4d787518dd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--gwp_asan/tests/harness.h7
-rw-r--r--gwp_asan/tests/never_allocated.cpp2
2 files changed, 8 insertions, 1 deletions
diff --git a/gwp_asan/tests/harness.h b/gwp_asan/tests/harness.h
index 3e85935..ae39a44 100644
--- a/gwp_asan/tests/harness.h
+++ b/gwp_asan/tests/harness.h
@@ -15,6 +15,13 @@
#define ZXTEST_USE_STREAMABLE_MACROS
#include <zxtest/zxtest.h>
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/gwp_asan/tests/never_allocated.cpp b/gwp_asan/tests/never_allocated.cpp
index bd43b22..2f695b4 100644
--- a/gwp_asan/tests/never_allocated.cpp
+++ b/gwp_asan/tests/never_allocated.cpp
@@ -25,7 +25,7 @@ TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
// in the posix crash handler.
char *volatile NeverAllocatedPtr = static_cast<char *>(Ptr) + 0x3000;
if (!Recoverable) {
- ASSERT_DEATH(*NeverAllocatedPtr = 0, DeathNeedle);
+ EXPECT_DEATH(*NeverAllocatedPtr = 0, DeathNeedle);
return;
}