]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-cgroup-util.c
kdbus: parse cgroup meta data, too
[thirdparty/systemd.git] / src / test / test-cgroup-util.c
1 #include <assert.h>
2
3 #include "util.h"
4 #include "cgroup-util.h"
5
6 #define check_c_t_u(path, code, result) \
7 { \
8 char a[] = path; \
9 char *unit = NULL; \
10 assert_se(cgroup_to_unit(a, &unit) == code); \
11 assert(code < 0 || streq(unit, result)); \
12 }
13
14
15 static void test_cgroup_to_unit(void) {
16 check_c_t_u("/system/getty@.service/tty2", 0, "getty@tty2.service");
17 check_c_t_u("/system/getty@.service/", -EINVAL, "getty@tty2.service");
18 check_c_t_u("/system/getty@.service", -EINVAL, "getty@tty2.service");
19 check_c_t_u("/system/getty.service", 0, "getty.service");
20 check_c_t_u("/system/getty", -EINVAL, "getty.service");
21 }
22
23 int main(void) {
24 test_cgroup_to_unit();
25
26 return 0;
27 }