]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/meson.build
Merge pull request #31000 from flatcar-hub/krnowak/mutable-overlays
[thirdparty/systemd.git] / src / test / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 awkscript = 'test-hashmap-ordered.awk'
4 test_hashmap_ordered_c = custom_target(
5 'test-hashmap-ordered.c',
6 input : [awkscript, 'test-hashmap-plain.c'],
7 output : 'test-hashmap-ordered.c',
8 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
9 capture : true,
10 build_by_default : want_tests != 'false')
11
12 path = run_command(sh, '-c', 'echo "$PATH"', check: true).stdout().strip()
13 test_env = environment()
14 test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
15 test_env.set('PATH', project_build_root + ':' + path)
16 test_env.set('PROJECT_BUILD_ROOT', project_build_root)
17 test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0')
18
19 if efi_addon != ''
20 test_env.set('EFI_ADDON', efi_addon)
21 endif
22
23 ############################################################
24
25 generate_sym_test_py = find_program('generate-sym-test.py')
26
27 test_libsystemd_sym_c = custom_target(
28 'test-libsystemd-sym.c',
29 input : [libsystemd_sym_path] + systemd_headers + libsystemd_sources,
30 output : 'test-libsystemd-sym.c',
31 command : [generate_sym_test_py, libsystemd_sym_path, libsystemd_dir_path] + systemd_headers,
32 capture : true,
33 build_by_default : want_tests != 'false')
34
35 test_libudev_sym_c = custom_target(
36 'test-libudev-sym.c',
37 input : [libudev_sym_path, libudev_h_path] + libudev_sources,
38 output : 'test-libudev-sym.c',
39 command : [generate_sym_test_py, libudev_sym_path, libudev_dir_path, libudev_h_path],
40 capture : true,
41 build_by_default : want_tests != 'false')
42
43 ############################################################
44
45 simple_tests += files(
46 'test-alloc-util.c',
47 'test-architecture.c',
48 'test-argv-util.c',
49 'test-barrier.c',
50 'test-bitfield.c',
51 'test-bitmap.c',
52 'test-blockdev-util.c',
53 'test-bootspec.c',
54 'test-build-path.c',
55 'test-bus-util.c',
56 'test-calendarspec.c',
57 'test-cgroup-setup.c',
58 'test-cgroup-util.c',
59 'test-cgroup.c',
60 'test-chase.c',
61 'test-clock.c',
62 'test-color-util.c',
63 'test-compare-operator.c',
64 'test-condition.c',
65 'test-conf-files.c',
66 'test-conf-parser.c',
67 'test-copy.c',
68 'test-coredump-util.c',
69 'test-cpu-set-util.c',
70 'test-creds.c',
71 'test-daemon.c',
72 'test-data-fd-util.c',
73 'test-date.c',
74 'test-dev-setup.c',
75 'test-device-nodes.c',
76 'test-devnum-util.c',
77 'test-dns-domain.c',
78 'test-ellipsize.c',
79 'test-env-file.c',
80 'test-env-util.c',
81 'test-errno-util.c',
82 'test-escape.c',
83 'test-ether-addr-util.c',
84 'test-exec-util.c',
85 'test-execve.c',
86 'test-exit-status.c',
87 'test-extract-word.c',
88 'test-fdset.c',
89 'test-fiemap.c',
90 'test-fileio.c',
91 'test-firewall-util.c',
92 'test-format-table.c',
93 'test-format-util.c',
94 'test-fs-util.c',
95 'test-fstab-util.c',
96 'test-glob-util.c',
97 'test-gpt.c',
98 'test-gunicode.c',
99 'test-hash-funcs.c',
100 'test-hexdecoct.c',
101 'test-hmac.c',
102 'test-hostname-setup.c',
103 'test-hostname-util.c',
104 'test-id128.c',
105 'test-image-policy.c',
106 'test-import-util.c',
107 'test-in-addr-prefix-util.c',
108 'test-in-addr-util.c',
109 'test-install-file.c',
110 'test-install-root.c',
111 'test-io-util.c',
112 'test-iovec-util.c',
113 'test-journal-importer.c',
114 'test-kbd-util.c',
115 'test-limits-util.c',
116 'test-list.c',
117 'test-local-addresses.c',
118 'test-locale-util.c',
119 'test-lock-util.c',
120 'test-log.c',
121 'test-logarithm.c',
122 'test-macro.c',
123 'test-memfd-util.c',
124 'test-memory-util.c',
125 'test-mempool.c',
126 'test-memstream-util.c',
127 'test-mkdir.c',
128 'test-modhex.c',
129 'test-mountpoint-util.c',
130 'test-net-naming-scheme.c',
131 'test-nulstr-util.c',
132 'test-open-file.c',
133 'test-ordered-set.c',
134 'test-os-util.c',
135 'test-parse-argument.c',
136 'test-parse-helpers.c',
137 'test-path-lookup.c',
138 'test-path-util.c',
139 'test-percent-util.c',
140 'test-pidref.c',
141 'test-pretty-print.c',
142 'test-prioq.c',
143 'test-proc-cmdline.c',
144 'test-procfs-util.c',
145 'test-psi-util.c',
146 'test-ratelimit.c',
147 'test-raw-clone.c',
148 'test-recurse-dir.c',
149 'test-replace-var.c',
150 'test-rlimit-util.c',
151 'test-rm-rf.c',
152 'test-sd-hwdb.c',
153 'test-sd-path.c',
154 'test-secure-bits.c',
155 'test-selinux.c',
156 'test-serialize.c',
157 'test-set.c',
158 'test-sha256.c',
159 'test-sigbus.c',
160 'test-signal-util.c',
161 'test-siphash24.c',
162 'test-sleep-config.c',
163 'test-socket-netlink.c',
164 'test-socket-util.c',
165 'test-specifier.c',
166 'test-stat-util.c',
167 'test-static-destruct.c',
168 'test-strbuf.c',
169 'test-string-util.c',
170 'test-strip-tab-ansi.c',
171 'test-strv.c',
172 'test-strxcpyx.c',
173 'test-sysctl-util.c',
174 'test-terminal-util.c',
175 'test-tmpfile-util.c',
176 'test-udev-util.c',
177 'test-uid-classification.c',
178 'test-uid-range.c',
179 'test-umask-util.c',
180 'test-unaligned.c',
181 'test-unit-file.c',
182 'test-user-util.c',
183 'test-utf8.c',
184 'test-verbs.c',
185 'test-vpick.c',
186 'test-web-util.c',
187 'test-xattr-util.c',
188 'test-xml.c',
189 )
190
191 ############################################################
192
193 common_test_dependencies = [
194 libblkid,
195 libmount,
196 librt,
197 libseccomp,
198 libselinux,
199 threads,
200 ]
201
202 executables += [
203 test_template + {
204 'sources' : files('test-acl-util.c'),
205 'conditions' : ['HAVE_ACL'],
206 },
207 test_template + {
208 'sources' : files('test-af-list.c') +
209 generated_gperf_headers,
210 },
211 test_template + {
212 'sources' : files('test-arphrd-util.c') +
213 generated_gperf_headers,
214 },
215 test_template + {
216 'sources' : files('test-ask-password-api.c'),
217 'type' : 'manual',
218 },
219 test_template + {
220 'sources' : files('test-async.c'),
221 'timeout' : 120,
222 },
223 test_template + {
224 'sources' : files('test-boot-timestamps.c'),
225 'conditions' : ['ENABLE_EFI'],
226 },
227 test_template + {
228 'sources' : files('test-btrfs.c'),
229 'type' : 'manual',
230 },
231 test_template + {
232 'sources' : files('test-btrfs-physical-offset.c'),
233 'type' : 'manual',
234 },
235 test_template + {
236 'sources' : files('test-cap-list.c') +
237 generated_gperf_headers,
238 'dependencies' : libcap,
239 },
240 test_template + {
241 'sources' : files('test-capability.c'),
242 'dependencies' : libcap,
243 },
244 test_template + {
245 'sources' : files('test-chase-manual.c'),
246 'type' : 'manual',
247 },
248 test_template + {
249 'sources' : files('test-compress-benchmark.c'),
250 'link_with' : [
251 libbasic_compress,
252 libshared,
253 ],
254 'timeout' : 90,
255 },
256 test_template + {
257 'sources' : files('test-compress.c'),
258 'link_with' : [
259 libbasic_compress,
260 libshared,
261 ],
262 },
263 test_template + {
264 'sources' : files('test-cryptolib.c'),
265 'dependencies' : lib_openssl_or_gcrypt,
266 'conditions' : ['HAVE_OPENSSL_OR_GCRYPT'],
267 },
268 test_template + {
269 'sources' : files('test-dlopen-so.c'),
270 'dependencies' : libp11kit_cflags
271 },
272 test_template + {
273 # only static linking apart from libdl, to make sure that the
274 # module is linked to all libraries that it uses.
275 'sources' : files('test-dlopen.c'),
276 'link_with' : libbasic,
277 'dependencies' : libdl,
278 'install' : false,
279 'type' : 'manual',
280 },
281 test_template + {
282 'sources' : files('test-errno-list.c') +
283 generated_gperf_headers,
284 },
285 test_template + {
286 'sources' : files('test-fd-util.c'),
287 'dependencies' : libseccomp,
288 },
289 test_template + {
290 'sources' : files(
291 'test-hashmap.c',
292 'test-hashmap-plain.c',
293 ) + [
294 test_hashmap_ordered_c,
295 ],
296 'timeout' : 180,
297 },
298 test_template + {
299 'sources' : files('test-ip-protocol-list.c') +
300 shared_generated_gperf_headers,
301 },
302 test_template + {
303 'sources' : files('test-ipcrm.c'),
304 'type' : 'unsafe',
305 },
306 test_template + {
307 'sources' : files('test-json.c'),
308 'dependencies' : libm,
309 },
310 test_template + {
311 'sources' : files('test-libcrypt-util.c'),
312 'dependencies' : libcrypt,
313 'timeout' : 120,
314 },
315 test_template + {
316 'sources' : files('test-libmount.c'),
317 'dependencies' : [
318 libmount,
319 threads,
320 ],
321 },
322 test_template + {
323 'sources' : files('test-loopback.c'),
324 'dependencies' : common_test_dependencies,
325 },
326 test_template + {
327 'sources' : files('test-math-util.c'),
328 'dependencies' : libm,
329 },
330 test_template + {
331 'sources' : files('test-mempress.c'),
332 'dependencies' : threads,
333 },
334 test_template + {
335 'sources' : files('test-mount-util.c'),
336 'dependencies' : libmount,
337 },
338 test_template + {
339 'sources' : files('test-netlink-manual.c'),
340 'dependencies' : libkmod,
341 'conditions' : ['HAVE_KMOD'],
342 'type' : 'manual',
343 },
344 test_template + {
345 'sources' : files('test-nft-set.c'),
346 'type' : 'manual',
347 },
348 test_template + {
349 'sources' : files('test-nscd-flush.c'),
350 'conditions' : ['ENABLE_NSCD'],
351 'type' : 'manual',
352 },
353 test_template + {
354 'sources' : files(
355 'test-nss-hosts.c',
356 'nss-test-util.c',
357 ),
358 'dependencies' : libdl,
359 'conditions' : ['ENABLE_NSS'],
360 'timeout' : 120,
361 },
362 test_template + {
363 'sources' : files(
364 'test-nss-users.c',
365 'nss-test-util.c',
366 ),
367 'dependencies' : libdl,
368 'conditions' : ['ENABLE_NSS'],
369 },
370 test_template + {
371 'sources' : files('test-openssl.c'),
372 'dependencies' : libopenssl,
373 'conditions' : ['HAVE_OPENSSL'],
374 },
375 test_template + {
376 'sources' : files('test-parse-util.c'),
377 'dependencies' : libm,
378 },
379 test_template + {
380 'sources' : files('test-process-util.c'),
381 'dependencies' : threads,
382 },
383 test_template + {
384 'sources' : files('test-qrcode-util.c'),
385 'dependencies' : libdl,
386 },
387 test_template + {
388 'sources' : files('test-random-util.c'),
389 'dependencies' : libm,
390 'timeout' : 120,
391 },
392 test_template + {
393 'sources' : files('test-sbat.c'),
394 'conditions' : ['ENABLE_BOOTLOADER'],
395 'c_args' : '-I@0@'.format(efi_config_h_dir),
396 },
397 test_template + {
398 'sources' : files('test-seccomp.c'),
399 'dependencies' : libseccomp,
400 'conditions' : ['HAVE_SECCOMP'],
401 },
402 test_template + {
403 'sources' : files('test-set-disable-mempool.c'),
404 'dependencies' : threads,
405 },
406 test_template + {
407 'sources' : files('test-sizeof.c'),
408 'link_with' : libbasic,
409 },
410 test_template + {
411 'sources' : files('test-time-util.c'),
412 'timeout' : 120,
413 },
414 test_template + {
415 'sources' : files('test-tpm2.c'),
416 'dependencies' : libopenssl,
417 'timeout' : 120,
418 },
419 test_template + {
420 'sources' : files('test-utmp.c'),
421 'conditions' : ['ENABLE_UTMP'],
422 },
423 test_template + {
424 'sources' : files('test-varlink.c'),
425 'dependencies' : threads,
426 },
427 test_template + {
428 'sources' : files('test-varlink-idl.c'),
429 'dependencies' : threads,
430 },
431 test_template + {
432 'sources' : files('test-watchdog.c'),
433 'type' : 'unsafe',
434 },
435
436 # Symbol tests
437 test_template + {
438 'name' : 'test-libsystemd-sym',
439 'sources' : test_libsystemd_sym_c,
440 'link_with' : libsystemd,
441 'suite' : 'libsystemd',
442 },
443 test_template + {
444 'name' : 'test-libsystemd-static-sym',
445 'sources' : test_libsystemd_sym_c,
446 'link_with' : install_libsystemd_static,
447 'build_by_default' : want_tests != 'false' and static_libsystemd != 'false',
448 'install' : install_tests and static_libsystemd != 'false',
449 'suite' : 'libsystemd',
450 },
451 test_template + {
452 'name' : 'test-libudev-sym',
453 'sources' : test_libudev_sym_c,
454 'include_directories' : libudev_includes,
455 'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
456 'link_with' : libudev,
457 'suite' : 'libudev',
458 },
459 test_template + {
460 'name' : 'test-libudev-static-sym',
461 'sources' : test_libudev_sym_c,
462 'include_directories' : libudev_includes,
463 'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
464 'link_with' : install_libudev_static,
465 'build_by_default' : want_tests != 'false' and static_libudev != 'false',
466 'install' : install_tests and static_libudev != 'false',
467 'suite' : 'libudev',
468 },
469
470 # Tests that link to libcore, i.e. tests for pid1 code.
471 core_test_template + {
472 'sources' : files('test-bpf-devices.c'),
473 'dependencies' : common_test_dependencies,
474 },
475 core_test_template + {
476 'sources' : files('test-bpf-firewall.c'),
477 'dependencies' : common_test_dependencies,
478 },
479 core_test_template + {
480 'sources' : files('test-bpf-foreign-programs.c'),
481 },
482 core_test_template + {
483 'sources' : files('test-bpf-restrict-fs.c'),
484 'dependencies' : common_test_dependencies,
485 },
486 core_test_template + {
487 'sources' : files('test-cgroup-cpu.c'),
488 },
489 core_test_template + {
490 'sources' : files('test-cgroup-mask.c'),
491 'dependencies' : common_test_dependencies,
492 },
493 core_test_template + {
494 'sources' : files('test-cgroup-unit-default.c'),
495 },
496 core_test_template + {
497 'sources' : files('test-chown-rec.c'),
498 },
499 core_test_template + {
500 'sources' : files('test-core-unit.c'),
501 'dependencies' : common_test_dependencies,
502 },
503 core_test_template + {
504 'sources' : files('test-emergency-action.c'),
505 },
506 core_test_template + {
507 'sources' : files('test-engine.c'),
508 'dependencies' : common_test_dependencies,
509 },
510 core_test_template + {
511 'sources' : files('test-execute.c'),
512 'dependencies' : common_test_dependencies,
513 'timeout' : 360,
514 },
515 core_test_template + {
516 'sources' : files('test-install.c'),
517 'type' : 'manual',
518 },
519 core_test_template + {
520 'sources' : files('test-job-type.c'),
521 'dependencies' : common_test_dependencies,
522 },
523 core_test_template + {
524 'sources' : files('test-load-fragment.c'),
525 'dependencies' : common_test_dependencies,
526 },
527 core_test_template + {
528 'sources' : files('test-loop-block.c'),
529 'dependencies' : [threads, libblkid],
530 'parallel' : false,
531 },
532 core_test_template + {
533 'sources' : files('test-manager.c'),
534 },
535 core_test_template + {
536 'sources' : files('test-namespace.c'),
537 'dependencies' : [
538 libblkid,
539 threads,
540 ],
541 },
542 core_test_template + {
543 'sources' : files('test-ns.c'),
544 'dependencies' : common_test_dependencies,
545 'type' : 'manual',
546 },
547 core_test_template + {
548 'sources' : files('test-path.c'),
549 'dependencies' : common_test_dependencies,
550 'timeout' : 120,
551 },
552 core_test_template + {
553 'sources' : files('test-sched-prio.c'),
554 'dependencies' : common_test_dependencies,
555 },
556 core_test_template + {
557 'sources' : files('test-socket-bind.c'),
558 'dependencies' : libdl,
559 'conditions' : ['BPF_FRAMEWORK'],
560 },
561 core_test_template + {
562 'sources' : files('test-tables.c'),
563 },
564 core_test_template + {
565 'sources' : files('test-unit-name.c'),
566 'dependencies' : common_test_dependencies,
567 },
568 core_test_template + {
569 'sources' : files('test-unit-serialize.c'),
570 'dependencies' : common_test_dependencies,
571 },
572 core_test_template + {
573 'sources' : files('test-watch-pid.c'),
574 'dependencies' : common_test_dependencies,
575 },
576
577 # Tests from other directories that have link_with deps that were not defined earlier
578 test_template + {
579 'sources' : files('../libsystemd/sd-bus/test-bus-error.c'),
580 'link_with' : [
581 libshared_static,
582 libsystemd_static,
583 ],
584 },
585 test_template + {
586 'sources' : files('../libsystemd/sd-device/test-sd-device-thread.c'),
587 'link_with' : [
588 libbasic,
589 libsystemd,
590 ],
591 'dependencies' : threads,
592 },
593 test_template + {
594 'sources' : files('../libudev/test-udev-device-thread.c'),
595 'link_with' : [
596 libbasic,
597 libudev,
598 ],
599 'dependencies' : threads,
600 },
601 test_template + {
602 'sources' : files('../libudev/test-libudev.c'),
603 'link_with' : [
604 libshared,
605 libudev_basic,
606 ],
607 },
608 test_template + {
609 'sources' : files('test-aux-scope.c'),
610 'type' : 'manual',
611 },
612 ]