1 # SPDX-License-Identifier: LGPL-2.1-or-later
3 if conf.get('ENABLE_SYSUSERS') == 1
4 test_sysusers_sh = configure_file(
5 input : 'test-sysusers.sh.in',
6 output : 'test-sysusers.sh',
9 if want_tests != 'false'
10 exe = executables_by_name.get('systemd-sysusers')
13 # https://github.com/mesonbuild/meson/issues/2681
14 args : exe.full_path(),
18 if have_standalone_binaries
19 exe = executables_by_name.get('systemd-sysusers.standalone')
20 test('test-sysusers.standalone',
22 # https://github.com/mesonbuild/meson/issues/2681
23 args : exe.full_path(),
30 install_data(test_sysusers_sh,
31 install_dir : unittestsdir)
32 install_subdir('test-sysusers',
33 exclude_files : '.gitattributes',
34 install_dir : testdata_dir)
38 ############################################################
40 if want_tests != 'false' and conf.get('ENABLE_HWDB') == 1
41 hwdb_test_sh = find_program('hwdb-test.sh')
42 exe = executables_by_name.get('systemd-hwdb')
46 args : exe.full_path(),
51 ############################################################
53 if want_tests != 'false'
54 test_systemctl_enable_sh = find_program('test-systemctl-enable.sh')
55 systemctl = executables_by_name.get('systemctl')
56 systemd_id128 = executables_by_name.get('systemd-id128')
57 test('test-systemctl-enable',
58 test_systemctl_enable_sh,
59 # https://github.com/mesonbuild/meson/issues/2681
60 args : [systemctl.full_path(),
61 systemd_id128.full_path()],
62 depends : [systemctl, systemd_id128],
66 ############################################################
68 if want_tests != 'false' and conf.get('HAVE_SYSV_COMPAT') == 1
69 sysv_generator_test_py = find_program('sysv-generator-test.py')
70 exe = executables_by_name.get('systemd-sysv-generator')
71 test('sysv-generator-test',
72 sysv_generator_test_py,
77 ############################################################
79 if want_tests != 'false' and conf.get('HAVE_BLKID') == 1
80 test_bootctl_json_sh = find_program('test-bootctl-json.sh')
81 exe = executables_by_name.get('bootctl')
82 test('test-bootctl-json',
84 args : exe.full_path(),
89 ############################################################
91 if want_tests != 'false' and conf.get('ENABLE_TMPFILES') == 1
92 test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py')
93 exe = executables_by_name.get('systemd-tmpfiles')
94 test('test-systemd-tmpfiles',
95 test_systemd_tmpfiles_py,
96 args : exe.full_path(),
100 if have_standalone_binaries
101 exe = executables_by_name.get('systemd-tmpfiles.standalone')
102 test('test-systemd-tmpfiles.standalone',
103 test_systemd_tmpfiles_py,
104 args : exe.full_path(),
110 ############################################################
112 test_compare_versions_sh = files('test-compare-versions.sh')
113 if want_tests != 'false'
114 exe = executables_by_name.get('systemd-analyze')
115 test('test-compare-versions',
116 test_compare_versions_sh,
117 args : exe.full_path(),
122 install_data(test_compare_versions_sh,
123 install_dir : unittestsdir)
126 ############################################################
128 rule_syntax_check_py = find_program('rule-syntax-check.py')
129 if want_tests != 'false'
130 test('rule-syntax-check',
131 rule_syntax_check_py,
135 exe = executables_by_name.get('udevadm')
136 test('udev-rules-check',
139 args : ['verify', '--resolve-names=never', all_rules])
142 ############################################################
145 install_data('run-unit-tests.py',
146 install_mode : 'rwxr-xr-x',
147 install_dir : testsdir)
149 install_data('integration-test-setup.sh',
150 install_mode : 'rwxr-xr-x',
151 install_dir : testdata_dir)
154 ############################################################
156 test_fstab_generator_sh = find_program('test-fstab-generator.sh')
157 if want_tests != 'false'
158 exe = executables_by_name.get('systemd-fstab-generator')
159 test('test-fstab-generator',
160 test_fstab_generator_sh,
161 # https://github.com/mesonbuild/meson/issues/2681
162 args : exe.full_path(),
168 install_data('test-fstab-generator.sh',
169 install_mode : 'rwxr-xr-x',
170 install_dir : unittestsdir)
173 ############################################################
175 test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
176 if want_tests != 'false'
177 exe = executables_by_name.get('systemd-network-generator')
178 test('test-network-generator-conversion',
179 test_network_generator_conversion_sh,
180 # https://github.com/mesonbuild/meson/issues/2681
181 args : exe.full_path(),
186 install_data('test-network-generator-conversion.sh',
187 install_mode : 'rwxr-xr-x',
188 install_dir : unittestsdir)
191 ############################################################
193 sys_script_py = files('sys-script.py')
194 test_udev_py = files('test-udev.py')
195 if want_tests != 'false'
196 exe = executables_by_name.get('test-udev-rule-runner')
200 env : ['UDEV_RULE_RUNNER=' + exe.full_path()],
209 install_dir : unittestsdir)
212 ############################################################
214 rpm = find_program('rpm', required : false)
215 rpmspec = find_program('rpmspec', required : false)
216 test_rpm_macros = find_program('test-rpm-macros.sh')
218 if rpm.found() and rpmspec.found()
219 if want_tests != 'false'
220 test('test-rpm-macros',
223 args : [project_build_root])
226 message('Skipping test-rpm-macros since rpm and/or rpmspec are not available')
229 ############################################################
231 if want_tests != 'false' and conf.get('HAVE_DMI') == 1
232 udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
233 exe = executables_by_name.get('dmi_memory_id')
235 if git.found() and fs.is_dir(project_source_root / '.git')
237 env, '-u', 'GIT_WORK_TREE',
238 git, '--git-dir=@0@/.git'.format(project_source_root),
239 'ls-files', ':/test/dmidecode-dumps/*.bin',
243 sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root,
247 foreach p : out.stdout().split()
248 source = project_source_root / p
249 test('dmidecode_' + fs.stem(p),
250 udev_dmi_memory_id_test,
252 args : [exe.full_path(),
259 ############################################################
261 if want_tests != 'false' and conf.get('ENABLE_KERNEL_INSTALL') == 1
262 kernel_install = executables_by_name.get('kernel-install')
263 args = [kernel_install.full_path(), loaderentry_install.full_path(), uki_copy_install]
264 deps = [kernel_install, loaderentry_install]
265 if want_ukify and boot_stubs.length() > 0
266 args += [ukify.full_path(), ukify_install.full_path(), boot_stubs[0]]
267 deps += [ukify, ukify_install, boot_stubs[0]]
270 test('test-kernel-install',
271 test_kernel_install_sh,
275 suite : 'kernel-install')
278 ############################################################
280 integration_test_wrapper = find_program('integration-test-wrapper.py')
281 integration_tests = []
282 integration_test_template = {
285 'storage' : 'volatile',
287 'firmware' : 'linux',
290 'memory-accounting' : 'no',
291 'command' : testdata_dir / 'units/%N.sh',
292 'wants' : 'multi-user.target user@4711.service',
293 'after' : 'user@4711.service',
300 'coredump-exclude-regex' : '',
301 'sanitizer-exclude-regex' : '',
310 'test-fstab-generator',
315 'test-network-generator-conversion',
330 'TEST-16-EXTEND-TIMEOUT',
332 'TEST-18-FAILUREACTION',
337 'TEST-24-CRYPTSETUP',
341 'TEST-30-ONCLOCKCHANGE',
342 'TEST-31-DEVICE-ENUMERATION',
344 'TEST-34-DYNAMICUSERMIGRATE',
346 'TEST-36-NUMAPOLICY',
348 'TEST-43-PRIVATEUSER-UNPRIV',
349 'TEST-44-LOG-NAMESPACE',
353 'TEST-52-HONORFIRSTSHUTDOWN',
354 'TEST-53-ISSUE-16347',
358 'TEST-59-RELOADING-RESTART',
359 'TEST-60-MOUNT-RATELIMIT',
360 'TEST-62-RESTRICT-IFACES',
362 'TEST-64-UDEV-STORAGE',
364 'TEST-66-DEVICE-ISOLATION',
366 'TEST-68-PROPAGATE-EXIT-STATUS',
377 'TEST-80-NOTIFYACCESS',
378 'TEST-81-GENERATORS',
379 'TEST-82-SOFTREBOOT',
383 'TEST-86-MULTI-PROFILE-UKI',
384 'TEST-87-AUX-UTILS-VM',
389 foreach integration_test : integration_tests
390 integration_test_args = [
391 '--meson-source-dir', meson.project_source_root(),
392 '--meson-build-dir', meson.project_build_root(),
393 '--name', integration_test['name'],
394 '--storage', integration_test['storage'],
395 '--firmware', integration_test['firmware'],
396 '--exit-code', integration_test['exit-code'].to_string(),
397 '--coredump-exclude-regex', integration_test['coredump-exclude-regex'],
398 '--sanitizer-exclude-regex', integration_test['sanitizer-exclude-regex'],
401 if 'unit' in integration_test
402 integration_test_unit = integration_test['unit']
404 integration_test_unit = configure_file(
405 input : 'test.service.in',
406 output : '@0@.service'.format(integration_test['name']),
407 configuration : integration_test['configuration'],
411 integration_test_args += ['--unit', fs.name(integration_test_unit)]
413 install_data(integration_test_unit, install_dir : testdata_dir / 'units')
416 if integration_test['vm']
417 integration_test_args += ['--vm']
424 integration_test_args += ['--mkosi', mkosi.full_path(), '--']
426 if integration_test['cmdline'].length() > 0
427 integration_test_args += [
428 '--kernel-command-line-extra=@0@'.format(' '.join(integration_test['cmdline']))
432 foreach credential : integration_test['credentials']
433 integration_test_args += ['--credential', credential]
436 if integration_test['qemu-args'].length() > 0
437 integration_test_args += ['--qemu-args=@0@'.format(' '.join(integration_test['qemu-args']))]
440 integration_test_args += integration_test['mkosi-args']
442 integration_test_env = {}
444 if want_integration_tests
445 integration_test_env += {'SYSTEMD_INTEGRATION_TESTS': '1'}
448 if not integration_test['enabled']
452 # We don't explicitly depend on the "mkosi" target because that means the image is rebuilt on every
453 # "ninja -C build". Instead, the mkosi target has to be rebuilt manually before running the
454 # integration tests with mkosi.
456 integration_test['name'],
457 integration_test_wrapper,
458 env : integration_test_env,
459 args : integration_test_args,
460 timeout : integration_test['timeout'],
461 priority : integration_test['priority'],
462 suite : 'integration-tests',
467 foreach subdir : testdata_subdirs
468 # install_subdir() before meson 1.3.0 does not handle symlinks correctly (it follows them
469 # instead of copying the symlink) so we use rsync instead.
470 if meson.version().version_compare('<1.3.0')
472 error('rsync is required to install the integration test data')
475 rsync_r = rsync.full_path() + ' -rlpt --exclude .gitattributes --exclude 25-default.link -- "@0@" "${DESTDIR:-}@1@"'
476 meson.add_install_script(sh, '-c',
477 rsync_r.format(meson.current_source_dir() / subdir, testdata_dir))
479 install_subdir(subdir,
480 exclude_files : ['.gitattributes', '25-default.link'],
481 install_dir : testdata_dir,
482 follow_symlinks : false)
486 # test-network/conf/25-default.link is a local symlink that becomes dangling when installed, so we
487 # exclude it and create the correct symlink here.
488 meson.add_install_script(sh, '-c', ln_s.format(networkdir / '99-default.link',
489 testdata_dir / 'test-network/conf/25-default.link'))
491 install_data(kbd_model_map,
492 install_dir : testdata_dir + '/test-keymap-util')
494 if conf.get('HAVE_ZSTD') == 1 and efi_arch != ''
495 install_subdir('test-bcd',
496 exclude_files : '.gitattributes',
497 install_dir : testdata_dir)
499 if conf.get('ENABLE_RESOLVE') == 1
500 install_subdir('test-resolve',
501 exclude_files : '.gitattributes',
502 install_dir : testdata_dir)
505 # The unit tests implemented as shell scripts expect to find testdata/
506 # in the directory where they are stored.
507 meson.add_install_script(sh, '-c', ln_s.format(testdata_dir,
508 unittestsdir / 'testdata'))