Skip to content

Commit

Permalink
oomd: fix unreachable test case in test-oomd-util
Browse files Browse the repository at this point in the history
This conditional with !empty_or_root(ctx->path) always returns false
because the most recent oomd_cgroup_context_acquire() call was with the
root cgroup. Make sure this test case can be reached by checking cgroup
instead of ctx->path.

While here, use an unused uid (61183) instead of the nobody uid so the
test case does not fail in unprivileged LXD containers.

(cherry picked from commit f05bcc1)
  • Loading branch information
enr0n authored and keszybz committed Nov 24, 2022
1 parent 2bdf5b0 commit bcd42b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/oom/test-oomd-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ static void test_oomd_fetch_cgroup_oom_preference(void) {

/* Assert that avoid/omit are not set if the cgroup and prefix are not
* owned by the same user.*/
if (test_xattrs && !empty_or_root(ctx->path)) {
if (test_xattrs && !empty_or_root(cgroup)) {
ctx = oomd_cgroup_context_free(ctx);
assert_se(cg_set_access(SYSTEMD_CGROUP_CONTROLLER, cgroup, 65534, 0) >= 0);
assert_se(cg_set_access(SYSTEMD_CGROUP_CONTROLLER, cgroup, 61183, 0) >= 0);
assert_se(oomd_cgroup_context_acquire(cgroup, &ctx) == 0);

assert_se(oomd_fetch_cgroup_oom_preference(ctx, NULL) == 0);
Expand Down

0 comments on commit bcd42b3

Please sign in to comment.