1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Fuzzing Infrastructure Tests
import("//build/config/sanitizers/sanitizers.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
group("tests") {
testonly = true
deps = [ ":fuzzing_unittests" ]
}
# Basic smoke tests for fuzzing
test("fuzzing_unittests") {
# The most basic smoketest for FUZZ_TEST macros.
# The main purpose is to ensure that this builds in all configurations:
# * on regular builders, this will produce a unit test executable
# * on ASAN builders, this will produce a unit test executable which
# additionally has sancov instrumentation to support --fuzz=
# arguments
# * on libfuzzer and centipede builders this will enable different
# options again.
sources = [ "fuzztest_smoketest.cc" ]
fuzztests = [ "FuzzTestSmokeTest.StringsAlwaysOccupyPositiveSpace" ]
deps = [
"//base/test:run_all_unittests",
"//testing/gtest",
"//third_party/fuzztest",
]
data_deps = []
data = []
if (use_fuzzing_engine) {
sources += [ "stacktrace_test.cc" ]
deps += [
"//base",
"//testing/gmock",
]
data_deps += [ ":stacktrace_test_fuzzer" ]
data += [ "data/uaf" ]
# TODO(crbug.com/40603084): Get these tests working on Windows.
if (!is_win) {
sources += [ "fuzzer_launcher_test.cc" ]
data_deps += [
":check_fuzzer_config",
":check_seed_corpus_archive",
":test_config_and_dict",
":test_config_and_seed_corpus",
":test_config_and_seed_corpuses",
":test_config_only",
":test_dict_from_subdir",
":test_dict_only",
]
}
}
}
# These fuzzer targets' outputs serve as inputs to `fuzzer_launcher_test.cc`,
# which checks that `.options`, `.dict` and corpus files are generated
# correctly. Only compile them when compiling the test itself.
if (use_fuzzing_engine && !is_win) {
fuzzer_test("test_dict_only") {
sources = [ "../fuzzers/empty_fuzzer.cc" ]
dict = "test.dict"
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
fuzzer_test("test_config_only") {
sources = [ "../fuzzers/empty_fuzzer.cc" ]
libfuzzer_options = [
"some_test_option=test_value",
"max_len=1024",
]
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
fuzzer_test("test_config_and_dict") {
sources = [ "../fuzzers/empty_fuzzer.cc" ]
dict = "test.dict"
libfuzzer_options = [
"max_len=random(1337, 31337)",
"timeout = 666",
"use_traces=1",
]
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
fuzzer_test("test_config_and_seed_corpus") {
sources = [ "../fuzzers/empty_fuzzer.cc" ]
seed_corpus = "test_corpus"
libfuzzer_options = [
"some_test_option=test_value",
"max_len=1024",
]
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
fuzzer_test("test_config_and_seed_corpuses") {
sources = [ "../fuzzers/empty_fuzzer.cc" ]
seed_corpuses = [
"test_corpus",
"test_corpus_2",
]
libfuzzer_options = [
"some_test_option=another_test_value",
"max_len=1337",
]
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
fuzzer_test("test_dict_from_subdir") {
sources = [ "../fuzzers/empty_fuzzer.cc" ]
dict = "dicts_subdir/test_subdir.dict"
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
copy("check_fuzzer_config") {
sources = [ "check_fuzzer_config.py" ]
outputs = [ "$root_build_dir/check_fuzzer_config.py" ]
}
copy("check_seed_corpus_archive") {
sources = [ "check_seed_corpus_archive.py" ]
outputs = [ "$root_build_dir/check_seed_corpus_archive.py" ]
}
}
fuzzer_test("stacktrace_test_fuzzer") {
sources = [ "stacktrace_test_fuzzer.cc" ]
deps = [ "//base" ]
additional_configs = [ "//testing/libfuzzer:no_clusterfuzz" ]
}
|