diff options
author | aizatsky <aizatsky@chromium.org> | 2015-12-14 12:59:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-14 21:00:54 +0000 |
commit | cb1a439304d9465d67a4c232c5e3a17c6ab7fc0c (patch) | |
tree | d0f7fc1bde71effd96f10e295d9b37346210c6bb /testing/libfuzzer/fuzzer_test.gni | |
parent | 0f3eb18441ba1c98a8bb7ef8d482b22f682c6968 (diff) | |
download | chromium_src-cb1a439304d9465d67a4c232c5e3a17c6ab7fc0c.zip chromium_src-cb1a439304d9465d67a4c232c5e3a17c6ab7fc0c.tar.gz chromium_src-cb1a439304d9465d67a4c232c5e3a17c6ab7fc0c.tar.bz2 |
Fuzzer_test GN template. Dictionary support.
This CL defines fuzzer_test() GN template with dict attribute support.
When dict attribute is present, test launcher is generated in
<test_name>.sh file to be used by CF. Additional runtime configuration
would also be present in the file in future (custom readonly corpus e.g)
BUG=566105
Review URL: https://codereview.chromium.org/1515123003
Cr-Commit-Position: refs/heads/master@{#365096}
Diffstat (limited to 'testing/libfuzzer/fuzzer_test.gni')
-rw-r--r-- | testing/libfuzzer/fuzzer_test.gni | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni new file mode 100644 index 0000000..db5e438 --- /dev/null +++ b/testing/libfuzzer/fuzzer_test.gni @@ -0,0 +1,83 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//testing/test.gni") + +# fuzzer_test is used to define individual libfuzzer tests. +# +# Supported attributes: +# - (required) sources - fuzzer test source files +# - data - test data files. +# - deps - test dependencies +# - additional_configs - additional configs to be used for compilation +# - dict - a dictionary file for the fuzzer. +# +# The template wraps test() target with appropriate dependencies. +# If any test run-time options are present (dict), then a launcher +# file would be generated with <fuzzer_name>.sh name in root output +# dir (next to test). +template("fuzzer_test") { + assert(defined(invoker.sources), "Need sources in $target_name.") + + test_deps = [ "//testing/libfuzzer:libfuzzer_main" ] + + if (defined(invoker.deps)) { + test_deps += invoker.deps + } + + test_data = [] + if (defined(invoker.data)) { + test_data += invoker.data + } + + if (defined(invoker.dict)) { + fuzzer_name = target_name + launcher_name = target_name + ".sh" + generated_script = "$root_build_dir/$launcher_name" + + # Copy dictionary to output + copy(target_name + "_dict_copy") { + sources = [ + invoker.dict, + ] + outputs = [ + "$target_out_dir/{{source_file_part}}", + ] + } + + # Generate test launcher + action(launcher_name) { + script = "//testing/libfuzzer/gen_fuzzer_runner.py" + args = [ + "--fuzzer", + fuzzer_name, + "--launcher", + rebase_path(generated_script, root_build_dir), + "--dict", + rebase_path("$target_out_dir/" + invoker.dict, root_build_dir), + ] + outputs = [ + generated_script, + ] + } + test_deps += [ + ":$launcher_name", + ":" + fuzzer_name + "_dict_copy", + ] + test_data += [ + invoker.dict, + ":$launcher_name", + ] + } + + test(target_name) { + forward_variables_from(invoker, [ "sources" ]) + deps = test_deps + data = test_data + + if (defined(invoker.additional_configs)) { + configs += invoker.additional_configs + } + } +} |