Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: testing/libfuzzer/fuzzer_test.gni

Issue 1867833002: [libfuzzer] store custom options in .GN build target instead of a separate file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update reference.md of libFuzzer & CF documentation. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/libfuzzer/efficient_fuzzer.md ('k') | testing/libfuzzer/fuzzers/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Defines fuzzer_test. 5 # Defines fuzzer_test.
6 # 6 #
7 import("//build/config/features.gni") 7 import("//build/config/features.gni")
8 import("//build/config/sanitizers/sanitizers.gni") 8 import("//build/config/sanitizers/sanitizers.gni")
9 import("//testing/test.gni") 9 import("//testing/test.gni")
10 10
(...skipping 18 matching lines...) Expand all
29 template("fuzzer_test") { 29 template("fuzzer_test") {
30 if (!disable_libfuzzer && (use_libfuzzer || use_drfuzz || is_linux)) { 30 if (!disable_libfuzzer && (use_libfuzzer || use_drfuzz || is_linux)) {
31 assert(defined(invoker.sources), "Need sources in $target_name.") 31 assert(defined(invoker.sources), "Need sources in $target_name.")
32 32
33 test_deps = [ "//testing/libfuzzer:libfuzzer_main" ] 33 test_deps = [ "//testing/libfuzzer:libfuzzer_main" ]
34 34
35 if (defined(invoker.deps)) { 35 if (defined(invoker.deps)) {
36 test_deps += invoker.deps 36 test_deps += invoker.deps
37 } 37 }
38 38
39 if (defined(invoker.libfuzzer_options) && !defined(invoker.dict)) {
40 # Copy libfuzzer_options to output if dict is not provided.
41 copy(target_name + "_libfuzzer_options_copy") {
42 sources = [
43 invoker.libfuzzer_options,
44 ]
45 outputs = [
46 "$root_build_dir/" + target_name + ".options",
47 ]
48 }
49
50 test_deps += [ ":" + target_name + "_libfuzzer_options_copy" ]
51 }
52
53 if (defined(invoker.seed_corpus)) { 39 if (defined(invoker.seed_corpus)) {
54 depfile = "$root_build_dir/$target_name" + ".seed_corpus.d" 40 depfile = "$root_build_dir/$target_name" + ".seed_corpus.d"
55 out = "$root_build_dir/$target_name" + "_seed_corpus.zip" 41 out = "$root_build_dir/$target_name" + "_seed_corpus.zip"
56 42
57 action(target_name + "_seed_corpus") { 43 action(target_name + "_seed_corpus") {
58 script = "//testing/libfuzzer/archive_corpus.py" 44 script = "//testing/libfuzzer/archive_corpus.py"
59 args = [ 45 args = [
60 "--depfile", 46 "--depfile",
61 rebase_path(depfile), 47 rebase_path(depfile),
62 "--corpus", 48 "--corpus",
63 rebase_path(invoker.seed_corpus), 49 rebase_path(invoker.seed_corpus),
64 "--output", 50 "--output",
65 rebase_path(out), 51 rebase_path(out),
66 "--fuzzer", 52 "--fuzzer",
67 rebase_path("$root_build_dir/$target_name"), 53 rebase_path("$root_build_dir/$target_name"),
68 ] 54 ]
69 55
70 depfile = depfile 56 depfile = depfile
71 outputs = [ 57 outputs = [
72 out, 58 out,
73 ] 59 ]
74 deps = [ 60 deps = [
75 "//testing/libfuzzer:seed_corpus", 61 "//testing/libfuzzer:seed_corpus",
76 ] 62 ]
77 } 63 }
78 64
79 test_deps += [ ":" + target_name + "_seed_corpus" ] 65 test_deps += [ ":" + target_name + "_seed_corpus" ]
80 } 66 }
81 67
82 if (defined(invoker.dict)) { 68 if (defined(invoker.dict) || defined(invoker.libfuzzer_options)) {
83 # Copy dictionary to output. 69 if (defined(invoker.dict)) {
84 copy(target_name + "_dict_copy") { 70 # Copy dictionary to output.
85 sources = [ 71 copy(target_name + "_dict_copy") {
86 invoker.dict, 72 sources = [
87 ] 73 invoker.dict,
88 outputs = [ 74 ]
89 "$root_build_dir/" + target_name + ".dict", 75 outputs = [
90 ] 76 "$root_build_dir/" + target_name + ".dict",
77 ]
78 }
79 test_deps += [ ":" + target_name + "_dict_copy" ]
91 } 80 }
92 81
93 test_deps += [ ":" + target_name + "_dict_copy" ] 82 # Generate .options file.
94
95 # Generate new .options file or update an existing one.
96 config_name = target_name + ".options" 83 config_name = target_name + ".options"
97 action(config_name) { 84 action(config_name) {
98 script = "//testing/libfuzzer/gen_fuzzer_config.py" 85 script = "//testing/libfuzzer/gen_fuzzer_config.py"
99 args = [ 86 args = [
100 "--config", 87 "--config",
101 rebase_path("$root_build_dir/" + config_name), 88 rebase_path("$root_build_dir/" + config_name),
102 "--dict",
103 rebase_path("$root_build_dir/" + invoker.target_name + ".dict"),
104 ] 89 ]
105 90
106 if (defined(invoker.libfuzzer_options)) { 91 if (defined(invoker.dict)) {
107 args += [ 92 args += [
108 "--libfuzzer_options", 93 "--dict",
109 rebase_path(invoker.libfuzzer_options), 94 rebase_path("$root_build_dir/" + invoker.target_name + ".dict"),
110 ] 95 ]
111 } 96 }
97
98 if (defined(invoker.libfuzzer_options)) {
99 args += [ "--libfuzzer_options" ]
100 args += invoker.libfuzzer_options
101 }
102
112 outputs = [ 103 outputs = [
113 "$root_build_dir/$config_name", 104 "$root_build_dir/$config_name",
114 ] 105 ]
115 } 106 }
116 test_deps += [ ":" + config_name ] 107 test_deps += [ ":" + config_name ]
117 } 108 }
118 109
119 test(target_name) { 110 test(target_name) {
120 forward_variables_from(invoker, 111 forward_variables_from(invoker,
121 [ 112 [
(...skipping 24 matching lines...) Expand all
146 assert(invoker.libfuzzer_options == [] || invoker.libfuzzer_options != []) 137 assert(invoker.libfuzzer_options == [] || invoker.libfuzzer_options != [])
147 } 138 }
148 if (defined(invoker.seed_corpus)) { 139 if (defined(invoker.seed_corpus)) {
149 assert(invoker.seed_corpus == [] || invoker.seed_corpus != []) 140 assert(invoker.seed_corpus == [] || invoker.seed_corpus != [])
150 } 141 }
151 142
152 group(target_name) { 143 group(target_name) {
153 } 144 }
154 } 145 }
155 } 146 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/efficient_fuzzer.md ('k') | testing/libfuzzer/fuzzers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698