]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | # SPDX-License-Identifier: LGPL-2.1-or-later |
3a726fcd | 2 | |
e5cc6d10 YW |
3 | if conf.get('ENABLE_SYSUSERS') == 1 |
4 | test_sysusers_sh = configure_file( | |
5 | input : 'test-sysusers.sh.in', | |
6 | output : 'test-sysusers.sh', | |
7 | configuration : conf) | |
8 | ||
9 | if want_tests != 'false' | |
10 | exe = executables_by_name.get('systemd-sysusers') | |
11 | test('test-sysusers', | |
12 | test_sysusers_sh, | |
13 | # https://github.com/mesonbuild/meson/issues/2681 | |
14 | args : exe.full_path(), | |
dc4a0055 YW |
15 | depends : exe, |
16 | suite : 'sysusers') | |
e5cc6d10 YW |
17 | |
18 | if have_standalone_binaries | |
19 | exe = executables_by_name.get('systemd-sysusers.standalone') | |
20 | test('test-sysusers.standalone', | |
21 | test_sysusers_sh, | |
22 | # https://github.com/mesonbuild/meson/issues/2681 | |
23 | args : exe.full_path(), | |
dc4a0055 YW |
24 | depends : exe, |
25 | suite : 'sysusers') | |
e5cc6d10 YW |
26 | endif |
27 | endif | |
28 | ||
29 | if install_tests | |
30 | install_data(test_sysusers_sh, | |
31 | install_dir : unittestsdir) | |
32 | install_subdir('test-sysusers', | |
33 | exclude_files : '.gitattributes', | |
34 | install_dir : testdata_dir) | |
35 | endif | |
36 | endif | |
0703d2f6 YW |
37 | |
38 | ############################################################ | |
39 | ||
e5cc6d10 YW |
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') | |
43 | test('hwdb-test', | |
44 | hwdb_test_sh, | |
45 | suite : 'dist', | |
46 | args : exe.full_path(), | |
47 | depends : exe, | |
48 | timeout : 90) | |
49 | endif | |
50 | ||
51 | ############################################################ | |
52 | ||
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()], | |
dc4a0055 YW |
62 | depends : [systemctl, systemd_id128], |
63 | suite : 'systemctl') | |
e5cc6d10 YW |
64 | endif |
65 | ||
66 | ############################################################ | |
67 | ||
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, | |
dc4a0055 YW |
73 | depends : exe, |
74 | suite : 'sysv') | |
e5cc6d10 YW |
75 | endif |
76 | ||
77 | ############################################################ | |
78 | ||
dedb925e | 79 | if want_tests != 'false' and conf.get('HAVE_BLKID') == 1 |
e5cc6d10 YW |
80 | test_bootctl_json_sh = find_program('test-bootctl-json.sh') |
81 | exe = executables_by_name.get('bootctl') | |
82 | test('test-bootctl-json', | |
83 | test_bootctl_json_sh, | |
84 | args : exe.full_path(), | |
dc4a0055 YW |
85 | depends : exe, |
86 | suite : 'boot') | |
e5cc6d10 YW |
87 | endif |
88 | ||
89 | ############################################################ | |
90 | ||
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(), | |
dc4a0055 YW |
97 | depends : exe, |
98 | suite : 'tmpfiles') | |
e5cc6d10 YW |
99 | |
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(), | |
dc4a0055 YW |
105 | depends : exe, |
106 | suite : 'tmpfiles') | |
e5cc6d10 | 107 | endif |
bd7e6aa7 ZJS |
108 | endif |
109 | ||
110 | ############################################################ | |
111 | ||
4e8295f4 | 112 | test_compare_versions_sh = files('test-compare-versions.sh') |
e5cc6d10 YW |
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(), | |
dc4a0055 YW |
118 | depends : exe, |
119 | suite : 'test') | |
e5cc6d10 | 120 | endif |
4e8295f4 ZJS |
121 | if install_tests |
122 | install_data(test_compare_versions_sh, | |
26c2b302 | 123 | install_dir : unittestsdir) |
4e8295f4 ZJS |
124 | endif |
125 | ||
126 | ############################################################ | |
127 | ||
6b97bf22 | 128 | rule_syntax_check_py = find_program('rule-syntax-check.py') |
938be089 ZJS |
129 | if want_tests != 'false' |
130 | test('rule-syntax-check', | |
131 | rule_syntax_check_py, | |
02e0f430 | 132 | suite : 'dist', |
938be089 | 133 | args : all_rules) |
e5cc6d10 YW |
134 | |
135 | exe = executables_by_name.get('udevadm') | |
136 | test('udev-rules-check', | |
137 | exe, | |
dc4a0055 | 138 | suite : 'udev', |
e5cc6d10 | 139 | args : ['verify', '--resolve-names=never', all_rules]) |
938be089 | 140 | endif |
6b97bf22 ZJS |
141 | |
142 | ############################################################ | |
143 | ||
3762f8e3 ZJS |
144 | if install_tests |
145 | install_data('run-unit-tests.py', | |
146 | install_mode : 'rwxr-xr-x', | |
147 | install_dir : testsdir) | |
e5cc6d10 YW |
148 | endif |
149 | ||
150 | ############################################################ | |
14055702 | 151 | |
e5cc6d10 YW |
152 | test_fstab_generator_sh = find_program('test-fstab-generator.sh') |
153 | if want_tests != 'false' | |
154 | exe = executables_by_name.get('systemd-fstab-generator') | |
155 | test('test-fstab-generator', | |
156 | test_fstab_generator_sh, | |
157 | # https://github.com/mesonbuild/meson/issues/2681 | |
158 | args : exe.full_path(), | |
159 | env : test_env, | |
dc4a0055 YW |
160 | depends : exe, |
161 | suite : 'fstab') | |
e5cc6d10 YW |
162 | endif |
163 | if install_tests | |
8cc8a073 YW |
164 | install_data('test-fstab-generator.sh', |
165 | install_mode : 'rwxr-xr-x', | |
26c2b302 | 166 | install_dir : unittestsdir) |
e5cc6d10 YW |
167 | endif |
168 | ||
169 | ############################################################ | |
8cc8a073 | 170 | |
e5cc6d10 YW |
171 | test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh') |
172 | if want_tests != 'false' | |
173 | exe = executables_by_name.get('systemd-network-generator') | |
174 | test('test-network-generator-conversion', | |
175 | test_network_generator_conversion_sh, | |
176 | # https://github.com/mesonbuild/meson/issues/2681 | |
177 | args : exe.full_path(), | |
dc4a0055 YW |
178 | depends : exe, |
179 | suite : 'network') | |
e5cc6d10 YW |
180 | endif |
181 | if install_tests | |
b322e683 YW |
182 | install_data('test-network-generator-conversion.sh', |
183 | install_mode : 'rwxr-xr-x', | |
26c2b302 | 184 | install_dir : unittestsdir) |
3762f8e3 ZJS |
185 | endif |
186 | ||
187 | ############################################################ | |
188 | ||
0454cf05 ZJS |
189 | sys_script_py = files('sys-script.py') |
190 | test_udev_py = files('test-udev.py') | |
130c87b1 YW |
191 | if want_tests != 'false' |
192 | exe = executables_by_name.get('test-udev-rule-runner') | |
193 | test('test-udev', | |
194 | test_udev_py, | |
195 | args : ['-v'], | |
196 | env : ['UDEV_RULE_RUNNER=' + exe.full_path()], | |
197 | depends : exe, | |
dc4a0055 YW |
198 | timeout : 180, |
199 | suite : 'udev') | |
130c87b1 | 200 | endif |
0454cf05 ZJS |
201 | if install_tests |
202 | install_data( | |
203 | sys_script_py, | |
204 | test_udev_py, | |
205 | install_dir : unittestsdir) | |
f2c02d23 ZJS |
206 | endif |
207 | ||
2b7b142e ZJS |
208 | ############################################################ |
209 | ||
55c09511 FS |
210 | rpm = find_program('rpm', required : false) |
211 | rpmspec = find_program('rpmspec', required : false) | |
212 | test_rpm_macros = find_program('test-rpm-macros.sh') | |
213 | ||
214 | if rpm.found() and rpmspec.found() | |
215 | if want_tests != 'false' | |
216 | test('test-rpm-macros', | |
217 | test_rpm_macros, | |
02e0f430 | 218 | suite : 'dist', |
55c09511 FS |
219 | args : [project_build_root]) |
220 | endif | |
221 | else | |
222 | message('Skipping test-rpm-macros since rpm and/or rpmspec are not available') | |
223 | endif | |
224 | ||
225 | ############################################################ | |
226 | ||
12b4cffd | 227 | if want_tests != 'false' and conf.get('HAVE_DMI') == 1 |
4dd465cb | 228 | udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh') |
adedcd39 | 229 | exe = executables_by_name.get('dmi_memory_id') |
2b7b142e | 230 | |
edd84b8e | 231 | if git.found() and fs.is_dir(project_source_root / '.git') |
2b7b142e | 232 | out = run_command( |
0f4c4f38 ZJS |
233 | env, '-u', 'GIT_WORK_TREE', |
234 | git, '--git-dir=@0@/.git'.format(project_source_root), | |
68a06b3c JJ |
235 | 'ls-files', ':/test/dmidecode-dumps/*.bin', |
236 | check: true) | |
2b7b142e ZJS |
237 | else |
238 | out = run_command( | |
ac3eda34 | 239 | sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root, |
68a06b3c | 240 | check: true) |
2b7b142e ZJS |
241 | endif |
242 | ||
243 | foreach p : out.stdout().split() | |
fce9abb2 | 244 | source = project_source_root / p |
739a62bb | 245 | test('dmidecode_' + fs.stem(p), |
2b7b142e | 246 | udev_dmi_memory_id_test, |
dc4a0055 | 247 | suite : 'udev', |
adedcd39 | 248 | args : [exe.full_path(), |
0b5f1bd4 | 249 | source, |
e93ada98 | 250 | source + '.txt'], |
adedcd39 | 251 | depends : exe) |
2b7b142e | 252 | endforeach |
4dd465cb BN |
253 | endif |
254 | ||
e5cc6d10 YW |
255 | ############################################################ |
256 | ||
257 | if want_tests != 'false' and conf.get('ENABLE_KERNEL_INSTALL') == 1 | |
258 | kernel_install = executables_by_name.get('kernel-install') | |
259 | args = [kernel_install.full_path(), loaderentry_install.full_path(), uki_copy_install] | |
260 | deps = [kernel_install, loaderentry_install] | |
261 | if want_ukify and boot_stubs.length() > 0 | |
262 | args += [ukify.full_path(), ukify_install.full_path(), boot_stubs[0]] | |
263 | deps += [ukify, ukify_install, boot_stubs[0]] | |
264 | endif | |
265 | ||
266 | test('test-kernel-install', | |
267 | test_kernel_install_sh, | |
268 | env : test_env, | |
269 | args : args, | |
dc4a0055 YW |
270 | depends : deps, |
271 | suite : 'kernel-install') | |
e5cc6d10 | 272 | endif |
945b722f RM |
273 | |
274 | ############################################################ | |
275 | ||
cf5e1b5d | 276 | integration_test_wrapper = find_program('integration-test-wrapper.py') |
5748f13e DDM |
277 | integration_tests = [] |
278 | integration_test_template = { | |
c87e243f | 279 | 'mkosi-args' : [], |
5748f13e DDM |
280 | 'timeout' : 1800, |
281 | 'storage' : 'volatile', | |
282 | 'priority' : 0, | |
283 | 'firmware' : 'linux', | |
284 | 'slow' : false, | |
4ce12c39 | 285 | 'enabled' : true, |
348f5017 DDM |
286 | 'configuration' : { |
287 | 'memory-accounting' : 'no', | |
288 | 'command' : testdata_dir / 'units/%N.sh', | |
1d9b8f34 DDM |
289 | 'wants' : '', |
290 | 'after' : '', | |
348f5017 | 291 | }, |
31c797e0 | 292 | 'cmdline' : [], |
9e262ef9 DDM |
293 | 'credentials' : [], |
294 | 'qemu-args' : [], | |
cf5e1b5d | 295 | } |
7a321b5a DDM |
296 | testdata_subdirs = [ |
297 | 'auxv', | |
298 | 'journal-data', | |
299 | 'knot-data', | |
300 | 'test-journals', | |
301 | 'units', | |
302 | 'test-execute', | |
303 | 'test-fstab-generator', | |
304 | 'test-path', | |
305 | 'test-path-util', | |
306 | 'test-umount', | |
307 | 'test-network', | |
308 | 'test-network-generator-conversion', | |
309 | ] | |
cf5e1b5d | 310 | |
5748f13e DDM |
311 | foreach dirname : [ |
312 | 'TEST-01-BASIC', | |
313 | 'TEST-02-UNITTESTS', | |
314 | 'TEST-03-JOBS', | |
315 | 'TEST-04-JOURNAL', | |
316 | 'TEST-05-RLIMITS', | |
317 | 'TEST-06-SELINUX', | |
318 | 'TEST-07-PID1', | |
4ce12c39 | 319 | 'TEST-08-INITRD', |
5748f13e DDM |
320 | 'TEST-09-REBOOT', |
321 | 'TEST-13-NSPAWN', | |
322 | 'TEST-15-DROPIN', | |
323 | 'TEST-16-EXTEND-TIMEOUT', | |
324 | 'TEST-17-UDEV', | |
325 | 'TEST-18-FAILUREACTION', | |
326 | 'TEST-19-CGROUP', | |
327 | 'TEST-21-DFUZZER', | |
328 | 'TEST-22-TMPFILES', | |
329 | 'TEST-23-UNIT-FILE', | |
4ce12c39 | 330 | 'TEST-24-CRYPTSETUP', |
5748f13e DDM |
331 | 'TEST-25-IMPORT', |
332 | 'TEST-26-SYSTEMCTL', | |
333 | 'TEST-29-PORTABLE', | |
334 | 'TEST-30-ONCLOCKCHANGE', | |
335 | 'TEST-31-DEVICE-ENUMERATION', | |
336 | 'TEST-32-OOMPOLICY', | |
337 | 'TEST-34-DYNAMICUSERMIGRATE', | |
338 | 'TEST-35-LOGIN', | |
339 | 'TEST-36-NUMAPOLICY', | |
340 | 'TEST-38-FREEZER', | |
341 | 'TEST-43-PRIVATEUSER-UNPRIV', | |
342 | 'TEST-44-LOG-NAMESPACE', | |
343 | 'TEST-45-TIMEDATE', | |
344 | 'TEST-46-HOMED', | |
345 | 'TEST-50-DISSECT', | |
346 | 'TEST-52-HONORFIRSTSHUTDOWN', | |
347 | 'TEST-53-ISSUE-16347', | |
4ce12c39 | 348 | 'TEST-54-CREDS', |
5748f13e DDM |
349 | 'TEST-55-OOMD', |
350 | 'TEST-58-REPART', | |
351 | 'TEST-59-RELOADING-RESTART', | |
352 | 'TEST-60-MOUNT-RATELIMIT', | |
353 | 'TEST-62-RESTRICT-IFACES', | |
354 | 'TEST-63-PATH', | |
4ce12c39 | 355 | 'TEST-64-UDEV-STORAGE', |
5748f13e DDM |
356 | 'TEST-65-ANALYZE', |
357 | 'TEST-66-DEVICE-ISOLATION', | |
358 | 'TEST-67-INTEGRITY', | |
359 | 'TEST-68-PROPAGATE-EXIT-STATUS', | |
4ce12c39 | 360 | 'TEST-69-SHUTDOWN', |
5748f13e DDM |
361 | 'TEST-70-TPM2', |
362 | 'TEST-71-HOSTNAME', | |
363 | 'TEST-72-SYSUPDATE', | |
364 | 'TEST-73-LOCALE', | |
365 | 'TEST-74-AUX-UTILS', | |
366 | 'TEST-75-RESOLVED', | |
367 | 'TEST-76-SYSCTL', | |
368 | 'TEST-78-SIGQUEUE', | |
369 | 'TEST-79-MEMPRESS', | |
370 | 'TEST-80-NOTIFYACCESS', | |
371 | 'TEST-81-GENERATORS', | |
4ce12c39 | 372 | 'TEST-82-SOFTREBOOT', |
5748f13e DDM |
373 | 'TEST-83-BTRFS', |
374 | 'TEST-84-STORAGETM', | |
375 | ] | |
376 | subdir(dirname) | |
377 | endforeach | |
378 | ||
379 | foreach integration_test : integration_tests | |
5748f13e | 380 | integration_test_args = [ |
cf5e1b5d DDM |
381 | '--meson-source-dir', meson.project_source_root(), |
382 | '--meson-build-dir', meson.project_build_root(), | |
f483e083 | 383 | '--name', integration_test['name'], |
5748f13e DDM |
384 | '--storage', integration_test['storage'], |
385 | '--firmware', integration_test['firmware'], | |
f1f87f3b DDM |
386 | ] |
387 | ||
348f5017 DDM |
388 | if 'unit' in integration_test |
389 | integration_test_unit = integration_test['unit'] | |
390 | else | |
391 | integration_test_unit = configure_file( | |
392 | input : 'test.service.in', | |
393 | output : '@0@.service'.format(integration_test['name']), | |
394 | configuration : integration_test['configuration'], | |
395 | ) | |
396 | endif | |
397 | ||
398 | integration_test_args += ['--unit', fs.name(integration_test_unit)] | |
399 | if install_tests | |
400 | install_data(integration_test_unit, install_dir : testdata_dir / 'units') | |
401 | endif | |
402 | ||
5748f13e DDM |
403 | if integration_test['slow'] |
404 | integration_test_args += ['--slow'] | |
f1f87f3b DDM |
405 | endif |
406 | ||
31c797e0 DDM |
407 | integration_test_args += ['--'] |
408 | ||
409 | if integration_test['cmdline'].length() > 0 | |
410 | integration_test_args += [ | |
411 | '--kernel-command-line-extra=@0@'.format(' '.join(integration_test['cmdline'])) | |
412 | ] | |
413 | endif | |
414 | ||
9e262ef9 DDM |
415 | foreach credential : integration_test['credentials'] |
416 | integration_test_args += ['--credential', credential] | |
417 | endforeach | |
418 | ||
419 | if integration_test['qemu-args'].length() > 0 | |
420 | integration_test_args += ['--qemu-args=@0@'.format(' '.join(integration_test['qemu-args']))] | |
421 | endif | |
422 | ||
31c797e0 | 423 | integration_test_args += integration_test['mkosi-args'] |
cf5e1b5d | 424 | |
38db5eff DDM |
425 | integration_test_env = {} |
426 | ||
427 | if want_integration_tests | |
f1f87f3b DDM |
428 | integration_test_env += {'SYSTEMD_INTEGRATION_TESTS': '1'} |
429 | endif | |
430 | ||
431 | if want_slow_tests | |
432 | integration_test_env += {'SYSTEMD_SLOW_TESTS': '1'} | |
38db5eff DDM |
433 | endif |
434 | ||
4ce12c39 DDM |
435 | if not integration_test['enabled'] |
436 | continue | |
437 | endif | |
438 | ||
5748f13e DDM |
439 | # We don't explicitly depend on the "mkosi" target because that means the image is rebuilt on every |
440 | # "ninja -C build". Instead, the mkosi target has to be rebuilt manually before running the | |
441 | # integration tests with mkosi. | |
442 | test( | |
443 | integration_test['name'], | |
444 | integration_test_wrapper, | |
445 | env : integration_test_env, | |
446 | args : integration_test_args, | |
447 | timeout : integration_test['timeout'], | |
448 | priority : integration_test['priority'], | |
449 | suite : 'integration-tests', | |
450 | ) | |
cf5e1b5d | 451 | endforeach |
7a321b5a DDM |
452 | |
453 | if install_tests | |
454 | foreach subdir : testdata_subdirs | |
455 | # install_subdir() before meson 1.3.0 does not handle symlinks correctly (it follows them | |
456 | # instead of copying the symlink) so we use rsync instead. | |
457 | if meson.version().version_compare('<1.3.0') | |
458 | if not rsync.found() | |
459 | error('rsync is required to install the integration test data') | |
460 | endif | |
461 | ||
462 | rsync_r = rsync.full_path() + ' -rlpt --exclude .gitattributes --exclude 25-default.link -- "@0@" "${DESTDIR:-}@1@"' | |
463 | meson.add_install_script(sh, '-c', | |
464 | rsync_r.format(meson.current_source_dir() / subdir, testdata_dir)) | |
465 | else | |
466 | install_subdir(subdir, | |
467 | exclude_files : ['.gitattributes', '25-default.link'], | |
468 | install_dir : testdata_dir, | |
469 | follow_symlinks : false) | |
470 | endif | |
471 | endforeach | |
472 | ||
473 | # test-network/conf/25-default.link is a local symlink that becomes dangling when installed, so we | |
474 | # exclude it and create the correct symlink here. | |
475 | meson.add_install_script(sh, '-c', ln_s.format(networkdir / '99-default.link', | |
476 | testdata_dir / 'test-network/conf/25-default.link')) | |
477 | ||
478 | install_data(kbd_model_map, | |
479 | install_dir : testdata_dir + '/test-keymap-util') | |
480 | ||
481 | if conf.get('HAVE_ZSTD') == 1 and efi_arch != '' | |
482 | install_subdir('test-bcd', | |
483 | exclude_files : '.gitattributes', | |
484 | install_dir : testdata_dir) | |
485 | endif | |
486 | if conf.get('ENABLE_RESOLVE') == 1 | |
487 | install_subdir('test-resolve', | |
488 | exclude_files : '.gitattributes', | |
489 | install_dir : testdata_dir) | |
490 | endif | |
491 | ||
492 | # The unit tests implemented as shell scripts expect to find testdata/ | |
493 | # in the directory where they are stored. | |
494 | meson.add_install_script(sh, '-c', ln_s.format(testdata_dir, | |
495 | unittestsdir / 'testdata')) | |
496 | endif |