Commit 90e9fb17 authored by Calder Kitagawa's avatar Calder Kitagawa Committed by Commit Bot

[libfuzzer] Add seed_corpus_deps

Zucchini has a use case for libfuzzer where the seed corpus can be
generated at compile time. The reason for this is that as the Zucchini
patch format changes the seeds need to change to reflect the new
format.

To do this at compile time a gn action that executes a python script
needs to be executed before the seed_corpus action occurs in the
fuzzer_test template. Adding the seed generation action to fuzzer_test
deps is insufficient since the seed_corpus action can executed before
seed exists. The solution to this is to add deps to the seed_corpus
action that perform the dependent action prior to the seed_corpus
archive generation.

Change-Id: Icd90e308102d9c5b5923aa93a466bd3f39387702
Reviewed-on: https://chromium-review.googlesource.com/1044116Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@google.com>
Cr-Commit-Position: refs/heads/master@{#556460}
parent 503c69a4
......@@ -18,6 +18,7 @@ import("//testing/test.gni")
# - dict - a dictionary file for the fuzzer.
# - libfuzzer_options - options for the fuzzer (e.g. -max_len or -timeout).
# - seed_corpus - a directory with seed corpus.
# - seed_corpus_deps - dependencies for generating the seed corpus.
# - skip_owners - if true, skips writing the owners file.
#
# If use_libfuzzer gn flag is defined, then proper fuzzer would be build.
......@@ -48,6 +49,12 @@ template("fuzzer_test") {
out = "$root_build_dir/$target_name" + "_seed_corpus.zip"
seed_corpus_deps = []
if (defined(invoker.seed_corpus_deps)) {
seed_corpus_deps += invoker.seed_corpus_deps
}
action(target_name + "_seed_corpus") {
script = "//testing/libfuzzer/archive_corpus.py"
......@@ -70,9 +77,7 @@ template("fuzzer_test") {
out,
]
deps = [
"//testing/libfuzzer:seed_corpus",
]
deps = [ "//testing/libfuzzer:seed_corpus" ] + seed_corpus_deps
}
test_deps += [ ":" + target_name + "_seed_corpus" ]
......@@ -195,6 +200,9 @@ template("fuzzer_test") {
if (defined(invoker.seed_corpuses)) {
assert(invoker.seed_corpuses == [] || invoker.seed_corpuses != [])
}
if (defined(invoker.seed_corpus_deps)) {
assert(invoker.seed_corpus_deps == [] || invoker.seed_corpus_deps != [])
}
assert(!defined(invoker.check_includes) || invoker.check_includes != [])
assert(!defined(invoker.include_dirs) || invoker.include_dirs != [])
assert(!defined(invoker.defines) || invoker.defines != [])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment