fuzzing: Add Vulkan backend fuzzer
Bug: dawn:295 Change-Id: If134a076e53eb6c1b03712b7b14436464bf5f73a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14680 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
5217ad51c5
commit
bfb2a5740f
|
@ -170,3 +170,15 @@ dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") {
|
|||
|
||||
additional_configs = [ "${dawn_root}/src/common:dawn_internal" ]
|
||||
}
|
||||
|
||||
dawn_fuzzer_test("dawn_wire_server_and_vulkan_backend_fuzzer") {
|
||||
sources = [
|
||||
"DawnWireServerAndVulkanBackendFuzzer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":dawn_wire_server_fuzzer_common",
|
||||
]
|
||||
|
||||
additional_configs = [ "${dawn_root}/src/common:dawn_internal" ]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2019 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "DawnWireServerFuzzer.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "dawn_native/DawnNative.h"
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
return DawnWireServerFuzzer::Run(data, size, [](dawn_native::Instance* instance) {
|
||||
instance->DiscoverDefaultAdapters();
|
||||
|
||||
std::vector<dawn_native::Adapter> adapters = instance->GetAdapters();
|
||||
|
||||
wgpu::Device device;
|
||||
for (dawn_native::Adapter adapter : adapters) {
|
||||
if (adapter.GetBackendType() == dawn_native::BackendType::Vulkan &&
|
||||
adapter.GetDeviceType() == dawn_native::DeviceType::CPU) {
|
||||
device = wgpu::Device::Acquire(adapter.CreateDevice());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(device.Get() != nullptr);
|
||||
return device;
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue