Integrate deprecation testing into DawnTestBase
This makes it a lot easier to modify old tests to test deprecation
behavior, and means we can mark all of the places that are going to
break in the deprecation CL (while we're thinking about it) instead of
the removal CL (which is weeks later).
It also makes it so all deprecation warnings in the tests will be
caught. Turns out that they were already clean.
Bug: dawn:520
Change-Id: I429f667207b88df04341179369bb6d24e034ca65
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31141
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp
index 569e682..7fa5c49 100644
--- a/src/tests/DawnTest.cpp
+++ b/src/tests/DawnTest.cpp
@@ -773,6 +773,11 @@
for (size_t i = 0; i < mReadbackSlots.size(); ++i) {
mReadbackSlots[i].buffer.Unmap();
}
+
+ if (!UsesWire()) {
+ EXPECT_EQ(mLastWarningCount,
+ dawn_native::GetDeprecationWarningCountForTesting(device.Get()));
+ }
}
void DawnTestBase::StartExpectDeviceError() {
diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h
index 8fea2a1..5e42930 100644
--- a/src/tests/DawnTest.h
+++ b/src/tests/DawnTest.h
@@ -270,6 +270,8 @@
DawnProcTable backendProcs = {};
WGPUDevice backendDevice = nullptr;
+ size_t mLastWarningCount = 0;
+
// Helper methods to implement the EXPECT_ macros
std::ostringstream& AddBufferExpectation(const char* file,
int line,
@@ -408,6 +410,24 @@
} \
} while (0)
+#define EXPECT_DEPRECATION_WARNING(statement) \
+ do { \
+ if (UsesWire()) { \
+ statement; \
+ } else { \
+ size_t warningsBefore = \
+ dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
+ statement; \
+ size_t warningsAfter = \
+ dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
+ EXPECT_EQ(mLastWarningCount, warningsBefore); \
+ if (!IsDawnValidationSkipped()) { \
+ EXPECT_EQ(warningsAfter, warningsBefore + 1); \
+ } \
+ mLastWarningCount = warningsAfter; \
+ } \
+ } while (0)
+
template <typename Params = AdapterTestParam>
class DawnTestWithParams : public DawnTestBase, public ::testing::TestWithParam<Params> {
protected:
diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp
index 4b3222d..9ae31a6 100644
--- a/src/tests/end2end/DeprecatedAPITests.cpp
+++ b/src/tests/end2end/DeprecatedAPITests.cpp
@@ -30,34 +30,8 @@
// Skip when validation is off because warnings might be emitted during validation calls
DAWN_SKIP_TEST_IF(IsDawnValidationSkipped());
}
-
- void TearDown() override {
- if (!UsesWire()) {
- EXPECT_EQ(mLastWarningCount,
- dawn_native::GetDeprecationWarningCountForTesting(device.Get()));
- }
- DawnTest::TearDown();
- }
-
- size_t mLastWarningCount = 0;
};
-#define EXPECT_DEPRECATION_WARNING(statement) \
- do { \
- if (UsesWire()) { \
- statement; \
- } else { \
- size_t warningsBefore = \
- dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
- statement; \
- size_t warningsAfter = \
- dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
- EXPECT_EQ(mLastWarningCount, warningsBefore); \
- EXPECT_EQ(warningsAfter, warningsBefore + 1); \
- mLastWarningCount = warningsAfter; \
- } \
- } while (0)
-
// Test that using BGLEntry.multisampled = true emits a deprecation warning.
TEST_P(DeprecationTests, BGLEntryMultisampledDeprecated) {
wgpu::BindGroupLayoutEntry entry{};