systemd/test/meson.build

205 lines
8 KiB
Meson
Raw Normal View History

# SPDX-License-Identifier: LGPL-2.1-or-later
if install_tests
testdata_dir = testsdir + '/testdata/'
install_subdir('journal-data',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('test-execute',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('test-fstab-generator',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('test-path',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('test-path-util',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('test-umount',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('test-network-generator-conversion',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-04.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-06.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-10.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-11.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-16.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-28.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-30.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-52.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_subdir('testsuite-63.units',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
install_data(kbd_model_map,
install_dir : testdata_dir + '/test-keymap-util')
testsuite08_dir = testdata_dir + '/testsuite-08.units'
install_data('testsuite-08.units/-.mount',
install_dir : testsuite08_dir)
install_data('testsuite-08.units/systemd-remount-fs.service',
install_dir : testsuite08_dir)
meson.add_install_script(meson_make_symlink,
'./-.mount',
testsuite08_dir + '/root.mount')
meson.add_install_script(meson_make_symlink,
'../-.mount',
testsuite08_dir + '/local-fs.target.wants/-.mount')
2021-12-10 10:55:38 +00:00
if conf.get('HAVE_GNU_EFI') == 1 and conf.get('HAVE_ZSTD') == 1
install_subdir('test-bcd',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
endif
if conf.get('ENABLE_RESOLVE') == 1
install_subdir('test-resolve',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
endif
install_data('create-busybox-container',
install_mode : 'rwxr-xr-x',
install_dir : testdata_dir)
endif
test_fstab_generator_sh = find_program('test-fstab-generator.sh')
test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
test_systemctl_enable_sh = find_program('test-systemctl-enable.sh')
test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py')
hwdb_test_sh = find_program('hwdb-test.sh')
############################################################
test_sysusers_sh = configure_file(
input : 'test-sysusers.sh.in',
output : 'test-sysusers.sh',
configuration : conf)
if install_tests and conf.get('ENABLE_SYSUSERS') == 1
install_data(test_sysusers_sh,
install_dir : testsdir)
install_subdir('test-sysusers',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
endif
############################################################
meson: re-attach rule-syntax-check.py test 39/248 rule-syntax-check OK 0.07 s --- command --- /home/zbyszek/src/systemd-work/test/rule-syntax-check.py \ /home/zbyszek/src/systemd-work/build/../rules/60-block.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-cdrom_id.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-drm.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-evdev.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-input-id.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-alsa.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-input.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-storage.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-storage-tape.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-v4l.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-sensor.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-serial.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-joystick.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-mouse.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-touchpad.rules \ /home/zbyszek/src/systemd-work/build/../rules/75-net-description.rules \ /home/zbyszek/src/systemd-work/build/../rules/75-probe_mtd.rules \ /home/zbyszek/src/systemd-work/build/../rules/78-sound-card.rules \ /home/zbyszek/src/systemd-work/build/../rules/80-drivers.rules \ /home/zbyszek/src/systemd-work/build/../rules/80-net-setup-link.rules \ /home/zbyszek/src/systemd-work/build/rules/50-udev-default.rules \ /home/zbyszek/src/systemd-work/build/rules/64-btrfs.rules \ /home/zbyszek/src/systemd-work/build/rules/99-systemd.rules --- stdout --- ... ------- It got dropped by mistake in 72cdb3e783174dcf9223a49f03e3b0e2ca95ddb8.
2017-11-22 11:42:28 +00:00
rule_syntax_check_py = find_program('rule-syntax-check.py')
if want_tests != 'false'
test('rule-syntax-check',
rule_syntax_check_py,
suite : 'dist-check',
args : all_rules)
endif
meson: re-attach rule-syntax-check.py test 39/248 rule-syntax-check OK 0.07 s --- command --- /home/zbyszek/src/systemd-work/test/rule-syntax-check.py \ /home/zbyszek/src/systemd-work/build/../rules/60-block.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-cdrom_id.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-drm.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-evdev.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-input-id.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-alsa.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-input.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-storage.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-storage-tape.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-v4l.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-sensor.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-serial.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-joystick.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-mouse.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-touchpad.rules \ /home/zbyszek/src/systemd-work/build/../rules/75-net-description.rules \ /home/zbyszek/src/systemd-work/build/../rules/75-probe_mtd.rules \ /home/zbyszek/src/systemd-work/build/../rules/78-sound-card.rules \ /home/zbyszek/src/systemd-work/build/../rules/80-drivers.rules \ /home/zbyszek/src/systemd-work/build/../rules/80-net-setup-link.rules \ /home/zbyszek/src/systemd-work/build/rules/50-udev-default.rules \ /home/zbyszek/src/systemd-work/build/rules/64-btrfs.rules \ /home/zbyszek/src/systemd-work/build/rules/99-systemd.rules --- stdout --- ... ------- It got dropped by mistake in 72cdb3e783174dcf9223a49f03e3b0e2ca95ddb8.
2017-11-22 11:42:28 +00:00
############################################################
tests: add a runner for installed tests We have "installed tests", but don't provide an easy way to run them. The protocol is very simple: each test must return 0 for success, 77 means "skipped", anything else is an error. In addition, we want to print test output only if the test failed. I wrote this simple script. It is pretty basic, but implements the functions listed above. Since it is written in python it should be easy to add option parsing (like running only specific tests, or running unsafe tests, etc.) I looked at the following alternatives: - Ubuntu root-unittests: this works, but just dumps all output to the terminal, has no coloring. - @ssahani's test runner [2] It uses the unittest library and the test suite was implented as a class, and doesn't implement any of the functions listed above. - cram [3,4] cram runs our tests, but does not understand the "ignore the output" part, has not support for our magic skip code (it uses hardcoded 80 instead), and seems dead upstream. - meson test Here the idea would be to provide an almost-empty meson.build file under /usr/lib/systemd/tests/ that would just define all the tests. This would allow us to reuse the test runner we use normally. Unfortunately meson requires a build directory and configuration to be done before running tests. This would be possible, but seems a lot of effort to just run a few binaries. [1] https://salsa.debian.org/systemd-team/systemd/blob/242c96addb06480ec9cd75248a5660f37a17b4b9/debian/tests/root-unittests [2] https://github.com/systemd/systemd-fedora-ci/blob/master/upstream/systemd-upstream-tests.py [3] https://bitheap.org/cram/ [4] https://pypi.org/project/pytest-cram/ Fixes #10069.
2018-09-20 14:34:14 +00:00
if install_tests
install_data('run-unit-tests.py',
install_mode : 'rwxr-xr-x',
install_dir : testsdir)
install_data('test-fstab-generator.sh',
install_mode : 'rwxr-xr-x',
install_dir : testsdir)
install_data('test-network-generator-conversion.sh',
install_mode : 'rwxr-xr-x',
install_dir : testsdir)
tests: add a runner for installed tests We have "installed tests", but don't provide an easy way to run them. The protocol is very simple: each test must return 0 for success, 77 means "skipped", anything else is an error. In addition, we want to print test output only if the test failed. I wrote this simple script. It is pretty basic, but implements the functions listed above. Since it is written in python it should be easy to add option parsing (like running only specific tests, or running unsafe tests, etc.) I looked at the following alternatives: - Ubuntu root-unittests: this works, but just dumps all output to the terminal, has no coloring. - @ssahani's test runner [2] It uses the unittest library and the test suite was implented as a class, and doesn't implement any of the functions listed above. - cram [3,4] cram runs our tests, but does not understand the "ignore the output" part, has not support for our magic skip code (it uses hardcoded 80 instead), and seems dead upstream. - meson test Here the idea would be to provide an almost-empty meson.build file under /usr/lib/systemd/tests/ that would just define all the tests. This would allow us to reuse the test runner we use normally. Unfortunately meson requires a build directory and configuration to be done before running tests. This would be possible, but seems a lot of effort to just run a few binaries. [1] https://salsa.debian.org/systemd-team/systemd/blob/242c96addb06480ec9cd75248a5660f37a17b4b9/debian/tests/root-unittests [2] https://github.com/systemd/systemd-fedora-ci/blob/master/upstream/systemd-upstream-tests.py [3] https://bitheap.org/cram/ [4] https://pypi.org/project/pytest-cram/ Fixes #10069.
2018-09-20 14:34:14 +00:00
endif
############################################################
# prepare test/sys tree
sys_script_py = find_program('sys-script.py')
custom_target(
'sys',
command : [sys_script_py, meson.current_build_dir()],
output : 'sys',
build_by_default : want_tests != 'false')
if perl.found()
udev_test_pl = find_program('udev-test.pl')
if want_tests != 'false'
test('udev-test',
udev_test_pl,
timeout : 180)
endif
else
message('Skipping udev-test because perl is not available')
endif
############################################################
rpm = find_program('rpm', required : false)
rpmspec = find_program('rpmspec', required : false)
test_rpm_macros = find_program('test-rpm-macros.sh')
if rpm.found() and rpmspec.found()
if want_tests != 'false'
test('test-rpm-macros',
test_rpm_macros,
suite : 'dist-check',
args : [project_build_root])
endif
else
message('Skipping test-rpm-macros since rpm and/or rpmspec are not available')
endif
############################################################
if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
if git.found() and fs.exists(project_source_root / '.git')
out = run_command(
meson: call find_program() once and reuse the variable everywhere Meson 0.58 has gotten quite bad with emitting a message every time a quoted command is used: Program /home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh found: YES (/home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh) Program sh found: YES (/usr/bin/sh) Program sh found: YES (/usr/bin/sh) Program sh found: YES (/usr/bin/sh) Program sh found: YES (/usr/bin/sh) Program sh found: YES (/usr/bin/sh) Program sh found: YES (/usr/bin/sh) Program xsltproc found: YES (/usr/bin/xsltproc) Configuring custom-entities.ent using configuration Message: Skipping bootctl.1 because ENABLE_EFI is false Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Message: Skipping journal-remote.conf.5 because HAVE_MICROHTTPD is false Message: Skipping journal-upload.conf.5 because HAVE_MICROHTTPD is false Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Message: Skipping loader.conf.5 because ENABLE_EFI is false Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) Program ln found: YES (/usr/bin/ln) ... Let's suffer one message only for each command. Hopefully we can silence even this when https://github.com/mesonbuild/meson/issues/8642 is resolved.
2021-05-14 12:16:17 +00:00
env, '-u', 'GIT_WORK_TREE',
git, '--git-dir=@0@/.git'.format(project_source_root),
'ls-files', ':/test/dmidecode-dumps/*.bin',
check: true)
else
out = run_command(
sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root,
check: true)
endif
foreach p : out.stdout().split()
source = project_source_root / p
name = 'dmidecode_' + p.split('/')[-1].split('.')[0]
test(name,
udev_dmi_memory_id_test,
suite : 'dist-check',
args : [udev_prog_paths['dmi_memory_id'].full_path(),
2021-07-27 15:48:53 +00:00
source,
source + '.txt'],
depends : udev_prog_paths['dmi_memory_id'])
endforeach
endif
fuzz: unify the "fuzz-regressions" directory with the main corpus There isn't really much need to keep them separate. Anything which is a good corpus entry can be used as a smoke test, and anything which which is a regression test can just as well be inserted into the corpus. The only functional difference from this patch (apart from different paths in output) is that the regression tests are now zipped together with the rest of the corpus. $ meson configure build -Dslow-tests=true && ninja -C build test ... 307/325 fuzz-dns-packet:issue-7888:address OK 0.06 s 308/325 fuzz-dns-packet:oss-fuzz-5465:address OK 0.04 s 309/325 fuzz-journal-remote:crash-5a8f03d4c3a46fcded39527084f437e8e4b54b76:address OK 0.07 s 310/325 fuzz-journal-remote:crash-96dee870ea66d03e89ac321eee28ea63a9b9aa45:address OK 0.05 s 311/325 fuzz-journal-remote:oss-fuzz-8659:address OK 0.05 s 312/325 fuzz-journal-remote:oss-fuzz-8686:address OK 0.07 s 313/325 fuzz-unit-file:oss-fuzz-6884:address OK 0.06 s 314/325 fuzz-unit-file:oss-fuzz-6885:address OK 0.05 s 315/325 fuzz-unit-file:oss-fuzz-6886:address OK 0.05 s 316/325 fuzz-unit-file:oss-fuzz-6892:address OK 0.05 s 317/325 fuzz-unit-file:oss-fuzz-6897:address OK 0.05 s 318/325 fuzz-unit-file:oss-fuzz-6897-evverx:address OK 0.06 s 319/325 fuzz-unit-file:oss-fuzz-6908:address OK 0.07 s 320/325 fuzz-unit-file:oss-fuzz-6917:address OK 0.07 s 321/325 fuzz-unit-file:oss-fuzz-6977:address OK 0.13 s 322/325 fuzz-unit-file:oss-fuzz-6977-unminimized:address OK 0.12 s 323/325 fuzz-unit-file:oss-fuzz-7004:address OK 0.05 s 324/325 fuzz-unit-file:oss-fuzz-8064:address OK 0.05 s 325/325 fuzz-unit-file:oss-fuzz-8827:address OK 0.52 s
2018-07-07 16:09:21 +00:00
subdir('fuzz')