summaryrefslogtreecommitdiffstats
path: root/src/test/test-cgroup.c
diff options
context:
space:
mode:
authorWen Yang <wenyang@linux.alibaba.com>2020-02-18 13:56:21 +0100
committerWen Yang <wenyang@linux.alibaba.com>2020-02-18 15:36:28 +0100
commit4ef0ac8f500ba97f865e7a9981593fba64da7f25 (patch)
treeb0c851adbeaddee41e770f6fc299ed8c7334651e /src/test/test-cgroup.c
parentMerge pull request #14555 from poettering/table-multine (diff)
downloadsystemd-4ef0ac8f500ba97f865e7a9981593fba64da7f25.tar.xz
systemd-4ef0ac8f500ba97f865e7a9981593fba64da7f25.zip
test: fix some failures in test-cgroup
Fix the following issues in test-cgroup: 1, commit 65be7e06528a ("pid1: do not reset subtree_control on already-existing units with delegation") changed the return value of cg_create () as follows: "Returns 0 if the group already existed, 1 on success, negative otherwise." So we need to modify the test cases related to cg_create (). 2, commit efdb02375beb ("core: unified cgroup hierarchy support") changed cg_delete () to cg_rmdir (), so the test cases also need to be adjusted a bit. 3. There is no cleanup of "test-a". If we execute test-cgroup multiple times, we will encounter an error. Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Diffstat (limited to 'src/test/test-cgroup.c')
-rw-r--r--src/test/test-cgroup.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c
index f16cb291f2..afcdcdc441 100644
--- a/src/test/test-cgroup.c
+++ b/src/test/test-cgroup.c
@@ -13,10 +13,10 @@ int main(int argc, char *argv[]) {
char *path;
char *c, *p;
+ assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 1);
assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
- assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
- assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b") == 0);
- assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-c") == 0);
+ assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b") == 1);
+ assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-c") == 1);
assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b", 0) == 0);
assert_se(cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, getpid_cached(), &path) == 0);
@@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
assert_se(path_equal(path, "/test-a"));
free(path);
- assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", 0) == 0);
+ assert_se(cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, "/test-b/test-d", 0) == 1);
assert_se(cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, getpid_cached(), &path) == 0);
assert_se(path_equal(path, "/test-b/test-d"));
@@ -57,8 +57,10 @@ int main(int argc, char *argv[]) {
cg_trim(SYSTEMD_CGROUP_CONTROLLER, "/", false);
- assert_se(cg_rmdir(SYSTEMD_CGROUP_CONTROLLER, "/test-b") < 0);
- assert_se(cg_rmdir(SYSTEMD_CGROUP_CONTROLLER, "/test-a") >= 0);
+ assert_se(cg_rmdir(SYSTEMD_CGROUP_CONTROLLER, "/test-b") == 0);
+ assert_se(cg_rmdir(SYSTEMD_CGROUP_CONTROLLER, "/test-a") < 0);
+ assert_se(cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, "/test-a", SYSTEMD_CGROUP_CONTROLLER, "system.slice", 0) > 0);
+ assert_se(cg_rmdir(SYSTEMD_CGROUP_CONTROLLER, "/test-a") == 0);
assert_se(cg_split_spec("foobar:/", &c, &p) == 0);
assert_se(streq(c, "foobar"));
@@ -66,7 +68,7 @@ int main(int argc, char *argv[]) {
free(c);
free(p);
- assert_se(cg_split_spec("foobar:", &c, &p) < 0);
+ assert_se(cg_split_spec("foobar:", &c, &p) == 0);
assert_se(cg_split_spec("foobar:asdfd", &c, &p) < 0);
assert_se(cg_split_spec(":///", &c, &p) < 0);
assert_se(cg_split_spec(":", &c, &p) < 0);