From: Nishal Kulkarni Date: Mon, 14 Mar 2022 18:40:39 +0000 (+0530) Subject: test/oomd: Add test for new oomd_ooms xattr X-Git-Tag: v251-rc1~65^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0ebfef358af2e714873134acd16f9c5235a7bc7;p=thirdparty%2Fsystemd.git test/oomd: Add test for new oomd_ooms xattr Check if `user.oomd_ooms` xattr is being set as part of `oomd_cgroup_kill()` this xattr tracks OOM kills that were initiated by systemd-oomd. --- diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c index 13d9e60f16c..82a60ad8803 100644 --- a/src/oom/test-oomd-util.c +++ b/src/oom/test-oomd-util.c @@ -77,12 +77,16 @@ static void test_oomd_cgroup_kill(void) { abort(); } + assert_se(cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, cgroup, "user.oomd_ooms", &v) >= 0); + assert_se(streq(v, i == 0 ? "1" : "2")); + v = mfree(v); + /* Wait a bit since processes may take some time to be cleaned up. */ sleep(2); assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, cgroup) == true); assert_se(cg_get_xattr_malloc(SYSTEMD_CGROUP_CONTROLLER, cgroup, "user.oomd_kill", &v) >= 0); - assert_se(memcmp(v, i == 0 ? "2" : "4", 2) == 0); + assert_se(streq(v, i == 0 ? "2" : "4")); } }