Implement DAWN_SKIP_TEST_IF for dawn_end2end_tests
This patch implements a micro DAWN_SKIP_TEST_IF in DawnTest.h which
can be used to skip running a test in dawn_end2end_tests when the
given condition is satisfied.
diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h
index 20896f9..d89dc41 100644
--- a/src/tests/DawnTest.h
+++ b/src/tests/DawnTest.h
@@ -177,6 +177,13 @@
testName##params, sizeof(testName##params) / sizeof(firstParam))), \
testing::PrintToStringParamName());
+// Skip a test when the given condition is satisfied.
+#define DAWN_SKIP_TEST_IF(condition) \
+ if (condition) { \
+ std::cout << "Test skipped: " #condition "." << std::endl; \
+ return; \
+ }
+
namespace detail {
// Helper functions used for DAWN_INSTANTIATE_TEST
bool IsBackendAvailable(BackendType type);
diff --git a/src/tests/end2end/BufferTests.cpp b/src/tests/end2end/BufferTests.cpp
index 0d8a92c..9cf6721 100644
--- a/src/tests/end2end/BufferTests.cpp
+++ b/src/tests/end2end/BufferTests.cpp
@@ -221,12 +221,9 @@
// Stress test for many calls to SetSubData
TEST_P(BufferSetSubDataTests, ManySetSubData) {
- if (IsD3D12() || IsMetal() || IsVulkan()) {
- // TODO(cwallez@chromium.org): Use ringbuffers for SetSubData on explicit APIs.
- // otherwise this creates too many resources and can take freeze the driver(?)
- std::cout << "Test skipped on D3D12, Metal and Vulkan" << std::endl;
- return;
- }
+ // TODO(cwallez@chromium.org): Use ringbuffers for SetSubData on explicit APIs.
+ // otherwise this creates too many resources and can take freeze the driver(?)
+ DAWN_SKIP_TEST_IF(IsD3D12() || IsMetal() || IsVulkan());
constexpr uint32_t kSize = 4000 * 1000;
constexpr uint32_t kElements = 1000 * 1000;
diff --git a/src/tests/end2end/ComputeCopyStorageBufferTests.cpp b/src/tests/end2end/ComputeCopyStorageBufferTests.cpp
index 8bf51be..15ec8b3 100644
--- a/src/tests/end2end/ComputeCopyStorageBufferTests.cpp
+++ b/src/tests/end2end/ComputeCopyStorageBufferTests.cpp
@@ -105,11 +105,8 @@
// Test that a slightly-less-trivial compute-shader memcpy implementation works.
TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
- if (IsD3D12()) {
- // TODO(kainino@chromium.org): Fails on D3D12. Probably due to a limitation in SPIRV-Cross?
- std::cout << "Test skipped on D3D12" << std::endl;
- return;
- }
+ // TODO(kainino@chromium.org): Fails on D3D12. Probably due to a limitation in SPIRV-Cross?
+ DAWN_SKIP_TEST_IF(IsD3D12());
BasicTest(R"(
#version 450
diff --git a/src/tests/end2end/CopyTests.cpp b/src/tests/end2end/CopyTests.cpp
index 44a1334..912d8b6 100644
--- a/src/tests/end2end/CopyTests.cpp
+++ b/src/tests/end2end/CopyTests.cpp
@@ -368,10 +368,7 @@
TEST_P(CopyTests_T2B, Texture2DArrayRegion)
{
// TODO(jiawei.shao@intel.com): support 2D array texture on OpenGL, D3D12 and Metal.
- if (IsOpenGL() || IsD3D12() || IsMetal()) {
- std::cout << "Test skipped on OpenGL, D3D12 and Metal" << std::endl;
- return;
- }
+ DAWN_SKIP_TEST_IF(IsOpenGL() || IsD3D12() || IsMetal());
constexpr uint32_t kWidth = 256;
constexpr uint32_t kHeight = 128;
@@ -382,10 +379,8 @@
// Test that copying texture 2D array mips with 256-byte aligned sizes works
TEST_P(CopyTests_T2B, Texture2DArrayMip) {
// TODO(jiawei.shao@intel.com): support 2D array texture on OpenGL, D3D12 and Metal.
- if (IsOpenGL() || IsD3D12() || IsMetal()) {
- std::cout << "Test skipped on OpenGL, D3D12 and Metal" << std::endl;
- return;
- }
+ DAWN_SKIP_TEST_IF(IsOpenGL() || IsD3D12() || IsMetal());
+
constexpr uint32_t kWidth = 256;
constexpr uint32_t kHeight = 128;
constexpr uint32_t kLayers = 6u;
diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp
index 6cd229f..d9582bb 100644
--- a/src/tests/end2end/IndexFormatTests.cpp
+++ b/src/tests/end2end/IndexFormatTests.cpp
@@ -201,10 +201,7 @@
// prevent a case in D3D12 where the index format would be captured from the last
// pipeline on SetIndexBuffer.
TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
- if (IsD3D12() || IsVulkan()) {
- std::cout << "Test skipped on D3D12 and Vulkan" << std::endl;
- return;
- }
+ DAWN_SKIP_TEST_IF(IsD3D12() || IsVulkan());
dawn::RenderPipeline pipeline32 = MakeTestPipeline(dawn::IndexFormat::Uint32);
dawn::RenderPipeline pipeline16 = MakeTestPipeline(dawn::IndexFormat::Uint16);
diff --git a/src/tests/end2end/ScissorTests.cpp b/src/tests/end2end/ScissorTests.cpp
index ba85127..19a1590 100644
--- a/src/tests/end2end/ScissorTests.cpp
+++ b/src/tests/end2end/ScissorTests.cpp
@@ -89,10 +89,7 @@
// Test setting an empty scissor rect
TEST_P(ScissorTest, EmptyRect) {
- if (IsMetal()) {
- std::cout << "Test skipped on Metal" << std::endl;
- return;
- }
+ DAWN_SKIP_TEST_IF(IsMetal());
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);