From 7355460100a2bf51ed2ea7f7f0d895798b490a86 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 19 May 2020 20:51:23 +0000 Subject: [PATCH] Skip window and surface tests if glfwInit fails This skips tests that would fail on SwiftShader on systems with no display. Bug: dawn:283 Change-Id: Ie3aa46349df3116305712a5aa143d874cef0d4b4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21781 Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya Commit-Queue: Austin Eng --- src/tests/end2end/SwapChainValidationTests.cpp | 2 +- src/tests/end2end/WindowSurfaceTests.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tests/end2end/SwapChainValidationTests.cpp b/src/tests/end2end/SwapChainValidationTests.cpp index b4a76d4212..e92bf847e9 100644 --- a/src/tests/end2end/SwapChainValidationTests.cpp +++ b/src/tests/end2end/SwapChainValidationTests.cpp @@ -32,7 +32,7 @@ class SwapChainValidationTests : public DawnTest { glfwSetErrorCallback([](int code, const char* message) { dawn::ErrorLog() << "GLFW error " << code << " " << message; }); - glfwInit(); + DAWN_SKIP_TEST_IF(!glfwInit()); // The SwapChainValidationTests don't create devices so we don't need to call // SetupGLFWWindowHintsForBackend. Set GLFW_NO_API anyway to avoid GLFW bringing up a GL diff --git a/src/tests/end2end/WindowSurfaceTests.cpp b/src/tests/end2end/WindowSurfaceTests.cpp index 29e4fcbed6..7bfc107fe0 100644 --- a/src/tests/end2end/WindowSurfaceTests.cpp +++ b/src/tests/end2end/WindowSurfaceTests.cpp @@ -16,6 +16,7 @@ #include "common/Platform.h" #include "dawn/dawn_proc.h" #include "dawn_native/DawnNative.h" +#include "tests/DawnTest.h" #include "utils/GLFWUtils.h" #include @@ -47,7 +48,7 @@ class WindowSurfaceInstanceTests : public testing::Test { glfwSetErrorCallback([](int code, const char* message) { dawn::ErrorLog() << "GLFW error " << code << " " << message; }); - glfwInit(); + DAWN_SKIP_TEST_IF(!glfwInit()); DawnProcTable procs = dawn_native::GetProcs(); dawnProcSetProcs(&procs);