summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-09-11 20:37:50 +0900
committerLuca Boccassi <luca.boccassi@gmail.com>2021-11-14 13:08:28 +0000
commit38787a985396277058a20ac0c6f66fd1377d0737 (patch)
tree1849e0b2c7006e7ffa2378a7d30cd1fddff1d3ee
parent9d08ba9b3fa7542037e0522c10d63517366afda6 (diff)
downloadsystemd-38787a985396277058a20ac0c6f66fd1377d0737.tar.gz
test-oomd-util: skip tests if cgroup memory controller is not available
Fixes #20593 and #20655. (cherry picked from commit 8b2e22579a6549ab8423858819703fc142862bcb)
-rw-r--r--src/oom/test-oomd-util.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c
index 776c65820e..29f2c54ab1 100644
--- a/src/oom/test-oomd-util.c
+++ b/src/oom/test-oomd-util.c
@@ -90,6 +90,7 @@ static void test_oomd_cgroup_context_acquire_and_insert(void) {
_cleanup_free_ char *cgroup = NULL;
ManagedOOMPreference root_pref;
OomdCGroupContext *c1, *c2;
+ CGroupMask mask;
bool test_xattrs;
int root_xattrs, r;
@@ -102,6 +103,11 @@ static void test_oomd_cgroup_context_acquire_and_insert(void) {
if (cg_all_unified() <= 0)
return (void) log_tests_skipped("cgroups are not running in unified mode");
+ assert_se(cg_mask_supported(&mask) >= 0);
+
+ if (!FLAGS_SET(mask, CGROUP_MASK_MEMORY))
+ return (void) log_tests_skipped("cgroup memory controller is not available");
+
assert_se(cg_pid_get_path(NULL, 0, &cgroup) >= 0);
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities