summaryrefslogtreecommitdiffstats
path: root/testing/libfuzzer
diff options
context:
space:
mode:
authoraizatsky <aizatsky@chromium.org>2016-02-12 17:22:18 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-13 01:23:02 +0000
commit43d459a5b49f03b1d57270a0696ac202ab09a7df (patch)
tree93d32e42e5321c49def7ce8958f8a686de4fee37 /testing/libfuzzer
parente53d9c39108b08a8f5f329e0eb70b5c8c3626b3b (diff)
downloadchromium_src-43d459a5b49f03b1d57270a0696ac202ab09a7df.zip
chromium_src-43d459a5b49f03b1d57270a0696ac202ab09a7df.tar.gz
chromium_src-43d459a5b49f03b1d57270a0696ac202ab09a7df.tar.bz2
Make fuzzer_test a no-op on unsupported platforms.
BUG=586030 Review URL: https://codereview.chromium.org/1692333002 Cr-Commit-Position: refs/heads/master@{#375314}
Diffstat (limited to 'testing/libfuzzer')
-rw-r--r--testing/libfuzzer/fuzzer_test.gni107
1 files changed, 66 insertions, 41 deletions
diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni
index 6a8cf98..2064f6c 100644
--- a/testing/libfuzzer/fuzzer_test.gni
+++ b/testing/libfuzzer/fuzzer_test.gni
@@ -4,6 +4,8 @@
# Defines fuzzer_test.
#
+import("//build/config/features.gni")
+import("//build/config/sanitizers/sanitizers.gni")
import("//testing/test.gni")
# visible for testing only.
@@ -38,63 +40,86 @@ template("fuzzer_test_launcher") {
# - additional_configs - additional configs to be used for compilation
# - dict - a dictionary file for the fuzzer.
#
+# If use_libfuzzer gn flag is defined, then proper fuzzer would be build.
+# Without use_libfuzzer a unit-test style binary would be built on linux
+# and the whole target is a no-op otherwise.
+#
# 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.")
+ if (!disable_libfuzzer && (use_libfuzzer || use_drfuzz || is_linux)) {
+ assert(defined(invoker.sources), "Need sources in $target_name.")
- test_deps = [ "//testing/libfuzzer:libfuzzer_main" ]
+ test_deps = [ "//testing/libfuzzer:libfuzzer_main" ]
- if (defined(invoker.deps)) {
- test_deps += invoker.deps
- }
+ if (defined(invoker.deps)) {
+ test_deps += invoker.deps
+ }
- test_data = []
- if (defined(invoker.data)) {
- test_data += invoker.data
- }
+ test_data = []
+ if (defined(invoker.data)) {
+ test_data += invoker.data
+ }
- if (defined(invoker.dict)) {
- fuzzer_name = target_name
- launcher_name = target_name + ".sh"
+ if (defined(invoker.dict)) {
+ fuzzer_name = target_name
+ launcher_name = target_name + ".sh"
- # Copy dictionary to output
- copy(target_name + "_dict_copy") {
- sources = [
- invoker.dict,
+ # Copy dictionary to output
+ copy(target_name + "_dict_copy") {
+ sources = [
+ invoker.dict,
+ ]
+ outputs = [
+ "$root_build_dir/" + invoker.dict,
+ ]
+ }
+
+ fuzzer_test_launcher(launcher_name) {
+ dict = invoker.dict
+ }
+
+ test_deps += [
+ ":$launcher_name",
+ ":" + fuzzer_name + "_dict_copy",
]
- outputs = [
- "$root_build_dir/" + invoker.dict,
+ test_data += [
+ invoker.dict,
+ ":$launcher_name",
]
}
- fuzzer_test_launcher(launcher_name) {
- dict = invoker.dict
- }
-
- test_deps += [
- ":$launcher_name",
- ":" + fuzzer_name + "_dict_copy",
- ]
- test_data += [
- invoker.dict,
- ":$launcher_name",
- ]
- }
-
- test(target_name) {
- forward_variables_from(invoker,
- [
- "sources",
- "include_dirs",
- ])
- deps = test_deps
- data = test_data
+ test(target_name) {
+ forward_variables_from(invoker,
+ [
+ "sources",
+ "include_dirs",
+ ])
+ deps = test_deps
+ data = test_data
+ if (defined(invoker.additional_configs)) {
+ configs += invoker.additional_configs
+ }
+ }
+ } else {
+ # noop on unsupported platforms.
+ # mark attributes as used.
+ assert(invoker.sources == [] || invoker.sources != [])
if (defined(invoker.additional_configs)) {
- configs += invoker.additional_configs
+ assert(
+ invoker.additional_configs == [] || invoker.additional_configs != [])
+ }
+ if (defined(invoker.deps)) {
+ assert(invoker.deps == [] || invoker.deps != [])
+ }
+ if (defined(invoker.dict)) {
+ assert(invoker.dict == [] || invoker.dict != [])
+ }
+
+ group(target_name) {
}
}
}