1 # SPDX-License-Identifier: LGPL-2.1-or-later
10 'test-fstab-generator',
15 'test-network-generator-conversion',
27 # install_subdir() does not handle symlinks correctly which causes a very ugly warning when
28 # installing, so if rsync is available we use that instead. TODO: switch to the new option
29 # 'follow_symlinks' once we require Meson 1.3.0 or greater, see:
30 # https://github.com/mesonbuild/meson/commit/0af126fec798d6dbb0d1ad52168cc1f3f1758acd
32 rsync_r = rsync.full_path() + ' -rlpt --exclude .gitattributes -- "@0@" "${DESTDIR:-}@1@"'
33 meson.add_install_script(sh, '-c',
34 rsync_r.format(meson.current_source_dir() / subdir, testdata_dir))
36 install_subdir(subdir,
37 exclude_files : '.gitattributes',
38 install_dir : testdata_dir)
42 install_data(kbd_model_map,
43 install_dir : testdata_dir + '/test-keymap-util')
45 if conf.get('HAVE_ZSTD') == 1 and efi_arch != ''
46 install_subdir('test-bcd',
47 exclude_files : '.gitattributes',
48 install_dir : testdata_dir)
50 if conf.get('ENABLE_RESOLVE') == 1
51 install_subdir('test-resolve',
52 exclude_files : '.gitattributes',
53 install_dir : testdata_dir)
56 # The unit tests implemented as shell scripts expect to find testdata/
57 # in the directory where they are stored.
58 meson.add_install_script(sh, '-c', ln_s.format(testdata_dir,
59 unittestsdir / 'testdata'))
62 ############################################################
64 if conf.get('ENABLE_SYSUSERS') == 1
65 test_sysusers_sh = configure_file(
66 input : 'test-sysusers.sh.in',
67 output : 'test-sysusers.sh',
70 if want_tests != 'false'
71 exe = executables_by_name.get('systemd-sysusers')
74 # https://github.com/mesonbuild/meson/issues/2681
75 args : exe.full_path(),
79 if have_standalone_binaries
80 exe = executables_by_name.get('systemd-sysusers.standalone')
81 test('test-sysusers.standalone',
83 # https://github.com/mesonbuild/meson/issues/2681
84 args : exe.full_path(),
91 install_data(test_sysusers_sh,
92 install_dir : unittestsdir)
93 install_subdir('test-sysusers',
94 exclude_files : '.gitattributes',
95 install_dir : testdata_dir)
99 ############################################################
101 if want_tests != 'false' and conf.get('ENABLE_HWDB') == 1
102 hwdb_test_sh = find_program('hwdb-test.sh')
103 exe = executables_by_name.get('systemd-hwdb')
107 args : exe.full_path(),
112 ############################################################
114 if want_tests != 'false'
115 test_systemctl_enable_sh = find_program('test-systemctl-enable.sh')
116 systemctl = executables_by_name.get('systemctl')
117 systemd_id128 = executables_by_name.get('systemd-id128')
118 test('test-systemctl-enable',
119 test_systemctl_enable_sh,
120 # https://github.com/mesonbuild/meson/issues/2681
121 args : [systemctl.full_path(),
122 systemd_id128.full_path()],
123 depends : [systemctl, systemd_id128],
127 ############################################################
129 if want_tests != 'false' and conf.get('HAVE_SYSV_COMPAT') == 1
130 sysv_generator_test_py = find_program('sysv-generator-test.py')
131 exe = executables_by_name.get('systemd-sysv-generator')
132 test('sysv-generator-test',
133 sysv_generator_test_py,
138 ############################################################
140 if want_tests != 'false' and conf.get('HAVE_BLKID') == 1
141 test_bootctl_json_sh = find_program('test-bootctl-json.sh')
142 exe = executables_by_name.get('bootctl')
143 test('test-bootctl-json',
144 test_bootctl_json_sh,
145 args : exe.full_path(),
150 ############################################################
152 if want_tests != 'false' and conf.get('ENABLE_TMPFILES') == 1
153 test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py')
154 exe = executables_by_name.get('systemd-tmpfiles')
155 test('test-systemd-tmpfiles',
156 test_systemd_tmpfiles_py,
157 args : exe.full_path(),
161 if have_standalone_binaries
162 exe = executables_by_name.get('systemd-tmpfiles.standalone')
163 test('test-systemd-tmpfiles.standalone',
164 test_systemd_tmpfiles_py,
165 args : exe.full_path(),
171 ############################################################
173 test_compare_versions_sh = files('test-compare-versions.sh')
174 if want_tests != 'false'
175 exe = executables_by_name.get('systemd-analyze')
176 test('test-compare-versions',
177 test_compare_versions_sh,
178 args : exe.full_path(),
183 install_data(test_compare_versions_sh,
184 install_dir : unittestsdir)
187 ############################################################
189 rule_syntax_check_py = find_program('rule-syntax-check.py')
190 if want_tests != 'false'
191 test('rule-syntax-check',
192 rule_syntax_check_py,
196 exe = executables_by_name.get('udevadm')
197 test('udev-rules-check',
200 args : ['verify', '--resolve-names=never', all_rules])
203 ############################################################
206 install_data('run-unit-tests.py',
207 install_mode : 'rwxr-xr-x',
208 install_dir : testsdir)
211 ############################################################
213 test_fstab_generator_sh = find_program('test-fstab-generator.sh')
214 if want_tests != 'false'
215 exe = executables_by_name.get('systemd-fstab-generator')
216 test('test-fstab-generator',
217 test_fstab_generator_sh,
218 # https://github.com/mesonbuild/meson/issues/2681
219 args : exe.full_path(),
225 install_data('test-fstab-generator.sh',
226 install_mode : 'rwxr-xr-x',
227 install_dir : unittestsdir)
230 ############################################################
232 test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
233 if want_tests != 'false'
234 exe = executables_by_name.get('systemd-network-generator')
235 test('test-network-generator-conversion',
236 test_network_generator_conversion_sh,
237 # https://github.com/mesonbuild/meson/issues/2681
238 args : exe.full_path(),
243 install_data('test-network-generator-conversion.sh',
244 install_mode : 'rwxr-xr-x',
245 install_dir : unittestsdir)
248 ############################################################
250 sys_script_py = files('sys-script.py')
251 test_udev_py = files('test-udev.py')
252 if want_tests != 'false'
253 exe = executables_by_name.get('test-udev-rule-runner')
257 env : ['UDEV_RULE_RUNNER=' + exe.full_path()],
266 install_dir : unittestsdir)
269 ############################################################
271 rpm = find_program('rpm', required : false)
272 rpmspec = find_program('rpmspec', required : false)
273 test_rpm_macros = find_program('test-rpm-macros.sh')
275 if rpm.found() and rpmspec.found()
276 if want_tests != 'false'
277 test('test-rpm-macros',
280 args : [project_build_root])
283 message('Skipping test-rpm-macros since rpm and/or rpmspec are not available')
286 ############################################################
288 if want_tests != 'false' and conf.get('HAVE_DMI') == 1
289 udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
290 exe = executables_by_name.get('dmi_memory_id')
292 if git.found() and fs.is_dir(project_source_root / '.git')
294 env, '-u', 'GIT_WORK_TREE',
295 git, '--git-dir=@0@/.git'.format(project_source_root),
296 'ls-files', ':/test/dmidecode-dumps/*.bin',
300 sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root,
304 foreach p : out.stdout().split()
305 source = project_source_root / p
306 test('dmidecode_' + fs.stem(p),
307 udev_dmi_memory_id_test,
309 args : [exe.full_path(),
316 ############################################################
318 if want_tests != 'false' and conf.get('ENABLE_KERNEL_INSTALL') == 1
319 kernel_install = executables_by_name.get('kernel-install')
320 args = [kernel_install.full_path(), loaderentry_install.full_path(), uki_copy_install]
321 deps = [kernel_install, loaderentry_install]
322 if want_ukify and boot_stubs.length() > 0
323 args += [ukify.full_path(), ukify_install.full_path(), boot_stubs[0]]
324 deps += [ukify, ukify_install, boot_stubs[0]]
327 test('test-kernel-install',
328 test_kernel_install_sh,
332 suite : 'kernel-install')