1# Copyright 2016 gRPC authors. 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"""Create tests for each fuzzer""" 15 16import copy 17import glob 18 19 20def mako_plugin(dictionary): 21 targets = dictionary['targets'] 22 tests = dictionary['tests'] 23 for tgt in targets: 24 if tgt['build'] == 'fuzzer': 25 new_target = copy.deepcopy(tgt) 26 new_target['build'] = 'test' 27 new_target['name'] += '_one_entry' 28 new_target['run'] = False 29 new_target['src'].append( 30 'test/core/util/one_corpus_entry_fuzzer.cc') 31 new_target['own_src'].append( 32 'test/core/util/one_corpus_entry_fuzzer.cc') 33 34 # avoid having two main() methods 35 to_remove = 'test/core/util/fuzzer_corpus_test.cc' 36 if to_remove in new_target['src']: 37 new_target['src'].remove(to_remove) 38 if to_remove in new_target['own_src']: 39 new_target['own_src'].remove(to_remove) 40 41 targets.append(new_target) 42 for corpus in new_target['corpus_dirs']: 43 for fn in sorted(glob.glob('%s/*' % corpus)): 44 tests.append({ 45 'name': new_target['name'], 46 'args': [fn], 47 'exclude_iomgrs': ['uv'], 48 'exclude_configs': ['tsan'], 49 'uses_polling': False, 50 'platforms': ['mac', 'linux'], 51 'ci_platforms': ['linux'], 52 'flaky': False, 53 'language': 'c', 54 'cpu_cost': 0.1, 55 }) 56