#!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later set -eux set -o pipefail systemd-analyze log-level debug # Ensure that the init.scope.d drop-in is applied on boot test "$(cat /sys/fs/cgroup/init.scope/memory.high)" != "max" # Loose checks to ensure the environment has the necessary features for systemd-oomd [[ -e /proc/pressure ]] || echo "no PSI" >>/skipped cgroup_type="$(stat -fc %T /sys/fs/cgroup/)" if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then echo "no cgroup2" >>/skipped fi if [ ! -f /usr/lib/systemd/systemd-oomd ] && [ ! -f /lib/systemd/systemd-oomd ]; then echo "no oomd" >>/skipped fi if [[ -e /skipped ]]; then exit 0 fi rm -rf /run/systemd/system/testsuite-55-testbloat.service.d # Activate swap file if we are in a VM if systemd-detect-virt --vm --quiet; then mkswap /swapfile swapon /swapfile swapon --show fi # Configure oomd explicitly to avoid conflicts with distro dropins mkdir -p /run/systemd/oomd.conf.d/ cat >/run/systemd/oomd.conf.d/99-oomd-test.conf </run/systemd/system/-.slice.d/99-oomd-test.conf </run/systemd/system/user@.service.d/99-oomd-test.conf </run/systemd/system/systemd-oomd.service.d/debug.conf </run/systemd/system/testsuite-55-testbloat.service.d/override.conf <