Systemd/test/fuzz/meson.build
Zbigniew Jędrzejewski-Szmek a412ec5714 meson: fix git ls-files invocations during rebase
Normally ls-files prints the full path to files from the repo root. But when
$GIT_WORK_TREE is set, ls-files prints paths relative to the current
directory. When rebasing, $GIT_WORK_TREE is set in the commands executed from
'rebase -x'. This causes problems if meson config is touched and the meson
reconfigures itself. ($GIT_WORK_TREE shouldn't be relevant, since the paths that
ls-files reports don't depend on the work tree, but whatever.) Let's unset
GIT_WORK_TREE to avoid the issue.

$ (cd test; git --git-dir=$PWD/../.git ls-files ':/test/dmidecode-dumps/*.bin')
test/dmidecode-dumps/HP-Z600.bin
test/dmidecode-dumps/Lenovo-ThinkPad-X280.bin
test/dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin

$ (cd test; GIT_WORK_TREE=$PWD/.. git --git-dir=$PWD/../.git ls-files ':/test/dmidecode-dumps/*.bin')
dmidecode-dumps/HP-Z600.bin
dmidecode-dumps/Lenovo-ThinkPad-X280.bin
dmidecode-dumps/Lenovo-Thinkcentre-m720s.bin

Fixes #18148.
2021-01-09 09:22:26 +09:00

45 lines
1.5 KiB
Meson

# SPDX-License-Identifier: LGPL-2.1-or-later
# The 'optimization' option was introduced in meson 0.48.0, so let's keep
# the code compatible with older versions as well
if meson.version().version_compare('>=0.48.0')
optimization = '--optimization=@0@'.format(get_option('optimization'))
else
optimization = ''
endif
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 @0@'.format(optimization),
' '.join(cc.cmd_array()),
cxx_cmd])
sanitizers = [['address,undefined', sanitize_address_undefined]]
if git.found()
out = run_command(
'env', '-u', 'GIT_WORK_TREE',
git,
'--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/test/fuzz/*/*')
else
out = run_command(
'sh', '-c', 'ls @0@/test/fuzz/*/*'.format(project_source_root))
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 not p.contains('\\')
fuzz_regression_tests += p
endif
endforeach