1 # SPDX-License-Identifier: LGPL-2.1-or-later
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@'],
10 build_by_default : want_tests != 'false')
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')
20 test_env.set('EFI_ADDON', efi_addon)
23 ############################################################
25 generate_sym_test_py = find_program('generate-sym-test.py')
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,
33 build_by_default : want_tests != 'false')
35 test_libudev_sym_c = custom_target(
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],
41 build_by_default : want_tests != 'false')
43 ############################################################
45 simple_tests += files(
47 'test-architecture.c',
52 'test-blockdev-util.c',
56 'test-calendarspec.c',
57 'test-cgroup-setup.c',
63 'test-compare-operator.c',
68 'test-coredump-util.c',
69 'test-cpu-set-util.c',
72 'test-data-fd-util.c',
75 'test-device-nodes.c',
83 'test-ether-addr-util.c',
87 'test-extract-word.c',
91 'test-firewall-util.c',
92 'test-format-table.c',
102 'test-hostname-setup.c',
103 'test-hostname-util.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',
113 'test-journal-importer.c',
115 'test-limits-util.c',
117 'test-local-addresses.c',
118 'test-locale-util.c',
124 'test-memory-util.c',
126 'test-memstream-util.c',
129 'test-mountpoint-util.c',
130 'test-net-naming-scheme.c',
131 'test-nulstr-util.c',
133 'test-ordered-set.c',
135 'test-parse-argument.c',
136 'test-parse-helpers.c',
137 'test-path-lookup.c',
139 'test-percent-util.c',
141 'test-pretty-print.c',
143 'test-proc-cmdline.c',
144 'test-procfs-util.c',
148 'test-recurse-dir.c',
149 'test-replace-var.c',
150 'test-rlimit-util.c',
154 'test-secure-bits.c',
160 'test-signal-util.c',
162 'test-sleep-config.c',
163 'test-socket-netlink.c',
164 'test-socket-util.c',
167 'test-static-destruct.c',
169 'test-string-util.c',
170 'test-strip-tab-ansi.c',
173 'test-sysctl-util.c',
174 'test-terminal-util.c',
175 'test-tmpfile-util.c',
177 'test-uid-classification.c',
191 ############################################################
193 common_test_dependencies = [
204 'sources' : files('test-acl-util.c'),
205 'conditions' : ['HAVE_ACL'],
208 'sources' : files('test-af-list.c') +
209 generated_gperf_headers,
212 'sources' : files('test-arphrd-util.c') +
213 generated_gperf_headers,
216 'sources' : files('test-ask-password-api.c'),
220 'sources' : files('test-async.c'),
224 'sources' : files('test-boot-timestamps.c'),
225 'conditions' : ['ENABLE_EFI'],
228 'sources' : files('test-btrfs.c'),
232 'sources' : files('test-btrfs-physical-offset.c'),
236 'sources' : files('test-cap-list.c') +
237 generated_gperf_headers,
238 'dependencies' : libcap,
241 'sources' : files('test-capability.c'),
242 'dependencies' : libcap,
245 'sources' : files('test-chase-manual.c'),
249 'sources' : files('test-compress-benchmark.c'),
257 'sources' : files('test-compress.c'),
264 'sources' : files('test-cryptolib.c'),
265 'dependencies' : lib_openssl_or_gcrypt,
266 'conditions' : ['HAVE_OPENSSL_OR_GCRYPT'],
269 'sources' : files('test-dlopen-so.c'),
270 'dependencies' : libp11kit_cflags
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,
282 'sources' : files('test-errno-list.c') +
283 generated_gperf_headers,
286 'sources' : files('test-fd-util.c'),
287 'dependencies' : libseccomp,
292 'test-hashmap-plain.c',
294 test_hashmap_ordered_c,
299 'sources' : files('test-ip-protocol-list.c') +
300 shared_generated_gperf_headers,
303 'sources' : files('test-ipcrm.c'),
307 'sources' : files('test-json.c'),
308 'dependencies' : libm,
311 'sources' : files('test-libcrypt-util.c'),
312 'dependencies' : libcrypt,
316 'sources' : files('test-libmount.c'),
323 'sources' : files('test-loopback.c'),
324 'dependencies' : common_test_dependencies,
327 'sources' : files('test-math-util.c'),
328 'dependencies' : libm,
331 'sources' : files('test-mempress.c'),
332 'dependencies' : threads,
335 'sources' : files('test-mount-util.c'),
336 'dependencies' : libmount,
339 'sources' : files('test-netlink-manual.c'),
340 'dependencies' : libkmod,
341 'conditions' : ['HAVE_KMOD'],
345 'sources' : files('test-nft-set.c'),
349 'sources' : files('test-nscd-flush.c'),
350 'conditions' : ['ENABLE_NSCD'],
358 'dependencies' : libdl,
359 'conditions' : ['ENABLE_NSS'],
367 'dependencies' : libdl,
368 'conditions' : ['ENABLE_NSS'],
371 'sources' : files('test-openssl.c'),
372 'dependencies' : libopenssl,
373 'conditions' : ['HAVE_OPENSSL'],
376 'sources' : files('test-parse-util.c'),
377 'dependencies' : libm,
380 'sources' : files('test-process-util.c'),
381 'dependencies' : threads,
384 'sources' : files('test-qrcode-util.c'),
385 'dependencies' : libdl,
388 'sources' : files('test-random-util.c'),
389 'dependencies' : libm,
393 'sources' : files('test-sbat.c'),
394 'conditions' : ['ENABLE_BOOTLOADER'],
395 'c_args' : '-I@0@'.format(efi_config_h_dir),
398 'sources' : files('test-seccomp.c'),
399 'dependencies' : libseccomp,
400 'conditions' : ['HAVE_SECCOMP'],
403 'sources' : files('test-set-disable-mempool.c'),
404 'dependencies' : threads,
407 'sources' : files('test-sizeof.c'),
408 'link_with' : libbasic,
411 'sources' : files('test-time-util.c'),
415 'sources' : files('test-tpm2.c'),
416 'dependencies' : libopenssl,
420 'sources' : files('test-utmp.c'),
421 'conditions' : ['ENABLE_UTMP'],
424 'sources' : files('test-varlink.c'),
425 'dependencies' : threads,
428 'sources' : files('test-varlink-idl.c'),
429 'dependencies' : threads,
432 'sources' : files('test-watchdog.c'),
438 'name' : 'test-libsystemd-sym',
439 'sources' : test_libsystemd_sym_c,
440 'link_with' : libsystemd,
441 'suite' : 'libsystemd',
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',
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,
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',
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,
475 core_test_template + {
476 'sources' : files('test-bpf-firewall.c'),
477 'dependencies' : common_test_dependencies,
479 core_test_template + {
480 'sources' : files('test-bpf-foreign-programs.c'),
482 core_test_template + {
483 'sources' : files('test-bpf-restrict-fs.c'),
484 'dependencies' : common_test_dependencies,
486 core_test_template + {
487 'sources' : files('test-cgroup-cpu.c'),
489 core_test_template + {
490 'sources' : files('test-cgroup-mask.c'),
491 'dependencies' : common_test_dependencies,
493 core_test_template + {
494 'sources' : files('test-cgroup-unit-default.c'),
496 core_test_template + {
497 'sources' : files('test-chown-rec.c'),
499 core_test_template + {
500 'sources' : files('test-core-unit.c'),
501 'dependencies' : common_test_dependencies,
503 core_test_template + {
504 'sources' : files('test-emergency-action.c'),
506 core_test_template + {
507 'sources' : files('test-engine.c'),
508 'dependencies' : common_test_dependencies,
510 core_test_template + {
511 'sources' : files('test-execute.c'),
512 'dependencies' : common_test_dependencies,
515 core_test_template + {
516 'sources' : files('test-install.c'),
519 core_test_template + {
520 'sources' : files('test-job-type.c'),
521 'dependencies' : common_test_dependencies,
523 core_test_template + {
524 'sources' : files('test-load-fragment.c'),
525 'dependencies' : common_test_dependencies,
527 core_test_template + {
528 'sources' : files('test-loop-block.c'),
529 'dependencies' : [threads, libblkid],
532 core_test_template + {
533 'sources' : files('test-manager.c'),
535 core_test_template + {
536 'sources' : files('test-namespace.c'),
542 core_test_template + {
543 'sources' : files('test-ns.c'),
544 'dependencies' : common_test_dependencies,
547 core_test_template + {
548 'sources' : files('test-path.c'),
549 'dependencies' : common_test_dependencies,
552 core_test_template + {
553 'sources' : files('test-sched-prio.c'),
554 'dependencies' : common_test_dependencies,
556 core_test_template + {
557 'sources' : files('test-socket-bind.c'),
558 'dependencies' : libdl,
559 'conditions' : ['BPF_FRAMEWORK'],
561 core_test_template + {
562 'sources' : files('test-tables.c'),
564 core_test_template + {
565 'sources' : files('test-unit-name.c'),
566 'dependencies' : common_test_dependencies,
568 core_test_template + {
569 'sources' : files('test-unit-serialize.c'),
570 'dependencies' : common_test_dependencies,
572 core_test_template + {
573 'sources' : files('test-watch-pid.c'),
574 'dependencies' : common_test_dependencies,
577 # Tests from other directories that have link_with deps that were not defined earlier
579 'sources' : files('../libsystemd/sd-bus/test-bus-error.c'),
586 'sources' : files('../libsystemd/sd-device/test-sd-device-thread.c'),
591 'dependencies' : threads,
594 'sources' : files('../libudev/test-udev-device-thread.c'),
599 'dependencies' : threads,
602 'sources' : files('../libudev/test-libudev.c'),
609 'sources' : files('test-aux-scope.c'),