1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
systemd/test/meson.build
Zbigniew Jędrzejewski-Szmek 0454cf05d3 test: rework how udev-test is invoked
As part of the build, we would populate build/test/sys/ using
sys-script.py, and then udev-test.p[ly] would create a tmpfs instance
on build/test/tmpfs and copy the sys tree to build/test/tmpfs/sys.

Also, we had udev-test.p[ly] which called test-udev. test-udev was
marked as a manual test and installed, but neither udev-test.p[ly] or
sys-script.py were.

test-udev is renamed to udev-rule-runner, which reduces confusion and
frees up the test-udev name. udev-test.py is renamed to test-udev.py.
All three files are now installed.

test-udev.py is modified to internally call sys-script.py to set up the
sys tree. Copying and creating it from scratch should take the same
amount of time. We avoid having a magic directory, everything is now
done underneath a temporary directory.

test-udev.py is now a normal installed test, and run-unit-tests.py will
pick it up. When test-udev.py is invoked from meson, the path to
udev-rule-runner is passed via envvar; when it is invoked via
run-unit-tests.py or directly, it looks for udev-rule-runner in a relative
path.

The goal of this whole change is to let Debian drop the 'udev' test.
It called sys-script.py and udev-test.pl from the source directory and
had to recreate a bunch of the logic. Now test-udev.py will now be called
via 'upstream'.
2023-05-09 08:11:10 +02:00

185 lines
6.6 KiB
Meson

# SPDX-License-Identifier: LGPL-2.1-or-later
if install_tests
foreach subdir : [
'auxv',
'journal-data',
'units',
'test-execute',
'test-fstab-generator',
'test-path',
'test-path-util',
'test-umount',
'test-network',
'test-network-generator-conversion',
'testsuite-03.units',
'testsuite-04.units',
'testsuite-06.units',
'testsuite-10.units',
'testsuite-11.units',
'testsuite-16.units',
'testsuite-28.units',
'testsuite-30.units',
'testsuite-52.units',
'testsuite-63.units',
'testsuite-80.units',
]
install_subdir(subdir,
exclude_files : '.gitattributes',
install_dir : testdata_dir)
endforeach
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')
if conf.get('HAVE_ZSTD') == 1 and efi_arch != ''
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)
# The unit tests implemented as shell scripts expect to find testdata/
# in the directory where they are stored.
meson.add_install_script(meson_make_symlink,
testdata_dir,
unittestsdir / 'testdata')
endif
test_bootctl_json_sh = find_program('test-bootctl-json.sh')
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 : unittestsdir)
install_subdir('test-sysusers',
exclude_files : '.gitattributes',
install_dir : testdata_dir)
endif
############################################################
test_compare_versions_sh = files('test-compare-versions.sh')
if install_tests
install_data(test_compare_versions_sh,
install_dir : unittestsdir)
endif
############################################################
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
############################################################
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 : unittestsdir)
install_data('test-network-generator-conversion.sh',
install_mode : 'rwxr-xr-x',
install_dir : unittestsdir)
endif
############################################################
sys_script_py = files('sys-script.py')
test_udev_py = files('test-udev.py')
if install_tests
install_data(
sys_script_py,
test_udev_py,
install_dir : unittestsdir)
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.is_dir(project_source_root / '.git')
out = run_command(
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(),
source,
source + '.txt'],
depends : udev_prog_paths['dmi_memory_id'])
endforeach
endif
subdir('fuzz')