Debian Codegraph @

src/test/meson.build

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