From 3aa5be97491c13272020912672b325569bec5769 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 16 Apr 2020 21:36:33 +0000 Subject: [PATCH] Print the failing statement in ASSERT_DEVICE_ERROR Makes it easier to track where and why a test failed. Bug: none Change-Id: Icdccde97db68c32c35af6c044a3eacd4d4978b61 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19701 Reviewed-by: Kai Ninomiya Reviewed-by: Corentin Wallez Commit-Queue: Austin Eng --- src/tests/DawnTest.h | 14 +++++++++----- src/tests/unittests/validation/ValidationTest.h | 12 ++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h index b7c81fd391..3dc13a7f39 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -59,11 +59,15 @@ // Should only be used to test validation of function that can't be tested by regular validation // tests; -#define ASSERT_DEVICE_ERROR(statement) \ - StartExpectDeviceError(); \ - statement; \ - FlushWire(); \ - ASSERT_TRUE(EndExpectDeviceError()) +#define ASSERT_DEVICE_ERROR(statement) \ + StartExpectDeviceError(); \ + statement; \ + FlushWire(); \ + if (!EndExpectDeviceError()) { \ + FAIL() << "Expected device error in:\n " << #statement; \ + } \ + do { \ + } while (0) struct RGBA8 { constexpr RGBA8() : RGBA8(0, 0, 0, 0) { diff --git a/src/tests/unittests/validation/ValidationTest.h b/src/tests/unittests/validation/ValidationTest.h index eeac5a6eb8..0b165fef09 100644 --- a/src/tests/unittests/validation/ValidationTest.h +++ b/src/tests/unittests/validation/ValidationTest.h @@ -19,10 +19,14 @@ #include "dawn_native/DawnNative.h" #include "gtest/gtest.h" -#define ASSERT_DEVICE_ERROR(statement) \ - StartExpectDeviceError(); \ - statement; \ - ASSERT_TRUE(EndExpectDeviceError()) +#define ASSERT_DEVICE_ERROR(statement) \ + StartExpectDeviceError(); \ + statement; \ + if (!EndExpectDeviceError()) { \ + FAIL() << "Expected device error in:\n " << #statement; \ + } \ + do { \ + } while (0) class ValidationTest : public testing::Test { public: