I don't think there's any particular reason to keep those functions in a separate
file.
#undef basename
#include "alloc-util.h"
+#include "cgroup-setup.h"
+#include "cgroup-util.h"
#include "env-file.h"
#include "env-util.h"
#include "fs-util.h"
#include "log.h"
#include "path-util.h"
+#include "random-util.h"
#include "strv.h"
#include "tests.h"
assert_se(munmap(p, CAN_MEMLOCK_SIZE) >= 0);
return b;
}
+
+int enter_cgroup_subroot(void) {
+ _cleanup_free_ char *cgroup_root = NULL, *cgroup_subroot = NULL;
+ CGroupMask supported;
+ int r;
+
+ r = cg_pid_get_path(NULL, 0, &cgroup_root);
+ if (r == -ENOMEDIUM)
+ return log_warning_errno(r, "cg_pid_get_path(NULL, 0, ...) failed: %m");
+ assert(r >= 0);
+
+ assert_se(asprintf(&cgroup_subroot, "%s/%" PRIx64, cgroup_root, random_u64()) >= 0);
+ assert_se(cg_mask_supported(&supported) >= 0);
+
+ /* If this fails, then we don't mind as the later cgroup operations will fail too, and it's fine if
+ * we handle any errors at that point. */
+
+ r = cg_create_everywhere(supported, _CGROUP_MASK_ALL, cgroup_subroot);
+ if (r < 0)
+ return r;
+
+ return cg_attach_everywhere(supported, cgroup_subroot, 0, NULL, NULL);
+}
#include <stdbool.h>
+#include "sd-daemon.h"
+
#include "macro.h"
static inline bool manager_errno_skip_test(int r) {
}
char* setup_fake_runtime_dir(void);
+int enter_cgroup_subroot(void);
const char* get_testdata_dir(void);
const char* get_catalog_dir(void);
bool slow_tests_enabled(void);
/* We use the small but non-trivial limit here */
#define CAN_MEMLOCK_SIZE (512 * 1024U)
bool can_memlock(void);
+
+#define TEST_REQ_RUNNING_SYSTEMD(x) \
+ if (sd_booted() > 0) { \
+ x; \
+ } else { \
+ printf("systemd not booted skipping '%s'\n", #x); \
+ }
[],
[]],
- [['src/test/test-engine.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-engine.c'],
[libcore,
libudev,
libshared],
[],
[]],
- [['src/test/test-unit-name.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-unit-name.c'],
[libcore,
libshared],
[threads,
libmount,
libblkid]],
- [['src/test/test-load-fragment.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-load-fragment.c'],
[libcore,
libshared],
[threads,
[libbasic],
[]],
- [['src/test/test-bpf-firewall.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-bpf-firewall.c'],
[libcore,
libshared],
[libmount,
libselinux,
libblkid]],
- [['src/test/test-watch-pid.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-watch-pid.c'],
[libcore,
libshared],
[libmount,
libshared],
[]],
- [['src/test/test-cgroup-unit-default.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-cgroup-unit-default.c'],
[libcore,
libshared],
[]],
- [['src/test/test-cgroup-mask.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-cgroup-mask.c'],
[libcore,
libshared],
[threads,
[],
'', 'manual'],
- [['src/test/test-path.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-path.c'],
[libcore,
libshared],
[threads,
libmount,
libblkid]],
- [['src/test/test-execute.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-execute.c'],
[libcore,
libshared],
[threads,
[],
[]],
- [['src/test/test-sched-prio.c',
- 'src/test/test-helper.c'],
+ [['src/test/test-sched-prio.c'],
[libcore,
libshared],
[threads,
#include "manager.h"
#include "rm-rf.h"
#include "service.h"
-#include "test-helper.h"
#include "tests.h"
#include "unit.h"
#include "virt.h"
#include "manager.h"
#include "rm-rf.h"
#include "string-util.h"
-#include "test-helper.h"
#include "tests.h"
#include "unit.h"
#include "cgroup.h"
#include "manager.h"
#include "rm-rf.h"
-#include "test-helper.h"
#include "tests.h"
#include "unit.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
-#include "test-helper.h"
#include "tests.h"
#include "user-util.h"
#include "util.h"
#include "manager.h"
#include "rm-rf.h"
#include "strv.h"
-#include "test-helper.h"
#include "tests.h"
#include "service.h"
#endif
#include "service.h"
#include "stat-util.h"
-#include "test-helper.h"
#include "tests.h"
#include "unit.h"
#include "user-util.h"
+++ /dev/null
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-#include "test-helper.h"
-#include "random-util.h"
-#include "alloc-util.h"
-#include "cgroup-setup.h"
-#include "string-util.h"
-
-int enter_cgroup_subroot(void) {
- _cleanup_free_ char *cgroup_root = NULL, *cgroup_subroot = NULL;
- CGroupMask supported;
- int r;
-
- r = cg_pid_get_path(NULL, 0, &cgroup_root);
- if (r == -ENOMEDIUM)
- return log_warning_errno(r, "cg_pid_get_path(NULL, 0, ...) failed: %m");
- assert(r >= 0);
-
- assert_se(asprintf(&cgroup_subroot, "%s/%" PRIx64, cgroup_root, random_u64()) >= 0);
- assert_se(cg_mask_supported(&supported) >= 0);
-
- /* If this fails, then we don't mind as the later cgroup operations will fail too, and it's fine if we handle
- * any errors at that point. */
-
- r = cg_create_everywhere(supported, _CGROUP_MASK_ALL, cgroup_subroot);
- if (r < 0)
- return r;
-
- return cg_attach_everywhere(supported, cgroup_subroot, 0, NULL, NULL);
-}
+++ /dev/null
-/* SPDX-License-Identifier: LGPL-2.1+ */
-#pragma once
-
-/***
- Copyright © 2013 Holger Hans Peter Freyther
-***/
-
-#include "sd-daemon.h"
-
-#define TEST_REQ_RUNNING_SYSTEMD(x) \
- if (sd_booted() > 0) { \
- x; \
- } else { \
- printf("systemd not booted skipping '%s'\n", #x); \
- }
-
-int enter_cgroup_subroot(void);
#include "specifier.h"
#include "string-util.h"
#include "strv.h"
-#include "test-helper.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "user-util.h"
#include "rm-rf.h"
#include "string-util.h"
#include "strv.h"
-#include "test-helper.h"
#include "tests.h"
#include "unit.h"
#include "util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "terminal-util.h"
-#include "test-helper.h"
#include "tests.h"
#include "util.h"
#include "virt.h"
#include "macro.h"
#include "manager.h"
#include "rm-rf.h"
-#include "test-helper.h"
#include "tests.h"
int main(int argc, char *argv[]) {
#include "special.h"
#include "specifier.h"
#include "string-util.h"
-#include "test-helper.h"
#include "tests.h"
#include "unit-def.h"
#include "unit-name.h"
#include "manager.h"
#include "rm-rf.h"
#include "service.h"
-#include "test-helper.h"
#include "tests.h"
int main(int argc, char *argv[]) {