diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-24 19:31:44 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-24 19:31:44 +0100 |
commit | 751bc6ac79320bc16e63e8c1bbb713c30a3b7bc9 (patch) | |
tree | 513508ade203dc372d6aabbfcb8bf5e6cc490dc6 /src/test/test-cgroup-util.c | |
parent | 4e6a9570b698b335c6f59ec3556dfb3e95817d75 (diff) |
bus: properly shift cgroup data returned from kdbus by the container's root before parsing
Diffstat (limited to 'src/test/test-cgroup-util.c')
-rw-r--r-- | src/test/test-cgroup-util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index f94f213f54..12dcc17ddb 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -246,6 +246,21 @@ static void test_slice_to_path(void) { test_slice_to_path_one("a-b-c-d-e.slice", "a.slice/a-b.slice/a-b-c.slice/a-b-c-d.slice/a-b-c-d-e.slice", 0); } +static void test_shift_path_one(const char *raw, const char *root, const char *shifted) { + const char *s = NULL; + + assert_se(cg_shift_path(raw, root, &s) >= 0); + assert_se(streq(s, shifted)); +} + +static void test_shift_path(void) { + + test_shift_path_one("/foobar/waldo", "/", "/foobar/waldo"); + test_shift_path_one("/foobar/waldo", "", "/foobar/waldo"); + test_shift_path_one("/foobar/waldo", "/foobar", "/waldo"); + test_shift_path_one("/foobar/waldo", "/fuckfuck", "/foobar/waldo"); +} + int main(void) { test_path_decode_unit(); test_path_get_unit(); @@ -258,6 +273,7 @@ int main(void) { TEST_REQ_RUNNING_SYSTEMD(test_escape()); test_controller_is_valid(); test_slice_to_path(); + test_shift_path(); return 0; } |