X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftest%2Ftest-cgroup-util.c;h=295bb02e3be788952fabd8a81787fe24e0abf3e7;hp=ed2c6aeeae053a989a504de73da49c122e4029fe;hb=b463b81399f0bc0d54107ef819cc0f843473c7d7;hpb=374ec6abf31ada6ca554cc8ea99b282373fac010 diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index ed2c6aeea..295bb02e3 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -32,12 +32,15 @@ static void check_p_d_u(const char *path, int code, const char *result) { } static void test_path_decode_unit(void) { - check_p_d_u("getty@.service/getty@tty2.service", 0, "getty@tty2.service"); - check_p_d_u("getty@.service/getty@tty2.service/xxx", 0, "getty@tty2.service"); + check_p_d_u("getty@tty2.service", 0, "getty@tty2.service"); + check_p_d_u("getty@tty2.service/", 0, "getty@tty2.service"); + check_p_d_u("getty@tty2.service/xxx", 0, "getty@tty2.service"); check_p_d_u("getty@.service/", -EINVAL, NULL); check_p_d_u("getty@.service", -EINVAL, NULL); check_p_d_u("getty.service", 0, "getty.service"); check_p_d_u("getty", -EINVAL, NULL); + check_p_d_u("getty/waldo", -EINVAL, NULL); + check_p_d_u("_cpu.service", 0, "cpu.service"); } static void check_p_g_u(const char *path, int code, const char *result) { @@ -49,13 +52,14 @@ static void check_p_g_u(const char *path, int code, const char *result) { static void test_path_get_unit(void) { check_p_g_u("/system.slice/foobar.service/sdfdsaf", 0, "foobar.service"); - check_p_g_u("/system.slice/getty@.service/getty@tty5.service", 0, "getty@tty5.service"); - check_p_g_u("/system.slice/getty@.service/getty@tty5.service/aaa/bbb", 0, "getty@tty5.service"); - check_p_g_u("/system.slice/getty@.service/getty@tty5.service/", 0, "getty@tty5.service"); + check_p_g_u("/system.slice/getty@tty5.service", 0, "getty@tty5.service"); + check_p_g_u("/system.slice/getty@tty5.service/aaa/bbb", 0, "getty@tty5.service"); + check_p_g_u("/system.slice/getty@tty5.service/", 0, "getty@tty5.service"); check_p_g_u("/system.slice/getty@tty6.service/tty5", 0, "getty@tty6.service"); check_p_g_u("sadfdsafsda", -EINVAL, NULL); - check_p_g_u("/system.slice/getty####@tty6.service/tty5", -EINVAL, NULL); + check_p_g_u("/system.slice/getty####@tty6.service/xxx", -EINVAL, NULL); check_p_g_u("/system.slice/system-waldo.slice/foobar.service/sdfdsaf", 0, "foobar.service"); + check_p_g_u("/system.slice/system-waldo.slice/_cpu.service/sdfdsaf", 0, "cpu.service"); } static void check_p_g_u_u(const char *path, int code, const char *result) { @@ -71,10 +75,11 @@ static void test_path_get_user_unit(void) { check_p_g_u_u("/user.slice/user-1002.slice/session-2.scope/foobar.service/waldo", 0, "foobar.service"); check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar.service/waldo/uuuux", 0, "foobar.service"); check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/waldo/waldo/uuuux", -EINVAL, NULL); - check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar@.service/foobar@pie.service/pa/po", 0, "foobar@pie.service"); - check_p_g_u_u("/session-2.scope/foobar@.service/foobar@pie.service/pa/po", 0, "foobar@pie.service"); - check_p_g_u_u("/xyz.slice/xyz-waldo.slice/session-77.scope/foobar@.service/foobar@pie.service/pa/po", 0, "foobar@pie.service"); + check_p_g_u_u("/user.slice/user-1000.slice/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service"); + check_p_g_u_u("/session-2.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service"); + check_p_g_u_u("/xyz.slice/xyz-waldo.slice/session-77.scope/foobar@pie.service/pa/po", 0, "foobar@pie.service"); check_p_g_u_u("/meh.service", -ENOENT, NULL); + check_p_g_u_u("/session-3.scope/_cpu.service", 0, "cpu.service"); } static void check_p_g_s(const char *path, int code, const char *result) {