blob: e17fc08aef93fc0c5ccf181c8ea3e6f5b6736c01 [file] [log] [blame] [edit]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/fidl/fidl.gni")
import("//build/test.gni")
import("//build/test/test_package.gni")
########################################
# Common elements
fidl("fuchsia.fuzzer") {
sources = [ "fuzzer.fidl" ]
public_deps = [ "//sdk/fidl/fuchsia.mem" ]
}
source_set("core_lib") {
sources = [
"shared-memory.cc",
"test-input.cc",
]
public_deps = [
":fuchsia.fuzzer",
"//src/lib/fxl",
]
public_configs = [ ":config" ]
}
test("fidl_fuzzer_core_unittests") {
sources = [
"shared-memory-unittest.cc",
"test-input-unittest.cc",
]
deps = [
":core_lib",
"//src/lib/fxl/test:gtest_main",
]
}
group("test_deps") {
testonly = true
public_deps = [
"//sdk/lib/sys/cpp/testing:unit",
"//src/lib/fxl/test:gtest_main",
"//src/lib/testing/loop_fixture",
]
}
config("config") {
include_dirs = [
".",
"//src",
]
}
########################################
# Fuzzing engine
source_set("engine_lib") {
sources = [
"coverage.cc",
"data-provider.cc",
"engine.cc",
]
public_deps = [
":core_lib",
"//sdk/lib/fidl/cpp",
"//sdk/lib/sys/cpp",
"//zircon/public/lib/sync",
"//zircon/system/ulib/async-loop:async-loop-cpp",
]
deps = [ "//zircon/system/ulib/async-loop:async-loop-default" ]
}
# This test links a fake implementation of LLVMFuzzerTestOneInput.
test("fidl_fuzzer_engine_unittests") {
sources = [
"coverage-unittest.cc",
"data-provider-unittest.cc",
"engine-unittest.cc",
]
deps = [
":client_lib",
":engine_lib",
":proxy_lib",
":test_deps",
"test:fake_sanitizer_cov_proxy",
]
}
########################################
# Fuzz target function/client for code under test
source_set("client_lib") {
sources = [ "llvm-fuzzer.cc" ]
public_deps = [
":core_lib",
"//sdk/lib/fidl/cpp",
"//zircon/public/lib/fbl",
"//zircon/public/lib/sync",
"//zircon/system/ulib/async-loop:async-loop-cpp",
]
}
source_set("client_main") {
sources = [ "llvm-fuzzer-main.cc" ]
deps = [
":client_lib",
"//zircon/system/ulib/async-loop:async-loop-default",
]
}
# This test links a fake implementation of LLVMFuzzerTestOneInput.
test("fidl_fuzzer_client_unittests") {
sources = [
"data-provider.cc",
"llvm-fuzzer-unittest.cc",
]
deps = [
":client_lib",
":test_deps",
]
}
########################################
# Instrumentation proxy for code under test
source_set("proxy_lib") {
sources = [ "sanitizer-cov-proxy.cc" ]
public_deps = [ ":proxy_lib_public_deps" ]
deps = [
"//sdk/lib/sys/cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
public_configs = [ ":config" ]
}
group("proxy_lib_public_deps") {
public_deps = [
":core_lib",
"//zircon/public/lib/sync",
"//zircon/system/ulib/async-loop:async-loop-cpp",
]
}
# This test links a fake implementation of the __sanitizer_cov_* interface.
test("fidl_fuzzer_proxy_unittests") {
sources = [ "sanitizer-cov-proxy-unittest.cc" ]
deps = [
":proxy_lib",
":test_deps",
"test:fake_sanitizer_cov",
]
}
########################################
# Test package
group("tests") {
testonly = true
deps = [ ":fidl-fuzzer-tests" ]
}
test_package("fidl-fuzzer-tests") {
deps = [
":fidl_fuzzer_client_unittests",
":fidl_fuzzer_core_unittests",
":fidl_fuzzer_engine_unittests",
":fidl_fuzzer_proxy_unittests",
]
tests = [
{
name = "fidl_fuzzer_core_unittests"
environments = [ emu_env ]
},
{
log_settings = {
max_severity = "ERROR"
}
name = "fidl_fuzzer_client_unittests"
environments = [ emu_env ]
},
{
log_settings = {
max_severity = "ERROR"
}
name = "fidl_fuzzer_engine_unittests"
environments = [ emu_env ]
},
{
name = "fidl_fuzzer_proxy_unittests"
environments = [ emu_env ]
},
]
}