Files
systemd/test/fuzz/meson.build
Michal Koutný 7db5761dda meson: Store fuzz tests in structured way
Put fuzzer tests into dictionary that maps `fuzzer->list of inputs`
instead of the flat list.
This is just refactoring with no intentional .
2022-10-11 09:48:05 +02:00

50 lines
2.0 KiB
Meson

# SPDX-License-Identifier: LGPL-2.1-or-later
sanitize_address_undefined = custom_target(
'sanitize-address-undefined-fuzzers',
output : 'sanitize-address-undefined-fuzzers',
command : [meson_build_sh,
project_source_root,
'@OUTPUT@',
'fuzzers',
'-Dfuzz-tests=true -Db_lundef=false -Db_sanitize=address,undefined --optimization=@0@ @1@ -Dc_args=@2@ -Dcpp_args=@2@ -Dskip-deps=@3@'.format(
get_option('optimization'),
get_option('werror') ? '--werror' : '',
'-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION',
get_option('skip-deps')
),
' '.join(cc.cmd_array()),
cxx_cmd])
fuzz_sanitizers = [['address,undefined', sanitize_address_undefined]]
fuzz_testsdir = 'test/fuzz'
if git.found() and fs.exists(project_source_root / '.git')
out = run_command(env, '-u', 'GIT_WORK_TREE',
git, '--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/@0@/*/*'.format(fuzz_testsdir),
check: true)
else
out = run_command(sh, '-c', 'cd "@0@"; echo @1@/*/*'.format(project_source_root, fuzz_testsdir), check: true)
endif
fuzz_regression_tests = {}
foreach p : out.stdout().split()
# Remove the last entry which is ''.
#
# Also, backslashes get mangled, so skip test. See
# https://github.com/mesonbuild/meson/issues/1564.
if p.contains('\\')
continue
endif
fuzzer = p.split('/')[-2]
fuzz_in = p.split('/')[-1]
if fuzzer not in fuzz_regression_tests
fuzz_regression_tests += {fuzzer: []}
endif
# Meson parser provision for: fuzz_regression_tests[fuzzer] += [fuzz_in]
l = fuzz_regression_tests[fuzzer]
l += [fuzz_in]
fuzz_regression_tests += {fuzzer: l}
endforeach