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