]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/meson.build
Merge pull request #32249 from CodethinkLabs/vmspawn/predicatable_tap_names
[thirdparty/systemd.git] / test / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 if install_tests
4 foreach subdir : [
5 'auxv',
6 'journal-data',
7 'test-journals',
8 'units',
9 'test-execute',
10 'test-fstab-generator',
11 'test-path',
12 'test-path-util',
13 'test-umount',
14 'test-network',
15 'test-network-generator-conversion',
16 'testsuite-03.units',
17 'testsuite-04.units',
18 'testsuite-06.units',
19 'testsuite-07.units',
20 'testsuite-16.units',
21 'testsuite-23.units',
22 'testsuite-30.units',
23 'testsuite-52.units',
24 'testsuite-63.units',
25 'testsuite-80.units',
26 ]
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
31 if rsync.found()
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))
35 else
36 install_subdir(subdir,
37 exclude_files : '.gitattributes',
38 install_dir : testdata_dir)
39 endif
40 endforeach
41
42 install_data(kbd_model_map,
43 install_dir : testdata_dir + '/test-keymap-util')
44
45 if conf.get('HAVE_ZSTD') == 1 and efi_arch != ''
46 install_subdir('test-bcd',
47 exclude_files : '.gitattributes',
48 install_dir : testdata_dir)
49 endif
50 if conf.get('ENABLE_RESOLVE') == 1
51 install_subdir('test-resolve',
52 exclude_files : '.gitattributes',
53 install_dir : testdata_dir)
54 endif
55
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'))
60 endif
61
62 ############################################################
63
64 if 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(),
76 depends : exe,
77 suite : 'sysusers')
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(),
85 depends : exe,
86 suite : 'sysusers')
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
97 endif
98
99 ############################################################
100
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')
104 test('hwdb-test',
105 hwdb_test_sh,
106 suite : 'dist',
107 args : exe.full_path(),
108 depends : exe,
109 timeout : 90)
110 endif
111
112 ############################################################
113
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],
124 suite : 'systemctl')
125 endif
126
127 ############################################################
128
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,
134 depends : exe,
135 suite : 'sysv')
136 endif
137
138 ############################################################
139
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(),
146 depends : exe,
147 suite : 'boot')
148 endif
149
150 ############################################################
151
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(),
158 depends : exe,
159 suite : 'tmpfiles')
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(),
166 depends : exe,
167 suite : 'tmpfiles')
168 endif
169 endif
170
171 ############################################################
172
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(),
179 depends : exe,
180 suite : 'test')
181 endif
182 if install_tests
183 install_data(test_compare_versions_sh,
184 install_dir : unittestsdir)
185 endif
186
187 ############################################################
188
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,
193 suite : 'dist',
194 args : all_rules)
195
196 exe = executables_by_name.get('udevadm')
197 test('udev-rules-check',
198 exe,
199 suite : 'udev',
200 args : ['verify', '--resolve-names=never', all_rules])
201 endif
202
203 ############################################################
204
205 if install_tests
206 install_data('run-unit-tests.py',
207 install_mode : 'rwxr-xr-x',
208 install_dir : testsdir)
209 endif
210
211 ############################################################
212
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(),
220 env : test_env,
221 depends : exe,
222 suite : 'fstab')
223 endif
224 if install_tests
225 install_data('test-fstab-generator.sh',
226 install_mode : 'rwxr-xr-x',
227 install_dir : unittestsdir)
228 endif
229
230 ############################################################
231
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(),
239 depends : exe,
240 suite : 'network')
241 endif
242 if install_tests
243 install_data('test-network-generator-conversion.sh',
244 install_mode : 'rwxr-xr-x',
245 install_dir : unittestsdir)
246 endif
247
248 ############################################################
249
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')
254 test('test-udev',
255 test_udev_py,
256 args : ['-v'],
257 env : ['UDEV_RULE_RUNNER=' + exe.full_path()],
258 depends : exe,
259 timeout : 180,
260 suite : 'udev')
261 endif
262 if install_tests
263 install_data(
264 sys_script_py,
265 test_udev_py,
266 install_dir : unittestsdir)
267 endif
268
269 ############################################################
270
271 rpm = find_program('rpm', required : false)
272 rpmspec = find_program('rpmspec', required : false)
273 test_rpm_macros = find_program('test-rpm-macros.sh')
274
275 if rpm.found() and rpmspec.found()
276 if want_tests != 'false'
277 test('test-rpm-macros',
278 test_rpm_macros,
279 suite : 'dist',
280 args : [project_build_root])
281 endif
282 else
283 message('Skipping test-rpm-macros since rpm and/or rpmspec are not available')
284 endif
285
286 ############################################################
287
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')
291
292 if git.found() and fs.is_dir(project_source_root / '.git')
293 out = run_command(
294 env, '-u', 'GIT_WORK_TREE',
295 git, '--git-dir=@0@/.git'.format(project_source_root),
296 'ls-files', ':/test/dmidecode-dumps/*.bin',
297 check: true)
298 else
299 out = run_command(
300 sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root,
301 check: true)
302 endif
303
304 foreach p : out.stdout().split()
305 source = project_source_root / p
306 test('dmidecode_' + fs.stem(p),
307 udev_dmi_memory_id_test,
308 suite : 'udev',
309 args : [exe.full_path(),
310 source,
311 source + '.txt'],
312 depends : exe)
313 endforeach
314 endif
315
316 ############################################################
317
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]]
325 endif
326
327 test('test-kernel-install',
328 test_kernel_install_sh,
329 env : test_env,
330 args : args,
331 depends : deps,
332 suite : 'kernel-install')
333 endif