5 # Let's run this test only if the "memory.oom.group" cgroupfs attribute
6 # exists. This test is a bit too strict, since the "memory.events"/"oom_kill"
7 # logic has been around since a longer time than "memory.oom.group", but it's
8 # an easier thing to test for, and also: let's not get confused by older
9 # kernels where the concept was still new.
11 if test -f /sys
/fs
/cgroup
/system.slice
/testsuite-32.service
/memory.oom.group
; then
12 systemd-analyze log-level debug
13 systemd-analyze log-target console
15 # Run a service that is guaranteed to be the first candidate for OOM killing
16 systemd-run
--unit=oomtest.service \
17 -p Type
=exec -p OOMScoreAdjust
=1000 -p OOMPolicy
=stop
-p MemoryAccounting
=yes \
20 # Trigger an OOM killer run
21 echo 1 >/proc
/sys
/kernel
/sysrq
22 echo f
>/proc
/sysrq-trigger
25 STATE
="$(systemctl show -P ActiveState oomtest.service)"
26 [ "$STATE" = "failed" ] && break
30 RESULT
="$(systemctl show -P Result oomtest.service)"
31 test "$RESULT" = "oom-kill"
33 systemd-analyze log-level info