diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index 7b118e83b2..18f12f57db 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp @@ -133,6 +133,10 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) { std::unique_ptr instance = CreateInstanceAndDiscoverAdapters(); ASSERT(instance); + if (!ValidateToggles(instance.get())) { + return; + } + SelectPreferredAdapterProperties(instance.get()); PrintTestConfigurationAndAdapterInfo(instance.get()); } @@ -415,6 +419,23 @@ std::vector DawnTestEnvironment::GetAvailableAdapterTestParams return testParams; } +bool DawnTestEnvironment::ValidateToggles(dawn::native::Instance* instance) const { + dawn::LogMessage err = dawn::ErrorLog(); + for (const std::string& toggle : GetEnabledToggles()) { + if (!instance->GetToggleInfo(toggle.c_str())) { + err << "unrecognized toggle: '" << toggle << "'\n"; + return false; + } + } + for (const std::string& toggle : GetDisabledToggles()) { + if (!instance->GetToggleInfo(toggle.c_str())) { + err << "unrecognized toggle: '" << toggle << "'\n"; + return false; + } + } + return true; +} + void DawnTestEnvironment::PrintTestConfigurationAndAdapterInfo( dawn::native::Instance* instance) const { dawn::LogMessage log = dawn::InfoLog(); diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h index a254710252..f8a8afc04a 100644 --- a/src/dawn/tests/DawnTest.h +++ b/src/dawn/tests/DawnTest.h @@ -187,6 +187,10 @@ class DawnTestEnvironment : public testing::Environment { void SelectPreferredAdapterProperties(const dawn::native::Instance* instance); void PrintTestConfigurationAndAdapterInfo(dawn::native::Instance* instance) const; + /// @returns true if all the toggles are recognised, otherwise prints an error and returns + /// false. + bool ValidateToggles(dawn::native::Instance* instance) const; + bool mUseWire = false; dawn::native::BackendValidationLevel mBackendValidationLevel = dawn::native::BackendValidationLevel::Disabled;