[libFuzzer] Enable fuzz targets to build in Chromium

Enable building elf_image_reader_fuzzer in Chromium.
Rename it to crashpad_elf_image_reader_fuzzer so that its clearer
where the fuzzer comes from.
Import chromium's fuzzer_test definition when building in Chromium and
make sure fuzzer is only built on Linux since it breaks fuzzer build
on Win (and maybe Mac?).

Bug: 950093
Change-Id: I8afc104d26871311b04931b82a1600614a81bfc8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1597091
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Jonathan Metzman 2019-05-06 12:01:34 -07:00 committed by Joshua Peraza
parent 607c80e0b8
commit 18aa41d48c
2 changed files with 24 additions and 9 deletions

View File

@ -14,8 +14,11 @@
import("crashpad_buildconfig.gni")
import("test.gni")
if (crashpad_is_in_chromium) {
import("//testing/libfuzzer/fuzzer_test.gni")
}
template("fuzzer_test") {
template("crashpad_fuzzer_test") {
if (crashpad_is_standalone && crashpad_use_libfuzzer) {
test(target_name) {
forward_variables_from(invoker,
@ -38,6 +41,15 @@ template("fuzzer_test") {
}
cflags += [ "-fsanitize=fuzzer" ]
}
if (defined(invoker.seed_corpus)) {
not_needed(invoker, [ "seed_corpus" ])
}
} else if (crashpad_is_in_chromium) {
# Append "crashpad_" to the beginning of the fuzzer's name to make it easier
# in Chromium to recognize where fuzzer came from.
forward_variables_from(invoker, "*")
fuzzer_test("crashpad_" + target_name) {
}
} else {
not_needed(invoker, "*")
group(target_name) {

View File

@ -243,15 +243,18 @@ static_library("snapshot") {
}
}
fuzzer_test("elf_image_reader_fuzzer") {
sources = [
"elf/elf_image_reader_fuzzer.cc",
]
if (crashpad_is_linux) {
crashpad_fuzzer_test("elf_image_reader_fuzzer") {
sources = [
"elf/elf_image_reader_fuzzer.cc",
]
deps = [
":snapshot",
"../third_party/mini_chromium:base",
]
deps = [
":snapshot",
"../third_party/mini_chromium:base",
]
seed_corpus = "elf/elf_image_reader_fuzzer_corpus"
}
}
static_library("test_support") {