]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/tests.h
6817ef4860653c98403cdc04ec5a8ae79aea5087
[thirdparty/systemd.git] / src / shared / tests.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "sd-daemon.h"
7
8 #include "macro.h"
9
10 static inline bool manager_errno_skip_test(int r) {
11 return IN_SET(abs(r),
12 EPERM,
13 EACCES,
14 EADDRINUSE,
15 EHOSTDOWN,
16 ENOENT,
17 ENOMEDIUM /* cannot determine cgroup */
18 );
19 }
20
21 char* setup_fake_runtime_dir(void);
22 int enter_cgroup_subroot(char **ret_cgroup);
23 int get_testdata_dir(const char *suffix, char **ret);
24 const char* get_catalog_dir(void);
25 bool slow_tests_enabled(void);
26 void test_setup_logging(int level);
27 int log_tests_skipped(const char *message);
28 int log_tests_skipped_errno(int r, const char *message);
29
30 bool have_namespaces(void);
31
32 /* We use the small but non-trivial limit here */
33 #define CAN_MEMLOCK_SIZE (512 * 1024U)
34 bool can_memlock(void);
35
36 #define TEST_REQ_RUNNING_SYSTEMD(x) \
37 if (sd_booted() > 0) { \
38 x; \
39 } else { \
40 printf("systemd not booted skipping '%s'\n", #x); \
41 }