From 37db223ed43c2c0d961f91340ad70dcaa9f550a6 Mon Sep 17 00:00:00 2001 From: Zhaoming Jiang Date: Thu, 12 Sep 2024 13:20:54 +0000 Subject: [PATCH] Dawn validation test: fix EXPECT_DEPRECATION_WARNINGS This CL make EXPECT_DEPRECATION_WARNINGS macro not accessing the private member mDawnInstance anymore, so that this macro can be used in test implementation. Without this CL the macro can only used in member functions of ValidationTest itself. Bug: 349125474 Change-Id: I82e5a027ce6a8cc171358c5767a462e9518533a8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/206087 Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- .../unittests/validation/ValidationTest.cpp | 4 ++++ .../unittests/validation/ValidationTest.h | 21 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/dawn/tests/unittests/validation/ValidationTest.cpp b/src/dawn/tests/unittests/validation/ValidationTest.cpp index 3ad9edbf604..4c2c0757f48 100644 --- a/src/dawn/tests/unittests/validation/ValidationTest.cpp +++ b/src/dawn/tests/unittests/validation/ValidationTest.cpp @@ -305,6 +305,10 @@ dawn::utils::WireHelper* ValidationTest::GetWireHelper() const { return mWireHelper.get(); } +uint64_t ValidationTest::GetInstanceDeprecationCountForTesting() { + return mDawnInstance->GetDeprecationWarningCountForTesting(); +} + uint32_t ValidationTest::GetDeviceCreationDeprecationWarningExpectation( const wgpu::DeviceDescriptor& descriptor) { uint32_t expectedDeprecatedCount = 0; diff --git a/src/dawn/tests/unittests/validation/ValidationTest.h b/src/dawn/tests/unittests/validation/ValidationTest.h index f59330fc917..367d1189fb5 100644 --- a/src/dawn/tests/unittests/validation/ValidationTest.h +++ b/src/dawn/tests/unittests/validation/ValidationTest.h @@ -92,16 +92,16 @@ } \ } while (0) -#define EXPECT_DEPRECATION_WARNINGS(statement, n) \ - do { \ - FlushWire(); \ - uint64_t warningsBefore = mDawnInstance->GetDeprecationWarningCountForTesting(); \ - EXPECT_EQ(mLastWarningCount, warningsBefore); \ - statement; \ - FlushWire(); \ - uint64_t warningsAfter = mDawnInstance->GetDeprecationWarningCountForTesting(); \ - EXPECT_EQ(warningsAfter, warningsBefore + n); \ - mLastWarningCount = warningsAfter; \ +#define EXPECT_DEPRECATION_WARNINGS(statement, n) \ + do { \ + FlushWire(); \ + uint64_t warningsBefore = GetInstanceDeprecationCountForTesting(); \ + EXPECT_EQ(mLastWarningCount, warningsBefore); \ + statement; \ + FlushWire(); \ + uint64_t warningsAfter = GetInstanceDeprecationCountForTesting(); \ + EXPECT_EQ(warningsAfter, warningsBefore + n); \ + mLastWarningCount = warningsAfter; \ } while (0) #define EXPECT_DEPRECATION_WARNING(statement) EXPECT_DEPRECATION_WARNINGS(statement, 1) @@ -180,6 +180,7 @@ class ValidationTest : public testing::Test { void SetUp(const wgpu::InstanceDescriptor* nativeDesc, const wgpu::InstanceDescriptor* wireDesc = nullptr); + uint64_t GetInstanceDeprecationCountForTesting(); // Helps compute expected deprecated warning count for creating device with given descriptor. uint32_t GetDeviceCreationDeprecationWarningExpectation( const wgpu::DeviceDescriptor& descriptor);