ac3a84
From 7706a5f2d35c6192a557fe7a72f76ea4e2591daf Mon Sep 17 00:00:00 2001
ac3a84
From: Nick Rosbrook <nick.rosbrook@canonical.com>
ac3a84
Date: Tue, 22 Nov 2022 11:30:03 -0500
ac3a84
Subject: [PATCH] oomd: fix unreachable test case in test-oomd-util
ac3a84
ac3a84
This conditional with !empty_or_root(ctx->path) always returns false
ac3a84
because the most recent oomd_cgroup_context_acquire() call was with the
ac3a84
root cgroup. Make sure this test case can be reached by checking cgroup
ac3a84
instead of ctx->path.
ac3a84
ac3a84
While here, use an unused uid (61183) instead of the nobody uid so the
ac3a84
test case does not fail in unprivileged LXD containers.
ac3a84
ac3a84
(cherry picked from commit f05bcc18941eef5c2f93cfa06660eb06e0dc4c55)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 src/oom/test-oomd-util.c | 4 ++--
ac3a84
 1 file changed, 2 insertions(+), 2 deletions(-)
ac3a84
ac3a84
diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c
ac3a84
index 176e3a8d69..faa75c5578 100644
ac3a84
--- a/src/oom/test-oomd-util.c
ac3a84
+++ b/src/oom/test-oomd-util.c
ac3a84
@@ -475,9 +475,9 @@ static void test_oomd_fetch_cgroup_oom_preference(void) {
ac3a84
 
ac3a84
         /* Assert that avoid/omit are not set if the cgroup and prefix are not
ac3a84
          * owned by the same user.*/
ac3a84
-        if (test_xattrs && !empty_or_root(ctx->path)) {
ac3a84
+        if (test_xattrs && !empty_or_root(cgroup)) {
ac3a84
                 ctx = oomd_cgroup_context_free(ctx);
ac3a84
-                assert_se(cg_set_access(SYSTEMD_CGROUP_CONTROLLER, cgroup, 65534, 0) >= 0);
ac3a84
+                assert_se(cg_set_access(SYSTEMD_CGROUP_CONTROLLER, cgroup, 61183, 0) >= 0);
ac3a84
                 assert_se(oomd_cgroup_context_acquire(cgroup, &ctx) == 0);
ac3a84
 
ac3a84
                 assert_se(oomd_fetch_cgroup_oom_preference(ctx, NULL) == 0);