diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-06-17 21:33:26 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-06-17 21:36:51 +0200 |
commit | a016b9228f338cb9b380ce7e00826ef462767d98 (patch) | |
tree | 515b85e7fb384bc186374067554baf233897a9d3 /src/test | |
parent | c647f10918940b5d11870df6d008c6c3180bdc41 (diff) |
core: add new .slice unit type for partitioning systems
In order to prepare for the kernel cgroup rework, let's introduce a new
unit type to systemd, the "slice". Slices can be arranged in a tree and
are useful to partition resources freely and hierarchally by the user.
Each service unit can now be assigned to one of these slices, and later
on login users and machines may too.
Slices translate pretty directly to the cgroup hierarchy, and the
various objects can be assigned to any of the slices in the tree.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-cgroup-util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index c9634d42b0..d4d58b320b 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -170,6 +170,25 @@ static void test_controller_is_valid(void) { assert_se(!cg_controller_is_valid("tatü", false)); } +static void test_slice_to_path_one(const char *unit, const char *path, int error) { + _cleanup_free_ char *ret = NULL; + + assert_se(cg_slice_to_path(unit, &ret) == error); + assert_se(streq_ptr(ret, path)); +} + +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", NULL, -EINVAL); + test_slice_to_path_one("-foo-.slice", NULL, -EINVAL); + test_slice_to_path_one("-foo.slice", NULL, -EINVAL); + test_slice_to_path_one("a-b.slice", "a.slice/a-b.slice", 0); + 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); +} + int main(void) { test_path_decode_unit(); test_path_get_unit(); @@ -178,6 +197,7 @@ int main(void) { test_proc(); test_escape(); test_controller_is_valid(); + test_slice_to_path(); return 0; } |