1fs = import('fs') 2 3fuzz_targets = [ 4 'fuzz_decode_data_uri', 5 'fuzz_cookie_parse', 6 'fuzz_content_sniffer', 7 'fuzz_date_time', 8] 9 10fuzzing_args = '-fsanitize=fuzzer,address,undefined' 11have_fuzzing = cc.has_argument(fuzzing_args) 12fuzzing_feature = get_option('fuzzing') 13 14if not have_fuzzing and fuzzing_feature.enabled() 15 error('clang and libfuzzer are required for fuzzing') 16endif 17 18if have_fuzzing and (fuzzing_feature.enabled() or fuzzing_feature.auto()) 19 foreach target : fuzz_targets 20 exe = executable(target, [target + '.c'], 21 c_args : [fuzzing_args, '-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION'], 22 link_args : fuzzing_args, 23 dependencies : libsoup_dep, 24 ) 25 26 extra_args = [] 27 dict_file = join_paths(meson.current_source_dir(), target + '.dict') 28 if fs.exists(dict_file) 29 extra_args += '-dict=' + dict_file 30 endif 31 32 test(target, exe, 33 args: [ 34 '-runs=200000', 35 '-artifact_prefix=meson-logs/' + target + '-', 36 '-print_final_stats=1', 37 ] + extra_args, 38 env: [ 39 'ASAN_OPTIONS=fast_unwind_on_malloc=0', 40 'UBSAN_OPTIONS=print_stacktrace=1', 41 ], 42 suite: 'fuzzing', 43 timeout: 360, 44 priority: -1, 45 ) 46 endforeach 47endif