]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/units/testsuite-32.sh
test: use show -P in places
[thirdparty/systemd.git] / test / units / testsuite-32.sh
CommitLineData
ff12a795 1#!/usr/bin/env bash
36869f33
LP
2set -ex
3set -o pipefail
4
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.
10
c8937bed 11if test -f /sys/fs/cgroup/system.slice/testsuite-32.service/memory.oom.group; then
36869f33
LP
12
13 systemd-analyze log-level debug
14 systemd-analyze log-target console
15
16 # Run a service that is guaranteed to be the first candidate for OOM killing
c8937bed
ZJS
17 systemd-run --unit=oomtest.service \
18 -p Type=exec -p OOMScoreAdjust=1000 -p OOMPolicy=stop -p MemoryAccounting=yes \
19 sleep infinity
36869f33
LP
20
21 # Trigger an OOM killer run
c8937bed
ZJS
22 echo 1 >/proc/sys/kernel/sysrq
23 echo f >/proc/sysrq-trigger
36869f33
LP
24
25 while : ; do
5522e628 26 STATE=`systemctl show -P ActiveState oomtest.service`
36869f33
LP
27 [ "$STATE" = "failed" ] && break
28 sleep .5
29 done
30
5522e628 31 RESULT=`systemctl show -P Result oomtest.service`
36869f33
LP
32 test "$RESULT" = "oom-kill"
33
34 systemd-analyze log-level info
35fi
36
c8937bed 37echo OK >/testok
36869f33
LP
38
39exit 0