]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-oomd-util: skip tests if cgroup memory controller is not available
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Sep 2021 11:37:50 +0000 (20:37 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 12 Sep 2021 01:29:25 +0000 (10:29 +0900)
Fixes #20593 and #20655.

src/oom/test-oomd-util.c

index 776c65820e37c2f59aba21227ec96e5338af965a..29f2c54ab13aa046961073ffeb33a9345b52c6c7 100644 (file)
@@ -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