]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/meson.build
nspawn, vmspawn, run0: add env var for turning off background tinting
[thirdparty/systemd.git] / test / meson.build
CommitLineData
db9ecf05 1# SPDX-License-Identifier: LGPL-2.1-or-later
3a726fcd 2
a18c7865 3if install_tests
2f809d29
ZJS
4 foreach subdir : [
5 'auxv',
6 'journal-data',
27add528 7 'test-journals',
2f809d29
ZJS
8 'units',
9 'test-execute',
10 'test-fstab-generator',
11 'test-path',
12 'test-path-util',
13 'test-umount',
3ceb96e0 14 'test-network',
2f809d29
ZJS
15 'test-network-generator-conversion',
16 'testsuite-03.units',
17 'testsuite-04.units',
18 'testsuite-06.units',
a8faac7d 19 'testsuite-07.units',
2f809d29 20 'testsuite-16.units',
8412cdf4 21 'testsuite-23.units',
2f809d29
ZJS
22 'testsuite-30.units',
23 'testsuite-52.units',
24 'testsuite-63.units',
25 'testsuite-80.units',
26 ]
cc2a0d85 27 # install_subdir() does not handle symlinks correctly which causes a very ugly warning when
413ef50a 28 # installing, so if rsync is available we use that instead. TODO: switch to the new option
ba4d7e80 29 # 'follow_symlinks' once we require Meson 1.3.0 or greater, see:
413ef50a 30 # https://github.com/mesonbuild/meson/commit/0af126fec798d6dbb0d1ad52168cc1f3f1758acd
cc2a0d85 31 if rsync.found()
e9b066ff 32 rsync_r = rsync.full_path() + ' -rLpt --exclude .gitattributes -- "@0@" "${DESTDIR:-}@1@"'
cc2a0d85
DDM
33 meson.add_install_script(sh, '-c',
34 rsync_r.format(meson.current_source_dir() / subdir, testdata_dir))
35 else
36 install_subdir(subdir,
37 exclude_files : '.gitattributes',
38 install_dir : testdata_dir)
39 endif
2f809d29 40 endforeach
80769cb6 41
be0cc2ce
FB
42 install_data(kbd_model_map,
43 install_dir : testdata_dir + '/test-keymap-util')
44
e8509329 45 if conf.get('HAVE_ZSTD') == 1 and efi_arch != ''
db7f5ab6
JJ
46 install_subdir('test-bcd',
47 exclude_files : '.gitattributes',
48 install_dir : testdata_dir)
49 endif
a18c7865
ZJS
50 if conf.get('ENABLE_RESOLVE') == 1
51 install_subdir('test-resolve',
082c6761 52 exclude_files : '.gitattributes',
a18c7865
ZJS
53 install_dir : testdata_dir)
54 endif
c8475239 55
c18cc7f7
FB
56 # The unit tests implemented as shell scripts expect to find testdata/
57 # in the directory where they are stored.
9289e093
YW
58 meson.add_install_script(sh, '-c', ln_s.format(testdata_dir,
59 unittestsdir / 'testdata'))
4ff3f251
ZJS
60endif
61
e5cc6d10
YW
62############################################################
63
64if conf.get('ENABLE_SYSUSERS') == 1
65 test_sysusers_sh = configure_file(
66 input : 'test-sysusers.sh.in',
67 output : 'test-sysusers.sh',
68 configuration : conf)
69
70 if want_tests != 'false'
71 exe = executables_by_name.get('systemd-sysusers')
72 test('test-sysusers',
73 test_sysusers_sh,
74 # https://github.com/mesonbuild/meson/issues/2681
75 args : exe.full_path(),
dc4a0055
YW
76 depends : exe,
77 suite : 'sysusers')
e5cc6d10
YW
78
79 if have_standalone_binaries
80 exe = executables_by_name.get('systemd-sysusers.standalone')
81 test('test-sysusers.standalone',
82 test_sysusers_sh,
83 # https://github.com/mesonbuild/meson/issues/2681
84 args : exe.full_path(),
dc4a0055
YW
85 depends : exe,
86 suite : 'sysusers')
e5cc6d10
YW
87 endif
88 endif
89
90 if install_tests
91 install_data(test_sysusers_sh,
92 install_dir : unittestsdir)
93 install_subdir('test-sysusers',
94 exclude_files : '.gitattributes',
95 install_dir : testdata_dir)
96 endif
97endif
0703d2f6
YW
98
99############################################################
100
e5cc6d10
YW
101if 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')
104 test('hwdb-test',
105 hwdb_test_sh,
106 suite : 'dist',
107 args : exe.full_path(),
108 depends : exe,
109 timeout : 90)
110endif
111
112############################################################
113
114if 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()],
dc4a0055
YW
123 depends : [systemctl, systemd_id128],
124 suite : 'systemctl')
e5cc6d10
YW
125endif
126
127############################################################
128
129if 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,
dc4a0055
YW
134 depends : exe,
135 suite : 'sysv')
e5cc6d10
YW
136endif
137
138############################################################
139
dedb925e 140if want_tests != 'false' and conf.get('HAVE_BLKID') == 1
e5cc6d10
YW
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(),
dc4a0055
YW
146 depends : exe,
147 suite : 'boot')
e5cc6d10
YW
148endif
149
150############################################################
151
152if 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(),
dc4a0055
YW
158 depends : exe,
159 suite : 'tmpfiles')
e5cc6d10
YW
160
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(),
dc4a0055
YW
166 depends : exe,
167 suite : 'tmpfiles')
e5cc6d10 168 endif
bd7e6aa7
ZJS
169endif
170
171############################################################
172
4e8295f4 173test_compare_versions_sh = files('test-compare-versions.sh')
e5cc6d10
YW
174if 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(),
dc4a0055
YW
179 depends : exe,
180 suite : 'test')
e5cc6d10 181endif
4e8295f4
ZJS
182if install_tests
183 install_data(test_compare_versions_sh,
26c2b302 184 install_dir : unittestsdir)
4e8295f4
ZJS
185endif
186
187############################################################
188
6b97bf22 189rule_syntax_check_py = find_program('rule-syntax-check.py')
938be089
ZJS
190if want_tests != 'false'
191 test('rule-syntax-check',
192 rule_syntax_check_py,
02e0f430 193 suite : 'dist',
938be089 194 args : all_rules)
e5cc6d10
YW
195
196 exe = executables_by_name.get('udevadm')
197 test('udev-rules-check',
198 exe,
dc4a0055 199 suite : 'udev',
e5cc6d10 200 args : ['verify', '--resolve-names=never', all_rules])
938be089 201endif
6b97bf22
ZJS
202
203############################################################
204
3762f8e3
ZJS
205if install_tests
206 install_data('run-unit-tests.py',
207 install_mode : 'rwxr-xr-x',
208 install_dir : testsdir)
e5cc6d10
YW
209endif
210
211############################################################
14055702 212
e5cc6d10
YW
213test_fstab_generator_sh = find_program('test-fstab-generator.sh')
214if 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(),
220 env : test_env,
dc4a0055
YW
221 depends : exe,
222 suite : 'fstab')
e5cc6d10
YW
223endif
224if install_tests
8cc8a073
YW
225 install_data('test-fstab-generator.sh',
226 install_mode : 'rwxr-xr-x',
26c2b302 227 install_dir : unittestsdir)
e5cc6d10
YW
228endif
229
230############################################################
8cc8a073 231
e5cc6d10
YW
232test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh')
233if 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(),
dc4a0055
YW
239 depends : exe,
240 suite : 'network')
e5cc6d10
YW
241endif
242if install_tests
b322e683
YW
243 install_data('test-network-generator-conversion.sh',
244 install_mode : 'rwxr-xr-x',
26c2b302 245 install_dir : unittestsdir)
3762f8e3
ZJS
246endif
247
248############################################################
249
0454cf05
ZJS
250sys_script_py = files('sys-script.py')
251test_udev_py = files('test-udev.py')
130c87b1
YW
252if want_tests != 'false'
253 exe = executables_by_name.get('test-udev-rule-runner')
254 test('test-udev',
255 test_udev_py,
256 args : ['-v'],
257 env : ['UDEV_RULE_RUNNER=' + exe.full_path()],
258 depends : exe,
dc4a0055
YW
259 timeout : 180,
260 suite : 'udev')
130c87b1 261endif
0454cf05
ZJS
262if install_tests
263 install_data(
264 sys_script_py,
265 test_udev_py,
266 install_dir : unittestsdir)
f2c02d23
ZJS
267endif
268
2b7b142e
ZJS
269############################################################
270
55c09511
FS
271rpm = find_program('rpm', required : false)
272rpmspec = find_program('rpmspec', required : false)
273test_rpm_macros = find_program('test-rpm-macros.sh')
274
275if rpm.found() and rpmspec.found()
276 if want_tests != 'false'
277 test('test-rpm-macros',
278 test_rpm_macros,
02e0f430 279 suite : 'dist',
55c09511
FS
280 args : [project_build_root])
281 endif
282else
283 message('Skipping test-rpm-macros since rpm and/or rpmspec are not available')
284endif
285
286############################################################
287
12b4cffd 288if want_tests != 'false' and conf.get('HAVE_DMI') == 1
4dd465cb 289 udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
adedcd39 290 exe = executables_by_name.get('dmi_memory_id')
2b7b142e 291
edd84b8e 292 if git.found() and fs.is_dir(project_source_root / '.git')
2b7b142e 293 out = run_command(
0f4c4f38
ZJS
294 env, '-u', 'GIT_WORK_TREE',
295 git, '--git-dir=@0@/.git'.format(project_source_root),
68a06b3c
JJ
296 'ls-files', ':/test/dmidecode-dumps/*.bin',
297 check: true)
2b7b142e
ZJS
298 else
299 out = run_command(
ac3eda34 300 sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root,
68a06b3c 301 check: true)
2b7b142e
ZJS
302 endif
303
304 foreach p : out.stdout().split()
fce9abb2 305 source = project_source_root / p
739a62bb 306 test('dmidecode_' + fs.stem(p),
2b7b142e 307 udev_dmi_memory_id_test,
dc4a0055 308 suite : 'udev',
adedcd39 309 args : [exe.full_path(),
0b5f1bd4 310 source,
e93ada98 311 source + '.txt'],
adedcd39 312 depends : exe)
2b7b142e 313 endforeach
4dd465cb
BN
314endif
315
e5cc6d10
YW
316############################################################
317
318if 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]]
325 endif
326
327 test('test-kernel-install',
328 test_kernel_install_sh,
329 env : test_env,
330 args : args,
dc4a0055
YW
331 depends : deps,
332 suite : 'kernel-install')
e5cc6d10 333endif
945b722f
RM
334
335############################################################
336
cf5e1b5d
DDM
337integration_test_wrapper = find_program('integration-test-wrapper.py')
338integration_tests = {
339 '01': 'TEST-01-BASIC',
340 '02': 'TEST-02-UNITTESTS',
66fb77a8 341 '03': 'TEST-03-JOBS',
f2018d06 342 # '04': 'TEST-04-JOURNAL', # Extremely flaky
66fb77a8 343 '05': 'TEST-05-RLIMITS',
4b1edf5c
DDM
344 # '06': 'TEST-06-SELINUX',
345 # '07': 'TEST-07-PID1',
346 # '08': 'TEST-08-INITRD',
f2018d06
RM
347 '09': 'TEST-09-REBOOT',
348 '13': 'TEST-13-NSPAWN',
349 '15': 'TEST-15-DROPIN',
66fb77a8
RM
350 '16': 'TEST-16-EXTEND-TIMEOUT',
351 '17': 'TEST-17-UDEV', # Can be flaky when overloaded if timeout abort test is slow
f2018d06 352 '18': 'TEST-18-FAILUREACTION',
66fb77a8 353 '19': 'TEST-19-CGROUP',
4b1edf5c 354 # '21': 'TEST-21-DFUZZER',
f2018d06 355 '22': 'TEST-22-TMPFILES',
4b1edf5c
DDM
356 # '23': 'TEST-23-UNIT-FILE',
357 # '24': 'TEST-24-CRYPTSETUP',
66fb77a8
RM
358 '25': 'TEST-25-IMPORT',
359 '26': 'TEST-26-SYSTEMCTL',
c77dad70 360 '29': 'TEST-29-PORTABLE',
66fb77a8 361 '30': 'TEST-30-ONCLOCKCHANGE',
4b1edf5c 362 # '31': 'TEST-31-DEVICE-ENUMERATION',
66fb77a8
RM
363 '32': 'TEST-32-OOMPOLICY',
364 '34': 'TEST-34-DYNAMICUSERMIGRATE',
f2018d06 365 '35': 'TEST-35-LOGIN',
66fb77a8
RM
366 '36': 'TEST-36-NUMAPOLICY',
367 '38': 'TEST-38-FREEZER',
c77dad70 368 '43': 'TEST-43-PRIVATEUSER-UNPRIV',
66fb77a8
RM
369 '44': 'TEST-44-LOG-NAMESPACE',
370 '45': 'TEST-45-TIMEDATE',
4b1edf5c 371 # '46': 'TEST-46-HOMED',
c77dad70 372 '50': 'TEST-50-DISSECT',
4b1edf5c
DDM
373 # '52': 'TEST-52-HONORFIRSTSHUTDOWN',
374 # '53': 'TEST-53-ISSUE-16347',
375 # '54': 'TEST-54-CREDS',
376 # '55': 'TEST-55-OOMD',
377 # '58': 'TEST-58-REPART',
66fb77a8
RM
378 # Can be flaky when overloaded if daemon-reload is too slow to be rate-limited
379 '59': 'TEST-59-RELOADING-RESTART',
380 '60': 'TEST-60-MOUNT-RATELIMIT',
381 '62': 'TEST-62-RESTRICT-IFACES',
382 '63': 'TEST-63-PATH',
4b1edf5c 383 # '64': 'TEST-54-UDEV-STORAGE',
f2018d06 384 '65': 'TEST-65-ANALYZE',
66fb77a8
RM
385 '66': 'TEST-66-DEVICE-ISOLATION',
386 '67': 'TEST-67-INTEGRITY',
387 '68': 'TEST-68-PROPAGATE-EXIT-STATUS',
f2018d06
RM
388 '70': 'TEST-70-TPM2',
389 '71': 'TEST-71-HOSTNAME',
66fb77a8 390 '72': 'TEST-72-SYSUPDATE',
4b1edf5c
DDM
391 # '73': 'TEST-73-LOCALE',
392 # '74': 'TEST-74-AUX-UTILS',
393 # '75': 'TEST-75-RESOLVED',
66fb77a8
RM
394 '76': 'TEST-76-SYSCTL',
395 '78': 'TEST-78-SIGQUEUE',
396 '79': 'TEST-79-MEMPRESS',
397 '80': 'TEST-80-NOTIFYACCESS',
398 '81': 'TEST-81-GENERATORS',
4b1edf5c 399 # '82': 'TEST-82-SOFTREBOOT',
f2018d06 400 '83': 'TEST-83-BTRFS',
66fb77a8 401 '84': 'TEST-84-STORAGETM',
cf5e1b5d
DDM
402}
403foreach test_number, dirname : integration_tests
404 test_params = {
405 'mkosi_args' : [],
51273281 406 'timeout' : 1800,
9a69900a 407 'storage': 'volatile',
945b722f 408 }
b85e5496 409
cf5e1b5d
DDM
410 # TODO: This fs.exists call isn't included in rebuild logic
411 # so if you add a new meson.build in a subdir
412 # you need to touch another build file to get it to reparse.
413 if fs.exists(dirname / 'meson.build')
414 subdir(dirname)
415 endif
416
417 args = [
418 '--meson-source-dir', meson.project_source_root(),
419 '--meson-build-dir', meson.project_build_root(),
420 '--test-name', dirname,
421 '--test-number', test_number,
9a69900a 422 '--storage', test_params['storage'],
cf5e1b5d
DDM
423 '--',
424 ] + test_params['mkosi_args']
425
426 # We don't explicitly depend on the "mkosi" target because that means the image is rebuilt
427 # on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before
428 # running the integration tests with mkosi.
429 test(dirname,
430 integration_test_wrapper,
431 env: test_env,
432 args : args,
433 timeout : test_params['timeout'],
434 suite : 'integration-tests')
435endforeach