test: move TEST-32-OOMPOLICY setup to static files

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-12-10 09:43:14 +01:00
parent 048d52d51e
commit c8937bed08
3 changed files with 15 additions and 20 deletions

View file

@ -16,21 +16,7 @@ test_setup() {
setup_basic_environment
mask_supporting_services
# setup the testsuite service
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
[Unit]
Description=Testsuite service
[Service]
ExecStart=/testsuite.sh
Type=oneshot
MemoryAccounting=yes
EOF
cp testsuite.sh $initdir/
setup_testsuite
)
}
do_test "$@"
do_test "$@" 32

View file

@ -0,0 +1,7 @@
[Unit]
Description=TEST-32-OOMPOLICY
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot
MemoryAccounting=yes

View file

@ -8,13 +8,15 @@ set -o pipefail
# an easier thing to test for, and also: let's not get confused by older
# kernels where the concept was still new.
if test -f /sys/fs/cgroup/system.slice/testsuite.service/memory.oom.group ; then
if test -f /sys/fs/cgroup/system.slice/testsuite-32.service/memory.oom.group; then
systemd-analyze log-level debug
systemd-analyze log-target console
# Run a service that is guaranteed to be the first candidate for OOM killing
systemd-run --unit=oomtest.service -p Type=exec -p OOMScoreAdjust=1000 -p OOMPolicy=stop -p MemoryAccounting=yes /bin/sleep infinity
systemd-run --unit=oomtest.service \
-p Type=exec -p OOMScoreAdjust=1000 -p OOMPolicy=stop -p MemoryAccounting=yes \
sleep infinity
# Trigger an OOM killer run
echo 1 >/proc/sys/kernel/sysrq