diff options
Diffstat (limited to 'pw_fuzzer/fuzzer.gni')
-rw-r--r-- | pw_fuzzer/fuzzer.gni | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/pw_fuzzer/fuzzer.gni b/pw_fuzzer/fuzzer.gni index 4a6fbf438..776fa5d5c 100644 --- a/pw_fuzzer/fuzzer.gni +++ b/pw_fuzzer/fuzzer.gni @@ -26,17 +26,22 @@ import("$dir_pw_unit_test/test.gni") # https://llvm.org/docs/LibFuzzer.html # template("pw_fuzzer") { - # This currently is ONLY supported on Linux using clang (debug). - # TODO(pwbug/179): Add Darwin, Windows here after testing. - fuzzing_platforms = [ "linux" ] - fuzzing_toolchains = - [ get_path_info("$dir_pw_toolchain:host_clang_og", "abspath") ] + # This currently is ONLY supported on Linux and Mac using clang (debug). + # TODO(pwbug/179): Add Windows here after testing. + fuzzing_platforms = [ + "linux", + "mac", + ] + + fuzzing_toolchains = [ "//targets/host:host_clang_fuzz" ] # This is how GN says 'elem in list': can_fuzz = fuzzing_platforms + [ host_os ] - [ host_os ] != fuzzing_platforms + can_fuzz = fuzzing_toolchains + [ current_toolchain ] - [ current_toolchain ] != fuzzing_toolchains && can_fuzz - if (can_fuzz && pw_sanitizer != "") { + + if (can_fuzz && pw_toolchain_SANITIZERS != []) { # Build the actual fuzzer using the fuzzing config. pw_executable(target_name) { forward_variables_from(invoker, "*", [ "visibility" ]) @@ -44,23 +49,26 @@ template("pw_fuzzer") { if (!defined(configs)) { configs = [] } - configs += [ - "$dir_pw_fuzzer:default_config", - "$dir_pw_fuzzer:sanitize_${pw_sanitizer}", - ] - if (oss_fuzz_enabled) { + configs += [ "$dir_pw_fuzzer:default_config" ] + if (pw_toolchain_OSS_FUZZ_ENABLED) { configs += [ "$dir_pw_fuzzer:oss_fuzz" ] } else { configs += [ "$dir_pw_fuzzer:fuzzing" ] } + _fuzzer_output_dir = "${target_out_dir}/bin" + if (defined(invoker.output_dir)) { + _fuzzer_output_dir = invoker.output_dir + } + output_dir = _fuzzer_output_dir + # Metadata for this fuzzer when used as part of a pw_test_group target. metadata = { tests = [ { type = "fuzzer" test_name = target_name - test_directory = rebase_path(target_out_dir, root_build_dir) + test_directory = rebase_path(output_dir, root_build_dir) }, ] } @@ -68,7 +76,12 @@ template("pw_fuzzer") { # Dummy target to satisfy `pw_test_group`. It is empty as we don't want to # automatically run fuzzers. - group(target_name + "_run") { + group(target_name + ".run") { + } + + # Dummy target to satisfy `pw_test`. It is empty as we don't need a separate + # lib target. + group(target_name + ".lib") { } } else { # Build a unit test that exercise the fuzz target function. |