diff options
author | Dan Streetman <ddstreet@canonical.com> | 2021-02-24 07:29:15 -0500 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-02-25 16:32:04 +0900 |
commit | b66789a9b5d4127d8a8065d47b7ec13e2f01e33a (patch) | |
tree | 21083126cc6d1a307f5987269a8b3a9902fdba75 | |
parent | a437c5e4da666d16f15649461ce45e0e6d735148 (diff) | |
download | systemd-b66789a9b5d4127d8a8065d47b7ec13e2f01e33a.tar.gz |
test: skip tests if cgroup isn't mounted
Debian builds in a chroot without cgroup mounted, so tests expecting
to access cgroup will fail with ENOMEDIUM, so skip the tests in that
situation.
-rw-r--r-- | src/test/test-cgroup-util.c | 2 | ||||
-rw-r--r-- | src/test/test-cgroup.c | 5 | ||||
-rw-r--r-- | src/test/test-condition.c | 10 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 41b1df117e..f95832acf6 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -338,7 +338,7 @@ static void test_cg_tests(void) { r = cg_unified(); if (r == -ENOMEDIUM) { - log_notice_errno(r, "Skipping cg hierarchy tests: %m"); + log_tests_skipped("cgroup not mounted"); return; } assert_se(r >= 0); diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c index 722e11a0c0..3025a9a986 100644 --- a/src/test/test-cgroup.c +++ b/src/test/test-cgroup.c @@ -47,10 +47,11 @@ static void test_cg_create(void) { int r; r = cg_unified_cached(false); - if (r < 0) { - log_info_errno(r, "Skipping %s: %m", __func__); + if (r == -ENOMEDIUM) { + log_tests_skipped("cgroup not mounted"); return; } + assert_se(r >= 0); _cleanup_free_ char *here = NULL; assert_se(cg_pid_get_path_shifted(0, NULL, &here) >= 0); diff --git a/src/test/test-condition.c b/src/test/test-condition.c index 3fe961f60b..db15fe3136 100644 --- a/src/test/test-condition.c +++ b/src/test/test-condition.c @@ -129,6 +129,11 @@ static void test_condition_test_control_group_hierarchy(void) { int r; r = cg_unified(); + if (r == -ENOMEDIUM) { + log_tests_skipped("cgroup not mounted"); + return; + } + assert_se(r >= 0); condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, "v1", false, false); assert_se(condition); @@ -148,10 +153,11 @@ static void test_condition_test_control_group_controller(void) { int r; r = cg_unified(); - if (r < 0) { - log_notice_errno(r, "Skipping ConditionControlGroupController tests: %m"); + if (r == -ENOMEDIUM) { + log_tests_skipped("cgroup not mounted"); return; } + assert_se(r >= 0); /* Invalid controllers are ignored */ condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, "thisisnotarealcontroller", false, false); |