tree-wide: use SPECIAL_ROOT_SLICE
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "parse-util.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "process-util.h"
|
||||
#include "special.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "test-helper.h"
|
||||
@@ -141,10 +142,10 @@ static void check_p_g_slice(const char *path, int code, const char *result) {
|
||||
|
||||
static void test_path_get_slice(void) {
|
||||
check_p_g_slice("/user.slice", 0, "user.slice");
|
||||
check_p_g_slice("/foobar", 0, "-.slice");
|
||||
check_p_g_slice("/foobar", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_slice("/user.slice/user-waldo.slice", 0, "user-waldo.slice");
|
||||
check_p_g_slice("", 0, "-.slice");
|
||||
check_p_g_slice("foobar", 0, "-.slice");
|
||||
check_p_g_slice("", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_slice("foobar", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_slice("foobar.slice", 0, "foobar.slice");
|
||||
check_p_g_slice("foo.slice/foo-bar.slice/waldo.service", 0, "foo-bar.slice");
|
||||
}
|
||||
@@ -165,10 +166,10 @@ static void test_path_get_user_slice(void) {
|
||||
check_p_g_u_slice("foobar.slice", -ENXIO, NULL);
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/waldo.service", -ENXIO, NULL);
|
||||
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service", 0, "-.slice");
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/", 0, "-.slice");
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service///", 0, "-.slice");
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/waldo.service", 0, "-.slice");
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service///", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/waldo.service", 0, SPECIAL_ROOT_SLICE);
|
||||
check_p_g_u_slice("foo.slice/foo-bar.slice/user@1000.service/piep.slice/foo.service", 0, "piep.slice");
|
||||
check_p_g_u_slice("/foo.slice//foo-bar.slice/user@1000.service/piep.slice//piep-pap.slice//foo.service", 0, "piep-pap.slice");
|
||||
}
|
||||
@@ -274,7 +275,7 @@ static void test_slice_to_path(void) {
|
||||
test_slice_to_path_one("foobar.slice", "foobar.slice", 0);
|
||||
test_slice_to_path_one("foobar-waldo.slice", "foobar.slice/foobar-waldo.slice", 0);
|
||||
test_slice_to_path_one("foobar-waldo.service", NULL, -EINVAL);
|
||||
test_slice_to_path_one("-.slice", "", 0);
|
||||
test_slice_to_path_one(SPECIAL_ROOT_SLICE, "", 0);
|
||||
test_slice_to_path_one("--.slice", NULL, -EINVAL);
|
||||
test_slice_to_path_one("-", NULL, -EINVAL);
|
||||
test_slice_to_path_one("-foo-.slice", NULL, -EINVAL);
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "manager.h"
|
||||
#include "path-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "special.h"
|
||||
#include "specifier.h"
|
||||
#include "string-util.h"
|
||||
#include "test-helper.h"
|
||||
@@ -338,7 +339,7 @@ static void test_unit_name_build(void) {
|
||||
}
|
||||
|
||||
static void test_slice_name_is_valid(void) {
|
||||
assert_se(slice_name_is_valid("-.slice"));
|
||||
assert_se(slice_name_is_valid(SPECIAL_ROOT_SLICE));
|
||||
assert_se(slice_name_is_valid("foo.slice"));
|
||||
assert_se(slice_name_is_valid("foo-bar.slice"));
|
||||
assert_se(slice_name_is_valid("foo-bar-baz.slice"));
|
||||
@@ -356,7 +357,7 @@ static void test_build_subslice(void) {
|
||||
char *a;
|
||||
char *b;
|
||||
|
||||
assert_se(slice_build_subslice("-.slice", "foo", &a) >= 0);
|
||||
assert_se(slice_build_subslice(SPECIAL_ROOT_SLICE, "foo", &a) >= 0);
|
||||
assert_se(slice_build_subslice(a, "bar", &b) >= 0);
|
||||
free(a);
|
||||
assert_se(slice_build_subslice(b, "barfoo", &a) >= 0);
|
||||
@@ -378,8 +379,8 @@ static void test_build_parent_slice_one(const char *name, const char *expect, in
|
||||
}
|
||||
|
||||
static void test_build_parent_slice(void) {
|
||||
test_build_parent_slice_one("-.slice", NULL, 0);
|
||||
test_build_parent_slice_one("foo.slice", "-.slice", 1);
|
||||
test_build_parent_slice_one(SPECIAL_ROOT_SLICE, NULL, 0);
|
||||
test_build_parent_slice_one("foo.slice", SPECIAL_ROOT_SLICE, 1);
|
||||
test_build_parent_slice_one("foo-bar.slice", "foo.slice", 1);
|
||||
test_build_parent_slice_one("foo-bar-baz.slice", "foo-bar.slice", 1);
|
||||
test_build_parent_slice_one("foo-bar--baz.slice", NULL, -EINVAL);
|
||||
|
||||
Reference in New Issue
Block a user