[utils] Fixes death test conditions and macros.

In https://dawn-review.git.corp.google.com/c/dawn/+/339076, when
trying to get partition_alloc death tests working for RawSpan,
I unconditionally imported:
  //build/config/sanitizers/sanitizers.gni
By importing that config, the use_fuzzing_engine flag was flipped
to "true" when the gn arg use_libfuzzer was set to "true". (This
happens in the clusterfuzz CI bot linked in the bug.) This
caused all the compilation flags of:
  DAWN_ENABLE_ASSERTS
  DAWN_ABORT_ON_ASSERT
  DAWN_DISABLE_LOGGING
to be set at compilation time. At the same time, that CI bot
actually sets is_debug = false, which meant that the
DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED macro assumed the test should
not crash, when in reality it does because DAWN_ENABLE_ASSERT
is the real flag that decides whether we crash or not and it
was set because use_fuzzing_engine was true.

This change does two main things:
  1) Fix the condition in utils/BUILD.gn such that we only set
     DAWN_ENABLE_ASSERTS w.r.t use_fuzzing_engine when we are
     building as a part of Chromium. This reverts the behavior
     of the tests to be the same as before the change above.
     Specifically, that the standalone clusterfuzz build does
     not build with asserts enabled since standalone builds
     depend on the is_debug flag to determine whether they
     should be enabled.
  2) Updates the test macros in utils/gtest.h to more
     explicitly handle the different cases appropriately so that
     tests don't need to handle them with ifdefs. This includes:
       - Adding DAWN_EXPECT_DEATH_IF_SUPPORTED macros that
         automatically suppresses string matching on the error
	 logs when DAWN_DISABLE_LOGGING in enabled.
       - Update DAWN_*_DEBUG_DEATH_IF_SUPPORTED macros to check
         both if we are in debug mode, or if DAWN_ENABLE_ASSERTS
	 is explicitly enabled.
       - Update PRESUBMIT.py to prevent Dawn code from using the
         gtest native macros, and instead make tests use the Dawn
	 ones that handle the different compilation defines
	 appropriately.
       - Update existing test code to use the new macros.

Bug: 564917473
Change-Id: Ia3e5cc597d9bcc7288cc3d66f16ce136d2f7db63
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/344475
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 381e6c6..40dbe33 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -162,20 +162,28 @@
         surface_as_gerrit_lint=True,
     ),
     BanRule(
-        pattern=r'/\b(EXPECT_DEATH|EXPECT_DEBUG_DEATH)\b',
-        excluded_paths=(r'^src/utils/gtest\.h$', ),
+        pattern=
+        r'/\b(EXPECT_DEATH|EXPECT_DEBUG_DEATH|EXPECT_DEATH_IF_SUPPORTED)\b',
+        excluded_paths=(
+            r'^src/utils/gtest\.h$',
+            r'^src/tint/',
+        ),
         explanation=(
-            'Use EXPECT_DEATH_IF_SUPPORTED or ',
+            'Use DAWN_EXPECT_DEATH_IF_SUPPORTED or ',
             'DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED instead.',
         ),
         treat_as_error=True,
         surface_as_gerrit_lint=True,
     ),
     BanRule(
-        pattern=r'/\b(ASSERT_DEATH|ASSERT_DEBUG_DEATH)\b',
-        excluded_paths=(r'^src/utils/gtest\.h$', ),
+        pattern=
+        r'/\b(ASSERT_DEATH|ASSERT_DEBUG_DEATH|ASSERT_DEATH_IF_SUPPORTED)\b',
+        excluded_paths=(
+            r'^src/utils/gtest\.h$',
+            r'^src/tint/',
+        ),
         explanation=(
-            'Use ASSERT_DEATH_IF_SUPPORTED or ',
+            'Use DAWN_ASSERT_DEATH_IF_SUPPORTED or ',
             'DAWN_ASSERT_DEBUG_DEATH_IF_SUPPORTED instead.',
         ),
         treat_as_error=True,
diff --git a/src/dawn/tests/unittests/CommandAllocatorTests.cpp b/src/dawn/tests/unittests/CommandAllocatorTests.cpp
index d95bd0c..9996db9 100644
--- a/src/dawn/tests/unittests/CommandAllocatorTests.cpp
+++ b/src/dawn/tests/unittests/CommandAllocatorTests.cpp
@@ -35,10 +35,10 @@
 #include <utility>
 #include <vector>
 
-#include "gtest/gtest.h"
 #include "src/dawn/common/Enumerator.h"
 #include "src/dawn/common/MemoryBlockAllocator.h"
 #include "src/dawn/native/CommandAllocator.h"
+#include "src/utils/gtest.h"
 
 namespace dawn::native {
 namespace {
@@ -405,28 +405,28 @@
 // Test for overflows in Allocate's computations, size 1 variant
 TEST(CommandAllocatorDeathTest, AllocationOverflow_1) {
     CommandAllocatorAndPool allocator;
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         allocator.AllocateData<AlignedStruct<1>>(std::numeric_limits<size_t>::max() / 1u), "");
 }
 
 // Test for overflows in Allocate's computations, size 2 variant
 TEST(CommandAllocatorDeathTest, AllocationOverflow_2) {
     CommandAllocatorAndPool allocator;
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         allocator.AllocateData<AlignedStruct<2>>(std::numeric_limits<size_t>::max() / 2u), "");
 }
 
 // Test for overflows in Allocate's computations, size 4 variant
 TEST(CommandAllocatorDeathTest, AllocationOverflow_4) {
     CommandAllocatorAndPool allocator;
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         allocator.AllocateData<AlignedStruct<4>>(std::numeric_limits<size_t>::max() / 4u), "");
 }
 
 // Test for overflows in Allocate's computations, size 8 variant
 TEST(CommandAllocatorDeathTest, AllocationOverflow_8) {
     CommandAllocatorAndPool allocator;
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         allocator.AllocateData<AlignedStruct<8>>(std::numeric_limits<size_t>::max() / 8u), "");
 }
 
diff --git a/src/dawn/tests/unittests/ITypArrayTests.cpp b/src/dawn/tests/unittests/ITypArrayTests.cpp
index a51f6d3..6495be3 100644
--- a/src/dawn/tests/unittests/ITypArrayTests.cpp
+++ b/src/dawn/tests/unittests/ITypArrayTests.cpp
@@ -122,12 +122,12 @@
     }
 
     Array arr;
-    EXPECT_DEATH_IF_SUPPORTED(arr[Key(10u)], "");
-    EXPECT_DEATH_IF_SUPPORTED(arr.at(Key(10u)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(arr[Key(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(arr.at(Key(10u)), "");
 
     const Array& constArr = arr;
-    EXPECT_DEATH_IF_SUPPORTED(constArr[Key(10u)], "");
-    EXPECT_DEATH_IF_SUPPORTED(constArr.at(Key(10u)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(constArr[Key(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(constArr.at(Key(10u)), "");
 }
 
 // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly.
@@ -144,11 +144,11 @@
 
     vec[Key64(9u)];
     // Regular out-of-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[Key64(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[Key64(10u)], "");
 
     vec[Key64(0u)];
     // If this were cast to a 32-bit size_t without a check, it would be in-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
 }
 
 }  // anonymous namespace
diff --git a/src/dawn/tests/unittests/ITypBitsetTests.cpp b/src/dawn/tests/unittests/ITypBitsetTests.cpp
index 484fb91..b5e6bd9 100644
--- a/src/dawn/tests/unittests/ITypBitsetTests.cpp
+++ b/src/dawn/tests/unittests/ITypBitsetTests.cpp
@@ -237,9 +237,10 @@
         constexpr uint64_t validBits = (one << bits) - 1;
         ityp::bitset<Key, bits>{0};                                             // Valid
         ityp::bitset<Key, bits>{validBits};                                     // All valid bits
-        EXPECT_DEATH_IF_SUPPORTED((ityp::bitset<Key, bits>{one << bits}), "");  // Invalid lsb
-        EXPECT_DEATH_IF_SUPPORTED((ityp::bitset<Key, bits>{one << 63}), "");    // Invalid msb
-        EXPECT_DEATH_IF_SUPPORTED((ityp::bitset<Key, bits>{~validBits}), "");   // All invalid bits
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::bitset<Key, bits>{one << bits}), "");  // Invalid lsb
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::bitset<Key, bits>{one << 63}), "");    // Invalid msb
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::bitset<Key, bits>{~validBits}),
+                                       "");  // All invalid bits
     };
 
     test(std::integral_constant<uint64_t, 1>{});
diff --git a/src/dawn/tests/unittests/ITypStackVecTests.cpp b/src/dawn/tests/unittests/ITypStackVecTests.cpp
index 3dbed0f..a7182b8 100644
--- a/src/dawn/tests/unittests/ITypStackVecTests.cpp
+++ b/src/dawn/tests/unittests/ITypStackVecTests.cpp
@@ -94,10 +94,10 @@
     }
 
     StackVec vec(Key(10u));
-    EXPECT_DEATH_IF_SUPPORTED(vec[Key(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[Key(10u)], "");
 
     const StackVec& constVec = vec;
-    EXPECT_DEATH_IF_SUPPORTED(constVec[Key(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(constVec[Key(10u)], "");
 }
 
 // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly.
@@ -111,20 +111,20 @@
     static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000u};
 
     // Crash either due to OOM (on 64-bit) or due to narrowing (on 32-bit).
-    EXPECT_DEATH_IF_SUPPORTED((ityp::stack_vec<Key64, Val, 20>(kHugeKey64)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::stack_vec<Key64, Val, 20>(kHugeKey64)), "");
 
     ityp::stack_vec<Key64, Val, 20> vec(Key64(10u));
 
     vec[Key64(9u)];
     // Regular out-of-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[Key64(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[Key64(10u)], "");
 
     vec[Key64(0u)];
     // If this were cast to a 32-bit size_t without a check, it would be in-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
 
-    EXPECT_DEATH_IF_SUPPORTED(vec.resize(kHugeKey64), "");
-    EXPECT_DEATH_IF_SUPPORTED(vec.reserve(kHugeKey64), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.resize(kHugeKey64), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.reserve(kHugeKey64), "");
 }
 
 }  // anonymous namespace
diff --git a/src/dawn/tests/unittests/ITypVectorTests.cpp b/src/dawn/tests/unittests/ITypVectorTests.cpp
index b413172..6423239 100644
--- a/src/dawn/tests/unittests/ITypVectorTests.cpp
+++ b/src/dawn/tests/unittests/ITypVectorTests.cpp
@@ -195,7 +195,7 @@
     {
         std::array<Val, 256> data = {};
         Vector8 vec;
-        EXPECT_DEATH_IF_SUPPORTED(vec.assign(data.begin(), data.end()), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.assign(data.begin(), data.end()), "");
     }
 
     // Note: not testing for assign with an std::initializer_list since it would require writing out
@@ -302,13 +302,13 @@
 
     Vector vec(Key(10u), Val(7u));
     vec[Key(9u)];
-    EXPECT_DEATH_IF_SUPPORTED(vec[Key(10u)], "");
-    EXPECT_DEATH_IF_SUPPORTED(vec.at(Key(10u)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[Key(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.at(Key(10u)), "");
 
     const Vector& constVec = vec;
     constVec[Key(9u)];
-    EXPECT_DEATH_IF_SUPPORTED(constVec[Key(10u)], "");
-    EXPECT_DEATH_IF_SUPPORTED(constVec.at(Key(10u)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(constVec[Key(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(constVec.at(Key(10u)), "");
 }
 
 // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly.
@@ -322,22 +322,22 @@
     static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000u};
 
     // Crash either due to OOM (on 64-bit) or due to narrowing (on 32-bit).
-    EXPECT_DEATH_IF_SUPPORTED((ityp::vector<Key64, Val>(kHugeKey64)), "");
-    EXPECT_DEATH_IF_SUPPORTED((ityp::vector<Key64, Val>(kHugeKey64, Val(7u))), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::vector<Key64, Val>(kHugeKey64)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::vector<Key64, Val>(kHugeKey64, Val(7u))), "");
 
     ityp::vector<Key64, Val> vec(Key64(10u), Val(7u));
 
     vec[Key64(9u)];
     // Regular out-of-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[Key64(10u)], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[Key64(10u)], "");
 
     vec[Key64(0u)];
     // If this were cast to a 32-bit size_t without a check, it would be in-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
 
-    EXPECT_DEATH_IF_SUPPORTED(vec.resize(kHugeKey64), "");
-    EXPECT_DEATH_IF_SUPPORTED(vec.resize(kHugeKey64, Val(7u)), "");
-    EXPECT_DEATH_IF_SUPPORTED(vec.reserve(kHugeKey64), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.resize(kHugeKey64), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.resize(kHugeKey64, Val(7u)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec.reserve(kHugeKey64), "");
 }
 
 }  // anonymous namespace
diff --git a/src/dawn/tests/unittests/MutexTests.cpp b/src/dawn/tests/unittests/MutexTests.cpp
index ee6f5bc..67d14c8 100644
--- a/src/dawn/tests/unittests/MutexTests.cpp
+++ b/src/dawn/tests/unittests/MutexTests.cpp
@@ -28,8 +28,8 @@
 #include <memory>
 #include <utility>
 
-#include "gtest/gtest.h"
 #include "src/dawn/common/Mutex.h"
+#include "src/utils/gtest.h"
 
 namespace dawn {
 namespace {
@@ -150,7 +150,7 @@
 TEST_F(MutexDeathTest, DoubleLockCalls) {
     Mutex::AutoLock autoLock1(&mMutex);
     EXPECT_TRUE(mMutex.IsLockedByCurrentThread());
-    ASSERT_DEATH_IF_SUPPORTED({ Mutex::AutoLock autoLock2(&mMutex); }, "");
+    DAWN_ASSERT_DEATH_IF_SUPPORTED({ Mutex::AutoLock autoLock2(&mMutex); }, "");
 }
 
 class RecursiveMutexTest : public ::testing::Test {
diff --git a/src/dawn/tests/unittests/RawPtrTests.cpp b/src/dawn/tests/unittests/RawPtrTests.cpp
index d781fb8..16d9462 100644
--- a/src/dawn/tests/unittests/RawPtrTests.cpp
+++ b/src/dawn/tests/unittests/RawPtrTests.cpp
@@ -27,8 +27,8 @@
 
 #include <memory>
 
-#include "gtest/gtest.h"
 #include "partition_alloc/pointers/raw_ptr.h"
+#include "src/utils/gtest.h"
 
 namespace dawn {
 namespace {
@@ -38,7 +38,7 @@
     std::unique_ptr<bool> owner = std::make_unique<bool>(true);
     raw_ptr<bool> ptr = owner.get();  // Lives until end of scope.
 
-    ASSERT_DEATH_IF_SUPPORTED(
+    DAWN_ASSERT_DEATH_IF_SUPPORTED(
         {
             owner.reset();  // DanglingRawPtrDetectedFn handler => no-op.
             ptr = nullptr;  // DanglingRawPtrReleasedFn handler => crash.
diff --git a/src/dawn/tests/unittests/SlabAllocatorTests.cpp b/src/dawn/tests/unittests/SlabAllocatorTests.cpp
index f869f3c..e197bea 100644
--- a/src/dawn/tests/unittests/SlabAllocatorTests.cpp
+++ b/src/dawn/tests/unittests/SlabAllocatorTests.cpp
@@ -29,9 +29,9 @@
 #include <set>
 #include <vector>
 
-#include "gtest/gtest.h"
 #include "src/dawn/common/Math.h"
 #include "src/dawn/common/SlabAllocator.h"
+#include "src/utils/gtest.h"
 
 namespace dawn {
 namespace {
@@ -265,7 +265,7 @@
     struct alignas(256) OverAlignedFoo : public Foo {
         using Foo::Foo;
     };
-    EXPECT_DEATH_IF_SUPPORTED(SlabAllocator<OverAlignedFoo>(100), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(SlabAllocator<OverAlignedFoo>(100), "");
 }
 
 }  // anonymous namespace
diff --git a/src/dawn/tests/unittests/wire/WireConfusionDeathTests.cpp b/src/dawn/tests/unittests/wire/WireConfusionDeathTests.cpp
index ed6e968..4b9b25d 100644
--- a/src/dawn/tests/unittests/wire/WireConfusionDeathTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireConfusionDeathTests.cpp
@@ -90,11 +90,7 @@
             WireTwo::GetWireClient()->Disconnect();
         }
         if (expectDeath) {
-#if defined(DAWN_ENABLE_ASSERTS)
-            EXPECT_DEATH_IF_SUPPORTED(lambda(), "forClient == mClient");
-#else
-            EXPECT_DEATH_IF_SUPPORTED(lambda(), "");
-#endif
+            DAWN_EXPECT_DEATH_IF_SUPPORTED(lambda(), "forClient == mClient");
         } else {
             lambda();
         }
diff --git a/src/utils/BUILD.gn b/src/utils/BUILD.gn
index 3be3c10..bdb1f21 100644
--- a/src/utils/BUILD.gn
+++ b/src/utils/BUILD.gn
@@ -314,8 +314,9 @@
   # running tests on the GPU builders. If we are not building with Chromium, we
   # ignore dcheck_always_on and rely on either dawn_always_assert or the build
   # type (is_debug) to enable asserts.
-  if (dawn_always_assert || (build_with_chromium && dcheck_always_on) ||
-      is_debug || use_fuzzing_engine) {
+  if (dawn_always_assert ||
+      (build_with_chromium && (dcheck_always_on || use_fuzzing_engine)) ||
+      is_debug) {
     defines += [ "DAWN_ENABLE_ASSERTS" ]
   }
 
diff --git a/src/utils/assert_test.cc b/src/utils/assert_test.cc
index fcdd9ce..1883a5c 100644
--- a/src/utils/assert_test.cc
+++ b/src/utils/assert_test.cc
@@ -79,11 +79,7 @@
 
 // DAWN_UNREACHABLE crashes in both debug and release.
 TEST_F(AssertDeathTest, SimpleUnreachable) {
-#if defined(DAWN_ENABLE_ASSERTS)
-    EXPECT_DEATH_IF_SUPPORTED(DAWN_UNREACHABLE(), "Unreachable code hit");
-#else
-    EXPECT_DEATH_IF_SUPPORTED(DAWN_UNREACHABLE(), "");
-#endif
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(DAWN_UNREACHABLE(), "Unreachable code hit");
 }
 
 enum class TestEnum : uint32_t {
@@ -125,11 +121,7 @@
     g_var = g_var + 1;
     TestEnum enum_val = static_cast<TestEnum>(g_var);
 
-#if defined(DAWN_ENABLE_ASSERTS)
-    EXPECT_DEATH_IF_SUPPORTED(g_var = DoFakeOp(enum_val, g_var), "Unreachable code hit");
-#else
-    EXPECT_DEATH_IF_SUPPORTED(g_var = DoFakeOp(enum_val, g_var), "");
-#endif
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(g_var = DoFakeOp(enum_val, g_var), "Unreachable code hit");
 
     g_var = g_var + 1;
 }
@@ -138,18 +130,16 @@
 volatile uint32_t g_var2 = 123;
 TEST_F(AssertDeathTest, AssertKills) {
     g_var2 = g_var2 + 1;
-#ifdef DAWN_ENABLE_ASSERTS
-    EXPECT_DEATH_IF_SUPPORTED(DAWN_ASSERT(g_var2 != 124), "g_var2 != 124");
-#endif
+    DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED(DAWN_ASSERT(g_var2 != 124), "g_var2 != 124");
 }
 
 #ifndef _WIN32
 TEST_F(AssertDeathTest, StackTrace) {
-    EXPECT_DEATH_IF_SUPPORTED(DAWN_UNREACHABLE(), "PC: @");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(DAWN_UNREACHABLE(), "PC: @");
 }
 
 TEST_F(AssertDeathTest, CrashStackTrace) {
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             volatile int* ptr = nullptr;
             *ptr = 1;
diff --git a/src/utils/gtest.h b/src/utils/gtest.h
index b4c4f0e..875a591 100644
--- a/src/utils/gtest.h
+++ b/src/utils/gtest.h
@@ -33,18 +33,39 @@
 #include "src/utils/assert.h"
 #include "src/utils/compiler.h"
 
-#ifdef GTEST_HAS_DEATH_TEST
-// If death tests are supported, defer to *_DEBUG_DEATH.
+// Wrappers around *_DEATH_IF_SUPPORTED that only match the death message when assertions and
+// logging are enabled (since DAWN_CHECK / DAWN_ASSERT only log condition strings when
+// DAWN_ENABLE_ASSERTS is defined and DAWN_DISABLE_LOGGING is not defined).
+#if defined(DAWN_ENABLE_ASSERTS) && !defined(DAWN_DISABLE_LOGGING)
+#define DAWN_EXPECT_DEATH_IF_SUPPORTED(statement, matcher) \
+    EXPECT_DEATH_IF_SUPPORTED(statement, matcher)
+#define DAWN_ASSERT_DEATH_IF_SUPPORTED(statement, matcher) \
+    ASSERT_DEATH_IF_SUPPORTED(statement, matcher)
+#else
+#define DAWN_EXPECT_DEATH_IF_SUPPORTED(statement, matcher) EXPECT_DEATH_IF_SUPPORTED(statement, "")
+#define DAWN_ASSERT_DEATH_IF_SUPPORTED(statement, matcher) ASSERT_DEATH_IF_SUPPORTED(statement, "")
+#endif
+
+#if defined(GTEST_HAS_DEATH_TEST) && !defined(DAWN_ENABLE_ASSERTS)
+// If death tests are supported and asserts are not enabled, defer to *_DEBUG_DEATH (which under
+// NDEBUG executes the statement directly without expecting death).
+#if !defined(DAWN_DISABLE_LOGGING)
 #define DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED(statement, matcher) \
     EXPECT_DEBUG_DEATH(statement, matcher)
 #define DAWN_ASSERT_DEBUG_DEATH_IF_SUPPORTED(statement, matcher) \
     ASSERT_DEBUG_DEATH(statement, matcher)
 #else
-// Otherwise, defer to *_DEATH_IF_SUPPORTED, to print the warning that we couldn't do the test.
+// If logging is disabled, don't match the death messages.
+#define DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED(statement, matcher) EXPECT_DEBUG_DEATH(statement, "")
+#define DAWN_ASSERT_DEBUG_DEATH_IF_SUPPORTED(statement, matcher) ASSERT_DEBUG_DEATH(statement, "")
+#endif
+#else
+// Otherwise, defer to DAWN_*_DEATH_IF_SUPPORTED, which either runs the death test (if supported) or
+// prints the warning that we couldn't do the test.
 #define DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED(statement, matcher) \
-    EXPECT_DEATH_IF_SUPPORTED(statement, matcher)
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(statement, matcher)
 #define DAWN_ASSERT_DEBUG_DEATH_IF_SUPPORTED(statement, matcher) \
-    ASSERT_DEATH_IF_SUPPORTED(statement, matcher)
+    DAWN_ASSERT_DEATH_IF_SUPPORTED(statement, matcher)
 #endif
 
 // Use DAWN_EXPECT_ASSERT_DEATH_IF_SUPPORTED_ELSE_SKIP_UBSAN to test
@@ -54,11 +75,7 @@
 // - Expect the death due to an assert, if death tests are supported and assert are turned on.
 // - Otherwise skip the statement, if an undefined behavior sanitizer is active
 // - Otherwise perform the statement. (In part to ensure test coverage).
-#if defined(GTEST_HAS_DEATH_TEST) && defined(DAWN_ENABLE_ASSERTS)
-// Perform the statement and expect death.
-#define DAWN_EXPECT_ASSERT_DEATH_IF_SUPPORTED_ELSE_SKIP_UBSAN(statement, matcher) \
-    EXPECT_DEATH(statement, matcher)
-#elif DAWN_UBSAN_ENABLED()
+#if !defined(DAWN_ENABLE_ASSERTS) && DAWN_UBSAN_ENABLED()
 #define DAWN_EXPECT_ASSERT_DEATH_IF_SUPPORTED_ELSE_SKIP_UBSAN(statement, matcher)  \
     do {                                                                           \
         GTEST_SKIP() << "Test exercises undefined behavior, and ubsan is enabled"; \
diff --git a/src/utils/heap_array_test.cc b/src/utils/heap_array_test.cc
index 51eedcf..0f27b3a 100644
--- a/src/utils/heap_array_test.cc
+++ b/src/utils/heap_array_test.cc
@@ -327,7 +327,7 @@
         std::ignore = ityp::HeapArrayFrom<IndexU8>(std::array<int, 254>{});
 
         // 255 is invalid because it's reserved as a sentinel value by dawn::SpanBase.
-        EXPECT_DEATH_IF_SUPPORTED(
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(
             std::ignore = ityp::HeapArrayFrom<IndexU8>(std::array<int, 255>{}), "");
     }
 }
@@ -427,10 +427,10 @@
     // Allocation of uint8_t values
     {
         // Exact maximum amount that will fit in the address space
-        EXPECT_DEATH_IF_SUPPORTED(
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(
             PreventElidingAllocation(HeapArray<uint8_t>{std::numeric_limits<size_t>::max()}), "");
         // And a bit less.
-        EXPECT_DEATH_IF_SUPPORTED(
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(
             PreventElidingAllocation(HeapArray<uint8_t>{std::numeric_limits<size_t>::max() - 4095}),
             "");
     }
@@ -438,14 +438,16 @@
     {
         static constexpr size_t kMaxSize = std::numeric_limits<size_t>::max() / sizeof(uint32_t);
         // Maximum amount that will fit in the address space
-        EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize}), "");
         // And a bit less.
-        EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize - 1023}),
-                                  "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(
+            PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize - 1023}), "");
 
         // Cases where size * sizeof(val) is larger than the address space and could overflow.
-        EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize + 1}), "");
-        EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize + 2}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize + 1}),
+                                       "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(HeapArray<uint32_t>{kMaxSize + 2}),
+                                       "");
     }
 }
 
@@ -454,8 +456,9 @@
     using Key64 = TypedInteger<struct Key64T, uint64_t>;
     static constexpr Key64 kHugeSize{0x1000'0000'0000'0000u};
 
-    EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(ityp::HeapArray<Key64, Val>{kHugeSize}), "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(PreventElidingAllocation(ityp::HeapArray<Key64, Val>{kHugeSize}),
+                                   "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         PreventElidingAllocation(
             // SAFETY: Testing unsafe API.
             DAWN_UNSAFE_BUFFERS(ityp::HeapArray<Key64, int>::Uninit(kHugeSize))),
@@ -471,10 +474,10 @@
     }
 
     HeapArrayVal arr{Index{10u}};
-    EXPECT_DEATH_IF_SUPPORTED(arr[Index{10u}], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(arr[Index{10u}], "");
 
     const HeapArrayVal& constArr = arr;
-    EXPECT_DEATH_IF_SUPPORTED(constArr[Index{10u}], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(constArr[Index{10u}], "");
 }
 
 // If the index/size is 64-bit, it needs to be narrowed to size_t. Verify that's checked correctly.
@@ -488,17 +491,17 @@
     static constexpr Key64 kHugeKey64{0x1000'0000'0000'0000u};
 
     // Crash either due to OOM (on 64-bit) or due to narrowing (on 32-bit).
-    EXPECT_DEATH_IF_SUPPORTED((ityp::HeapArray<Key64, Val>(kHugeKey64)), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED((ityp::HeapArray<Key64, Val>(kHugeKey64)), "");
 
     ityp::HeapArray<Key64, Val> vec(Key64{10u});
 
     vec[Key64{9u}];
     // Regular out-of-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[Key64{10u}], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[Key64{10u}], "");
 
     vec[Key64{0u}];
     // If this were cast to a 32-bit size_t without a check, it would be in-bounds.
-    EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(vec[kHugeKey64], "");
 }
 
 // Using uninitialized memory should crash on MSan builds.
@@ -509,7 +512,7 @@
 
     // SAFETY: Testing unsafe API.
     auto arr = DAWN_UNSAFE_BUFFERS(HeapArrayPOD::Uninit(Index{1u}));
-    EXPECT_DEATH_IF_SUPPORTED([&]() { printf("%d\n", arr[Index{0u}]); }(), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED([&]() { printf("%d\n", arr[Index{0u}]); }(), "");
 }
 
 }  // anonymous namespace
diff --git a/src/utils/numeric_test.cc b/src/utils/numeric_test.cc
index a343e51..1d9c8dc 100644
--- a/src/utils/numeric_test.cc
+++ b/src/utils/numeric_test.cc
@@ -59,11 +59,11 @@
     checked_cast<T64>(T32{std::numeric_limits<Prim32>::max()});
 
     // Narrowing
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         checked_cast<T32>(T64{Prim64{std::numeric_limits<Prim32>::max()} + 1}), "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         checked_cast<T32>(T64{Prim64{std::numeric_limits<Prim32>::max()} * 2}), "");
-    EXPECT_DEATH_IF_SUPPORTED(checked_cast<T32>(T64{std::numeric_limits<Prim64>::max()}), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(checked_cast<T32>(T64{std::numeric_limits<Prim64>::max()}), "");
 }
 template <typename U32, typename I32, typename U64, typename I64>
 void CheckedCastTest() {
diff --git a/src/utils/raw_span_tests.cc b/src/utils/raw_span_tests.cc
index 44f8eb9..232eee0 100644
--- a/src/utils/raw_span_tests.cc
+++ b/src/utils/raw_span_tests.cc
@@ -39,19 +39,19 @@
 
 TEST(RawSpanDanglingDeathTest, Constructor) {
     auto owner = std::make_unique<std::vector<int>>(std::initializer_list<int>{1, 2, 3});
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sp = RawSpan<int>{*owner};
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sub = RawSpan<int>{*owner}.subspan(1u);
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sp =
                 // SAFETY: This is viewing owner, just with typed indices.
@@ -59,7 +59,7 @@
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sub =
                 // SAFETY: This is viewing owner, just with typed indices.
@@ -72,25 +72,25 @@
 
 TEST(RawSpanDanglingDeathTest, SpanAsBytes) {
     auto owner = std::make_unique<std::vector<int>>(std::initializer_list<int>{1, 2, 3});
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto bsp = SpanAsBytes(RawSpan<int>{*owner});
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sub = SpanAsBytes(RawSpan<int>{*owner}).subspan(1u);
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto wbsp = SpanAsWritableBytes(RawSpan<int>{*owner});
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sub = SpanAsWritableBytes(RawSpan<int>{*owner}).subspan(1u);
             owner.reset();
@@ -100,26 +100,26 @@
 
 TEST(RawSpanDanglingDeathTest, ReinterpretSpan) {
     auto owner = std::make_unique<std::vector<std::byte>>(4 * sizeof(int));
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sp = ReinterpretSpan<int>(RawSpan<std::byte>{*owner});
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sub =
                 ReinterpretSpan<int>(RawSpan<std::byte>{*owner}).subspan(1u);
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sp = (ReinterpretSpan<int, Index>(RawSpan<std::byte>{*owner}));
             owner.reset();
         },
         "");
-    EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(
         {
             [[maybe_unused]] auto sub =
                 (ReinterpretSpan<int, Index>(RawSpan<std::byte>{*owner})).subspan(Index{1u});
diff --git a/src/utils/span_tests.cc b/src/utils/span_tests.cc
index b9d91c6..a8e01fe 100644
--- a/src/utils/span_tests.cc
+++ b/src/utils/span_tests.cc
@@ -172,27 +172,27 @@
 TYPED_TEST(SpanDeathTest, Constructor_DefaultFixedSpan) {
     {
         SPAN<int, 5> sp;
-        EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp[0], "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.at(0), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.begin(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.first(1), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.last(1), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.subspan(1), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.subspan(0, 1), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp[0], "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.at(0), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.begin(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.first(1), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.last(1), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(1), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(0, 1), "");
     }
     {
         ITYP_SPAN<Index, int, Index{5u}> sp;
-        EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp[Index{0u}], "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.at(Index{0u}), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.begin(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.first(Index{1u}), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.last(Index{1u}), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.subspan(Index{1u}), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.subspan(Index{0u}, Index{1u}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp[Index{0u}], "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.at(Index{0u}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.begin(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.first(Index{1u}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.last(Index{1u}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(Index{1u}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(Index{0u}, Index{1u}), "");
     }
 }
 
@@ -298,14 +298,14 @@
 
     constexpr Index64 kHugeSize{0x1'0000'0000LLU};
     // SAFETY: Test for the unsafe constructor.
-    DAWN_UNSAFE_BUFFERS(EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_UNSAFE_BUFFERS(DAWN_EXPECT_DEATH_IF_SUPPORTED(
         (ITYP_SPAN<Index64, const int>(kSpanData.data(), kHugeSize)), ""));
 }
 
 TYPED_TEST(SpanDeathTest, Constructor_PointerAndSizeDynamicExtent) {
     // DynamicExtent is invalid because it's reserved as a sentinel value.
     // SAFETY: Test for the unsafe constructor.
-    DAWN_UNSAFE_BUFFERS(EXPECT_DEATH_IF_SUPPORTED(
+    DAWN_UNSAFE_BUFFERS(DAWN_EXPECT_DEATH_IF_SUPPORTED(
         (ITYP_SPAN<Index8, const int>(kSpanData.data(), detail::DynamicExtent<Index8>)), ""));
 }
 
@@ -406,9 +406,10 @@
 TYPED_TEST(SpanDeathTest, Constructor_TwoIteratorsInverted) {
     std::array<int, 3> data = {1, 2, 3};
     // SAFETY: Test for the unsafe constructor.
-    DAWN_UNSAFE_BUFFERS(EXPECT_DEATH_IF_SUPPORTED((SPAN<int>{data.end(), data.begin()}), ""));
+    DAWN_UNSAFE_BUFFERS(DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<int>{data.end(), data.begin()}), ""));
     // SAFETY: Test for the unsafe constructor.
-    DAWN_UNSAFE_BUFFERS(EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 3>{data.end(), data.begin()}), ""));
+    DAWN_UNSAFE_BUFFERS(
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 3>{data.end(), data.begin()}), ""));
 }
 
 TYPED_TEST(SpanDeathTest, Constructor_TwoIteratorsLargerThanIndexType) {
@@ -417,13 +418,13 @@
 
     // SAFETY: Test for the unsafe constructor.
     DAWN_UNSAFE_BUFFERS(
-        EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index8, int>(data.begin(), data.end())), ""));
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index8, int>(data.begin(), data.end())), ""));
 
     // 255 is invalid because it's reserved as a sentinel value.
     data.resize(255);
     // SAFETY: Test for the unsafe constructor.
     DAWN_UNSAFE_BUFFERS(
-        EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index8, int>(data.begin(), data.end())), ""));
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index8, int>(data.begin(), data.end())), ""));
 
     // Fits in uint8_t for indexing without matching DynamicExtent.
     data.resize(254);
@@ -594,18 +595,18 @@
         SPAN<const int> constSp(constData);
 
         // Dynamic span larger than fixed extent.
-        EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 2>{sp}), "");
-        EXPECT_DEATH_IF_SUPPORTED((SPAN<const int, 2>{constSp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 2>{sp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<const int, 2>{constSp}), "");
 
         // Dynamic span smaller than fixed extent.
-        EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 10>{sp}), "");
-        EXPECT_DEATH_IF_SUPPORTED((SPAN<const int, 10>{constSp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 10>{sp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<const int, 10>{constSp}), "");
 
         // Empty dynamic span to non-zero fixed extent.
         SPAN<int> emptySp;
         SPAN<const int> emptyConstSp;
-        EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 3>{emptySp}), "");
-        EXPECT_DEATH_IF_SUPPORTED((SPAN<const int, 3>{emptyConstSp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<int, 3>{emptySp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((SPAN<const int, 3>{emptyConstSp}), "");
     }
 
     // Typed integer index tests.
@@ -614,16 +615,16 @@
         ITYP_SPAN<Index, const int> constSp(data);
 
         // Dynamic span larger than fixed extent.
-        EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, const int, Index{2u}>{constSp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, const int, Index{2u}>{constSp}), "");
 
         // Dynamic span smaller than fixed extent.
-        EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, const int, Index{10u}>{constSp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, const int, Index{10u}>{constSp}), "");
 
         // Empty dynamic span to non-zero fixed extent.
         ITYP_SPAN<Index, int> emptySp;
         ITYP_SPAN<Index, const int> emptyConstSp;
-        EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, int, Index{3u}>{emptySp}), "");
-        EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, const int, Index{3u}>{emptyConstSp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, int, Index{3u}>{emptySp}), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ITYP_SPAN<Index, const int, Index{3u}>{emptyConstSp}), "");
     }
 }
 
@@ -807,7 +808,7 @@
     // We check specifically that libc++'s bounded iterators are used as iterators for dawn::Span.
 #if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)
     // Error case, the hardened iterator will fail when we try to write a non-existent 4th element.
-    EXPECT_DEATH_IF_SUPPORTED(std::ranges::copy(src4, dstSpan.begin()), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(std::ranges::copy(src4, dstSpan.begin()), "");
 #else
     // Still a success case because we don't have bounded iterators.
     std::ranges::copy(src4, dstSpan.begin());
@@ -840,13 +841,13 @@
 TYPED_TEST(SpanDeathTest, FrontBackOfEmpty) {
     {
         SPAN<const int> sp;
-        EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
     }
     {
         SPAN<const int, 0> sp;
-        EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
-        EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.front(), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.back(), "");
     }
 }
 
@@ -885,16 +886,16 @@
 
 TYPED_TEST(SpanDeathTest, IndexingOOB) {
     SPAN<const int> sp(FakeRange{});
-    EXPECT_DEATH_IF_SUPPORTED(sp.at(sp.size()), "");
-    EXPECT_DEATH_IF_SUPPORTED(sp[sp.size()], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.at(sp.size()), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp[sp.size()], "");
 
     SPAN<const int> spEmpty;
-    EXPECT_DEATH_IF_SUPPORTED(spEmpty.at(0u), "");
-    EXPECT_DEATH_IF_SUPPORTED(spEmpty[0u], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(spEmpty.at(0u), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(spEmpty[0u], "");
 
     SPAN<const int, 0> spFixedEmpty;
-    EXPECT_DEATH_IF_SUPPORTED(spFixedEmpty.at(0u), "");
-    EXPECT_DEATH_IF_SUPPORTED(spFixedEmpty[0u], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(spFixedEmpty.at(0u), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(spFixedEmpty[0u], "");
 }
 
 TYPED_TEST(SpanDeathTest, IndexingOversizedIndex) {
@@ -908,7 +909,7 @@
     // The narrowing to size_t would give 0 which is in bounds, so this checks that the cast to
     // size_t itself causes a crash.
     constexpr Index64 kHugeIndex{0x1'0000'0000LLU};
-    EXPECT_DEATH_IF_SUPPORTED(sp[kHugeIndex], "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp[kHugeIndex], "");
 }
 
 // .data() and .size() are tested in every test essentially.
@@ -1046,10 +1047,10 @@
     SPAN<const int> sp{FakeRange()};
 
     sp.first(sp.size());
-    EXPECT_DEATH_IF_SUPPORTED(sp.first(sp.size() + 1), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.first(sp.size() + 1), "");
 
     sp.last(sp.size());
-    EXPECT_DEATH_IF_SUPPORTED(sp.last(sp.size() + 1), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.last(sp.size() + 1), "");
 }
 
 TYPED_TEST(SpanTest, Subspan1Arg) {
@@ -1099,12 +1100,12 @@
     {
         SPAN<const int> sp{FakeRange()};
         sp.subspan(sp.size());
-        EXPECT_DEATH_IF_SUPPORTED(sp.subspan(sp.size() + 1), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(sp.size() + 1), "");
     }
     {
         SPAN<const int, 5> sp{FakeRange()};
         sp.subspan(sp.size());
-        EXPECT_DEATH_IF_SUPPORTED(sp.subspan(sp.size() + 1), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(sp.size() + 1), "");
     }
 }
 
@@ -1156,11 +1157,11 @@
     SPAN<const int> sp{FakeRange()};
 
     sp.subspan(2, sp.size() - 2);
-    EXPECT_DEATH_IF_SUPPORTED(sp.subspan(2, sp.size() - 1), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(2, sp.size() - 1), "");
 
     // Check that overflows of offset + count is handled.
-    EXPECT_DEATH_IF_SUPPORTED(sp.subspan(std::numeric_limits<size_t>::max(), 1), "");
-    EXPECT_DEATH_IF_SUPPORTED(sp.subspan(1, std::numeric_limits<size_t>::max()), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(std::numeric_limits<size_t>::max(), 1), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.subspan(1, std::numeric_limits<size_t>::max()), "");
 
     // SAFETY: This is the same range as kSpanData, just viewed with a uint8_t index (which fits the
     // size of kSpanData since it is 5).
@@ -1170,11 +1171,11 @@
     Index8 kOne = Index8{uint8_t{1}};
     Index8 kTwo = Index8{uint8_t{2}};
     sp8.subspan(kTwo, sp8.size() - kTwo);
-    EXPECT_DEATH_IF_SUPPORTED(sp8.subspan(kTwo, sp8.size() - kOne), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp8.subspan(kTwo, sp8.size() - kOne), "");
 
     // Check that overflows of offset + count is handled.
-    EXPECT_DEATH_IF_SUPPORTED(sp8.subspan(std::numeric_limits<Index8>::max(), kOne), "");
-    EXPECT_DEATH_IF_SUPPORTED(sp8.subspan(kOne, std::numeric_limits<Index8>::max()), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp8.subspan(std::numeric_limits<Index8>::max(), kOne), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp8.subspan(kOne, std::numeric_limits<Index8>::max()), "");
 }
 
 TYPED_TEST(SpanTest, SpanAsBytes) {
@@ -1426,35 +1427,35 @@
         auto bsp = SPAN<std::byte>(bytes).subspan(1u, 0);
         EXPECT_EQ(bsp.size(), 0u);
         EXPECT_NE(bsp.data(), nullptr);
-        EXPECT_DEATH_IF_SUPPORTED(ReinterpretSpan<uint32_t>(bsp), "");
-        EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint32_t, Index>(bsp)), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(ReinterpretSpan<uint32_t>(bsp), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint32_t, Index>(bsp)), "");
     }
     // Alignment check fails.
     {
         alignas(uint32_t) std::array<std::byte, 9> bytes{};
         auto bsp = SPAN<std::byte>(bytes).subspan(1u, 4u);
         if (alignof(uint32_t) > 1) {
-            EXPECT_DEATH_IF_SUPPORTED(ReinterpretSpan<uint32_t>(bsp), "");
-            EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint32_t, Index>(bsp)), "");
+            DAWN_EXPECT_DEATH_IF_SUPPORTED(ReinterpretSpan<uint32_t>(bsp), "");
+            DAWN_EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint32_t, Index>(bsp)), "");
         }
     }
     // Size check fails.
     {
         alignas(uint32_t) std::array<std::byte, 8> bytes{};
         auto bsp = SPAN<std::byte>(bytes).first(7u);
-        EXPECT_DEATH_IF_SUPPORTED(ReinterpretSpan<uint32_t>(bsp), "");
-        EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint32_t, Index>(bsp)), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED(ReinterpretSpan<uint32_t>(bsp), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint32_t, Index>(bsp)), "");
     }
     // Index check fails.
     {
         std::array<std::byte, 256> bytes{};
         auto bsp = SPAN<std::byte>(bytes);
-        EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint8_t, Index8>(bsp)), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint8_t, Index8>(bsp)), "");
     }
     {
         std::array<std::byte, 255> bytes{};
         auto bsp = SPAN<std::byte>(bytes);
-        EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint8_t, Index8>(bsp)), "");
+        DAWN_EXPECT_DEATH_IF_SUPPORTED((ReinterpretSpan<uint8_t, Index8>(bsp)), "");
     }
 }
 
@@ -1551,7 +1552,7 @@
     SPAN<const int> sp{FakeRange()};
 
     sp.TakeFirst(sp.size());
-    EXPECT_DEATH_IF_SUPPORTED(sp.TakeFirst(sp.size() + 1), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(sp.TakeFirst(sp.size() + 1), "");
 }
 
 TYPED_TEST(SpanTest, CopyFrom) {
@@ -1623,7 +1624,7 @@
     SPAN<int> dst_sp{dst};
     SPAN<const int> src_sp{src};
 
-    EXPECT_DEATH_IF_SUPPORTED(dst_sp.CopyFrom(src_sp), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(dst_sp.CopyFrom(src_sp), "");
 }
 
 TYPED_TEST(SpanTest, CopyPrefixFrom) {
@@ -1695,7 +1696,7 @@
     SPAN<int> dst_sp{dst};
     SPAN<const int> src_sp{src};
 
-    EXPECT_DEATH_IF_SUPPORTED(dst_sp.CopyPrefixFrom(src_sp), "");
+    DAWN_EXPECT_DEATH_IF_SUPPORTED(dst_sp.CopyPrefixFrom(src_sp), "");
 }
 
 TYPED_TEST(SpanTest, FillBytes) {