ryantimwilson / rpms / systemd

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