Fix test that relied on NDEBUG always disabling DCHECK

The test BaseAnnotationShouldNotSupportSpinGuard assumed NDEBUG builds
always disabled DCHECK()s, but DCHECK_ALWAYS_ON overrides this.

This CL fixes the test for NDEDBUG + DCHECK_ALWAYS_ON builds by using
the DCHECK_IS_ON() macro to skip the test when DCHECKs are enabled.

Change-Id: I7b64729568c5d3139ca777e27462d81eba931834
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4255429
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Ben Hamilton <benhamilton@google.com>
This commit is contained in:
Ben Hamilton 2023-02-15 12:09:32 -07:00 committed by Crashpad LUCI CQ
parent 0adab59836
commit 485805c6fe

View File

@ -161,8 +161,9 @@ TEST_F(Annotation, BaseAnnotationShouldNotSupportSpinGuard) {
crashpad::Annotation::Type::kString, "no-spin-guard", buffer);
EXPECT_EQ(annotation.concurrent_access_guard_mode(),
crashpad::Annotation::ConcurrentAccessGuardMode::kUnguarded);
#ifdef NDEBUG
// This fails a DCHECK() in debug builds, so only test it for NDEBUG builds.
#if !DCHECK_IS_ON()
// This fails a DCHECK() in debug builds, so only test it when DCHECK()
// is not on.
EXPECT_EQ(std::nullopt, annotation.TryCreateScopedSpinGuard(0));
#endif
}