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