Home | History | Annotate | Download | only in fuzzers
      1 # Copyright 2018 Google Inc. All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #     http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 
     15 import("//testing/libfuzzer/fuzzer_test.gni")
     16 import("//testing/test.gni")
     17 
     18 config("fuzzer_config") {
     19   configs = [ "../..:spvtools_internal_config" ]
     20 }
     21 
     22 group("fuzzers") {
     23   testonly = true
     24   deps = []
     25 
     26   if (!build_with_chromium || use_fuzzing_engine) {
     27     deps += [ ":fuzzers_bin" ]
     28   }
     29 }
     30 
     31 if (!build_with_chromium || use_fuzzing_engine) {
     32   group("fuzzers_bin") {
     33     testonly = true
     34 
     35     deps = [
     36       ":spvtools_binary_parser_fuzzer",
     37       ":spvtools_opt_legalization_fuzzer",
     38       ":spvtools_opt_performance_fuzzer",
     39       ":spvtools_opt_size_fuzzer",
     40       ":spvtools_val_fuzzer",
     41     ]
     42   }
     43 }
     44 
     45 template("spvtools_fuzzer") {
     46   source_set(target_name) {
     47     testonly = true
     48     sources = invoker.sources
     49     deps = [
     50       "../..:spvtools",
     51       "../..:spvtools_opt",
     52       "../..:spvtools_val",
     53     ]
     54     if (defined(invoker.deps)) {
     55       deps += invoker.deps
     56     }
     57 
     58     configs -= [ "//build/config/compiler:chromium_code" ]
     59     configs += [
     60       "//build/config/compiler:no_chromium_code",
     61       ":fuzzer_config",
     62     ]
     63   }
     64 }
     65 
     66 spvtools_fuzzer("spvtools_binary_parser_fuzzer_src") {
     67   sources = [
     68     "spvtools_binary_parser_fuzzer.cpp",
     69   ]
     70 }
     71 
     72 spvtools_fuzzer("spvtools_opt_performance_fuzzer_src") {
     73   sources = [
     74     "spvtools_opt_performance_fuzzer.cpp",
     75   ]
     76 }
     77 
     78 spvtools_fuzzer("spvtools_opt_legalization_fuzzer_src") {
     79   sources = [
     80     "spvtools_opt_legalization_fuzzer.cpp",
     81   ]
     82 }
     83 
     84 spvtools_fuzzer("spvtools_opt_size_fuzzer_src") {
     85   sources = [
     86     "spvtools_opt_size_fuzzer.cpp",
     87   ]
     88 }
     89 
     90 spvtools_fuzzer("spvtools_val_fuzzer_src") {
     91   sources = [
     92     "spvtools_val_fuzzer.cpp",
     93   ]
     94 }
     95 
     96 if (!build_with_chromium || use_fuzzing_engine) {
     97   fuzzer_test("spvtools_binary_parser_fuzzer") {
     98     sources = []
     99     deps = [
    100       ":spvtools_binary_parser_fuzzer_src",
    101     ]
    102     # Intentionally doesn't use the seed corpus, because it consumes
    103     #  part of the input as not part of the file.
    104   }
    105 
    106   fuzzer_test("spvtools_opt_performance_fuzzer") {
    107     sources = []
    108     deps = [
    109       ":spvtools_opt_performance_fuzzer_src",
    110     ]
    111     seed_corpus = "corpora/spv"
    112   }
    113 
    114   fuzzer_test("spvtools_opt_legalization_fuzzer") {
    115     sources = []
    116     deps = [
    117       ":spvtools_opt_legalization_fuzzer_src",
    118     ]
    119     seed_corpus = "corpora/spv"
    120   }
    121 
    122   fuzzer_test("spvtools_opt_size_fuzzer") {
    123     sources = []
    124     deps = [
    125       ":spvtools_opt_size_fuzzer_src",
    126     ]
    127     seed_corpus = "corpora/spv"
    128   }
    129 
    130   fuzzer_test("spvtools_val_fuzzer") {
    131     sources = []
    132     deps = [
    133       ":spvtools_val_fuzzer_src",
    134     ]
    135     seed_corpus = "corpora/spv"
    136   }
    137 }
    138