dawn/test: Display an error message if toggles aren't recognised
Instead of cryptically crashing in release builds. Change-Id: I22d222c6d6550010c3484e1f18397cef22602b92 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122384 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
ea1fc1daeb
commit
b902e56ae7
|
@ -133,6 +133,10 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) {
|
|||
std::unique_ptr<dawn::native::Instance> instance = CreateInstanceAndDiscoverAdapters();
|
||||
ASSERT(instance);
|
||||
|
||||
if (!ValidateToggles(instance.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SelectPreferredAdapterProperties(instance.get());
|
||||
PrintTestConfigurationAndAdapterInfo(instance.get());
|
||||
}
|
||||
|
@ -415,6 +419,23 @@ std::vector<AdapterTestParam> 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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue