Skip tests if no adapter is available

Bug: dawn:208
Change-Id: I076fd497101dd017e8d83ae034edb7b1fa1f8581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11941
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2019-10-09 16:23:22 +00:00 committed by Commit Bot service account
parent 70c8c10571
commit e79b06100f
29 changed files with 92 additions and 85 deletions

View File

@ -164,20 +164,8 @@ void DawnTestEnvironment::SetUp() {
mInstance->EnableBackendValidation(mEnableBackendValidation); mInstance->EnableBackendValidation(mEnableBackendValidation);
mInstance->EnableBeginCaptureOnStartup(mBeginCaptureOnStartup); mInstance->EnableBeginCaptureOnStartup(mBeginCaptureOnStartup);
static constexpr dawn_native::BackendType kWindowlessBackends[] = { mInstance.get()->DiscoverDefaultAdapters();
dawn_native::BackendType::D3D12, DiscoverOpenGLAdapter();
dawn_native::BackendType::Metal,
dawn_native::BackendType::Vulkan,
};
for (dawn_native::BackendType backend : kWindowlessBackends) {
if (detail::IsBackendAvailable(backend)) {
mInstance.get()->DiscoverDefaultAdapters();
}
}
if (detail::IsBackendAvailable(dawn_native::BackendType::OpenGL)) {
DiscoverOpenGLAdapter();
}
std::cout << "Testing configuration\n" std::cout << "Testing configuration\n"
"---------------------\n" "---------------------\n"
@ -238,7 +226,9 @@ uint32_t DawnTestEnvironment::GetVendorIdFilter() const {
void DawnTestEnvironment::DiscoverOpenGLAdapter() { void DawnTestEnvironment::DiscoverOpenGLAdapter() {
#ifdef DAWN_ENABLE_BACKEND_OPENGL #ifdef DAWN_ENABLE_BACKEND_OPENGL
ASSERT_TRUE(glfwInit()); if (!glfwInit()) {
return;
}
glfwDefaultWindowHints(); glfwDefaultWindowHints();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
@ -407,7 +397,9 @@ void DawnTestBase::SetUp() {
} }
} }
ASSERT(mBackendAdapter); if (!mBackendAdapter) {
return;
}
} }
mPCIInfo = mBackendAdapter.GetPCIInfo(); mPCIInfo = mBackendAdapter.GetPCIInfo();
@ -478,6 +470,10 @@ void DawnTestBase::TearDown() {
} }
} }
bool DawnTestBase::HasAdapter() const {
return !!mBackendAdapter;
}
void DawnTestBase::StartExpectDeviceError() { void DawnTestBase::StartExpectDeviceError() {
mExpectError = true; mExpectError = true;
mError = false; mError = false;

View File

@ -200,6 +200,7 @@ class DawnTestBase {
uint32_t pixelSize, uint32_t pixelSize,
detail::Expectation* expectation); detail::Expectation* expectation);
bool HasAdapter() const;
void WaitABit(); void WaitABit();
void FlushWire(); void FlushWire();
@ -272,14 +273,31 @@ class DawnTestBase {
dawn_native::Adapter mBackendAdapter; dawn_native::Adapter mBackendAdapter;
}; };
// Skip a test when the given condition is satisfied.
#define DAWN_SKIP_TEST_IF(condition) \
if (condition) { \
std::cout << "Test skipped: " #condition "." << std::endl; \
GTEST_SKIP(); \
return; \
}
template <typename Params = DawnTestParam> template <typename Params = DawnTestParam>
class DawnTestWithParams : public DawnTestBase, public ::testing::TestWithParam<Params> { class DawnTestWithParams : public DawnTestBase, public ::testing::TestWithParam<Params> {
private:
void SetUp() override final {
// DawnTestBase::SetUp() gets the adapter, and creates the device and wire.
// It's separate from TestSetUp() so we can skip tests completely if no adapter
// is available.
DawnTestBase::SetUp();
DAWN_SKIP_TEST_IF(!HasAdapter());
TestSetUp();
}
protected: protected:
DawnTestWithParams(); DawnTestWithParams();
~DawnTestWithParams() override = default; ~DawnTestWithParams() override = default;
void SetUp() override { virtual void TestSetUp() {
DawnTestBase::SetUp();
} }
void TearDown() override { void TearDown() override {
@ -303,12 +321,6 @@ using DawnTest = DawnTestWithParams<>;
testName##params, sizeof(testName##params) / sizeof(firstParam))), \ testName##params, sizeof(testName##params) / sizeof(firstParam))), \
testing::PrintToStringParamName()) 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 { namespace detail {
// Helper functions used for DAWN_INSTANTIATE_TEST // Helper functions used for DAWN_INSTANTIATE_TEST

View File

@ -26,8 +26,8 @@ constexpr static unsigned int kRTSize = 64;
class ColorStateTest : public DawnTest { class ColorStateTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450 #version 450

View File

@ -34,8 +34,8 @@ struct CopyConfig {
class CompressedTextureBCFormatTest : public DawnTest { class CompressedTextureBCFormatTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
mBindGroupLayout = utils::MakeBindGroupLayout( mBindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler}, device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler},
{1, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture}}); {1, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture}});

View File

@ -29,8 +29,8 @@ namespace {
class D3D12ResourceTestBase : public DawnTest { class D3D12ResourceTestBase : public DawnTest {
public: public:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
if (UsesWire()) { if (UsesWire()) {
return; return;
} }
@ -101,8 +101,8 @@ namespace {
// These tests are skipped if the harness is using the wire. // These tests are skipped if the harness is using the wire.
class D3D12SharedHandleValidation : public D3D12ResourceTestBase { class D3D12SharedHandleValidation : public D3D12ResourceTestBase {
public: public:
void SetUp() override { void TestSetUp() override {
D3D12ResourceTestBase::SetUp(); D3D12ResourceTestBase::TestSetUp();
dawnDescriptor.dimension = dawn::TextureDimension::e2D; dawnDescriptor.dimension = dawn::TextureDimension::e2D;
dawnDescriptor.format = dawn::TextureFormat::BGRA8Unorm; dawnDescriptor.format = dawn::TextureFormat::BGRA8Unorm;

View File

@ -22,8 +22,8 @@ constexpr static unsigned int kRTSize = 64;
class DepthStencilStateTest : public DawnTest { class DepthStencilStateTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
dawn::TextureDescriptor renderTargetDescriptor; dawn::TextureDescriptor renderTargetDescriptor;
renderTargetDescriptor.dimension = dawn::TextureDimension::e2D; renderTargetDescriptor.dimension = dawn::TextureDimension::e2D;

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DestroyTest : public DawnTest { class DestroyTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawIndexedIndirectTest : public DawnTest { class DrawIndexedIndirectTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawIndexedTest : public DawnTest { class DrawIndexedTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawIndirectTest : public DawnTest { class DrawIndirectTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawTest : public DawnTest { class DrawTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -24,8 +24,8 @@ constexpr uint32_t kBindingSize = 8;
class DynamicBufferOffsetTests : public DawnTest { class DynamicBufferOffsetTests : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
// Mix up dynamic and non dynamic resources in one bind group and using not continuous // Mix up dynamic and non dynamic resources in one bind group and using not continuous
// binding number to cover more cases. // binding number to cover more cases.

View File

@ -60,8 +60,8 @@ class FenceTests : public DawnTest {
FenceTests() : mCallIndex(0) { FenceTests() : mCallIndex(0) {
} }
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
mockFenceOnCompletionCallback = std::make_unique<MockFenceOnCompletionCallback>(); mockFenceOnCompletionCallback = std::make_unique<MockFenceOnCompletionCallback>();
mockPopErrorScopeCallback = std::make_unique<MockPopErrorScopeCallback>(); mockPopErrorScopeCallback = std::make_unique<MockPopErrorScopeCallback>();
} }

View File

@ -22,8 +22,8 @@ constexpr uint32_t kRTSize = 400;
class IndexFormatTest : public DawnTest { class IndexFormatTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
} }

View File

@ -20,8 +20,8 @@
class MultisampledRenderingTest : public DawnTest { class MultisampledRenderingTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
InitTexturesForTest(); InitTexturesForTest();
} }

View File

@ -19,8 +19,8 @@
class NonzeroTextureCreationTests : public DawnTest { class NonzeroTextureCreationTests : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
} }
constexpr static uint32_t kSize = 128; constexpr static uint32_t kSize = 128;

View File

@ -20,8 +20,8 @@
class OpArrayLengthTest : public DawnTest { class OpArrayLengthTest : public DawnTest {
protected: protected:
void SetUp() { void TestSetUp() {
DawnTest::SetUp(); DawnTest::TestSetUp();
// Create buffers of various size to check the length() implementation // Create buffers of various size to check the length() implementation
dawn::BufferDescriptor bufferDesc; dawn::BufferDescriptor bufferDesc;

View File

@ -145,8 +145,8 @@ constexpr static float kVertices[] = {
class PrimitiveTopologyTest : public DawnTest { class PrimitiveTopologyTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -26,8 +26,8 @@ constexpr RGBA8 kColors[2] = {RGBA8(0, 255, 0, 255), RGBA8(0, 0, 255, 255)};
// tested in all other rendering tests. // tested in all other rendering tests.
class RenderBundleTest : public DawnTest { class RenderBundleTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -56,8 +56,8 @@ class DrawQuad {
class RenderPassLoadOpTests : public DawnTest { class RenderPassLoadOpTests : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
dawn::TextureDescriptor descriptor; dawn::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = dawn::TextureDimension::e2D;

View File

@ -22,8 +22,8 @@ constexpr dawn::TextureFormat kFormat = dawn::TextureFormat::RGBA8Unorm;
class RenderPassTest : public DawnTest { class RenderPassTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
// Shaders to draw a bottom-left triangle in blue. // Shaders to draw a bottom-left triangle in blue.
mVSModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( mVSModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(

View File

@ -38,8 +38,8 @@ namespace {
class SamplerTest : public DawnTest { class SamplerTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
mBindGroupLayout = utils::MakeBindGroupLayout( mBindGroupLayout = utils::MakeBindGroupLayout(

View File

@ -111,8 +111,8 @@ class ExpectFloat16 : public detail::Expectation {
class TextureFormatTest : public DawnTest { class TextureFormatTest : public DawnTest {
protected: protected:
void SetUp() { void TestSetUp() {
DawnTest::SetUp(); DawnTest::TestSetUp();
} }
// Structure containing all the information that tests need to know about the format. // Structure containing all the information that tests need to know about the format.

View File

@ -78,8 +78,8 @@ protected:
return static_cast<int>(level * 10) + static_cast<int>(layer + 1); return static_cast<int>(level * 10) + static_cast<int>(layer + 1);
} }
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -20,8 +20,8 @@
class TextureZeroInitTest : public DawnTest { class TextureZeroInitTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
} }
dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount, dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount,
uint32_t arrayLayerCount, uint32_t arrayLayerCount,

View File

@ -46,8 +46,8 @@ std::vector<destType> BitCast(std::vector<srcType> data) {
class VertexFormatTest : public DawnTest { class VertexFormatTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
} }

View File

@ -35,8 +35,8 @@ constexpr static unsigned int kRTCellSize = 100;
class VertexInputTest : public DawnTest { class VertexInputTest : public DawnTest {
protected: protected:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp(); DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
} }

View File

@ -58,7 +58,7 @@ class BufferUploadPerf : public DawnPerfTestWithParams<BufferUploadParams> {
} }
~BufferUploadPerf() override = default; ~BufferUploadPerf() override = default;
void SetUp() override; void TestSetUp() override;
private: private:
void Step() override; void Step() override;
@ -67,8 +67,8 @@ class BufferUploadPerf : public DawnPerfTestWithParams<BufferUploadParams> {
std::vector<uint8_t> data; std::vector<uint8_t> data;
}; };
void BufferUploadPerf::SetUp() { void BufferUploadPerf::TestSetUp() {
DawnPerfTestWithParams<BufferUploadParams>::SetUp(); DawnPerfTestWithParams<BufferUploadParams>::TestSetUp();
dawn::BufferDescriptor desc = {}; dawn::BufferDescriptor desc = {};
desc.size = kBufferSize; desc.size = kBufferSize;

View File

@ -31,8 +31,7 @@ namespace {
class VulkanImageWrappingTestBase : public DawnTest { class VulkanImageWrappingTestBase : public DawnTest {
public: public:
void SetUp() override { void TestSetUp() override {
DawnTest::SetUp();
if (UsesWire() || IsIntel()) { if (UsesWire() || IsIntel()) {
return; return;
} }
@ -198,8 +197,8 @@ namespace {
class VulkanImageWrappingValidationTests : public VulkanImageWrappingTestBase { class VulkanImageWrappingValidationTests : public VulkanImageWrappingTestBase {
public: public:
void SetUp() override { void TestSetUp() override {
VulkanImageWrappingTestBase::SetUp(); VulkanImageWrappingTestBase::TestSetUp();
if (UsesWire() || IsIntel()) { if (UsesWire() || IsIntel()) {
return; return;
} }
@ -349,8 +348,8 @@ TEST_P(VulkanImageWrappingValidationTests, DestroyedTextureSignalSemaphoreExport
// These tests are skipped if the harness is using the wire. // These tests are skipped if the harness is using the wire.
class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase { class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
public: public:
void SetUp() override { void TestSetUp() override {
VulkanImageWrappingTestBase::SetUp(); VulkanImageWrappingTestBase::TestSetUp();
if (UsesWire() || IsIntel()) { if (UsesWire() || IsIntel()) {
return; return;
} }