diff options
author | Luca Boccassi <bluca@debian.org> | 2023-02-08 20:36:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 20:36:21 +0100 |
commit | 777440f11092eef6009476a3aefe3bf835423126 (patch) | |
tree | 6be2cf7d32042844f2382615c7fdd68f6eebeaa8 /src/test | |
parent | ukify: add explanatory message when import fails (diff) | |
parent | journald: fix ignored filtering patterns for delegated cgroups (diff) | |
download | systemd-777440f11092eef6009476a3aefe3bf835423126.tar.xz systemd-777440f11092eef6009476a3aefe3bf835423126.zip |
Merge pull request #26225 from qdeslandes/fix_delegate_cgroup_logs_filtering
Fix delegate cgroup logs filtering
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-cgroup-util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 0b286ed8e4..cdf911926c 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -63,6 +63,33 @@ TEST(path_get_unit) { check_p_g_u("/user.slice/user-1000.slice/user@.service/server.service", -ENXIO, NULL); } +static void check_p_g_u_p(const char *path, int code, const char *result) { + _cleanup_free_ char *unit_path = NULL; + int r; + + r = cg_path_get_unit_path(path, &unit_path); + printf("%s: %s → %s %d expected %s %d\n", __func__, path, unit_path, r, strnull(result), code); + assert_se(r == code); + assert_se(streq_ptr(unit_path, result)); +} + +TEST(path_get_unit_path) { + check_p_g_u_p("/system.slice/foobar.service/sdfdsaf", 0, "/system.slice/foobar.service"); + check_p_g_u_p("/system.slice/getty@tty5.service", 0, "/system.slice/getty@tty5.service"); + check_p_g_u_p("/system.slice/getty@tty5.service/aaa/bbb", 0, "/system.slice/getty@tty5.service"); + check_p_g_u_p("/system.slice/getty@tty5.service/", 0, "/system.slice/getty@tty5.service"); + check_p_g_u_p("/system.slice/getty@tty6.service/tty5", 0, "/system.slice/getty@tty6.service"); + check_p_g_u_p("sadfdsafsda", -ENXIO, NULL); + check_p_g_u_p("/system.slice/getty####@tty6.service/xxx", -ENXIO, NULL); + check_p_g_u_p("/system.slice/system-waldo.slice/foobar.service/sdfdsaf", 0, "/system.slice/system-waldo.slice/foobar.service"); + check_p_g_u_p("/system.slice/system-waldo.slice/_cpu.service/sdfdsaf", 0, "/system.slice/system-waldo.slice/_cpu.service"); + check_p_g_u_p("/system.slice/system-waldo.slice/_cpu.service", 0, "/system.slice/system-waldo.slice/_cpu.service"); + check_p_g_u_p("/user.slice/user-1000.slice/user@1000.service/server.service", 0, "/user.slice/user-1000.slice/user@1000.service"); + check_p_g_u_p("/user.slice/user-1000.slice/user@.service/server.service", -ENXIO, NULL); + check_p_g_u_p("/user.slice/_user-1000.slice/user@1000.service/foobar.slice/foobar@pie.service", 0, "/user.slice/_user-1000.slice/user@1000.service"); + check_p_g_u_p("/_session-2.scope/_foobar@pie.service/pa/po", 0, "/_session-2.scope"); +} + static void check_p_g_u_u(const char *path, int code, const char *result) { _cleanup_free_ char *unit = NULL; int r; |