#!/usr/bin/env bash # SPDX-License-Identifier: LGPL-2.1-or-later set -eux set -o pipefail # shellcheck source=test/units/util.sh . "$(dirname "$0")"/util.sh . /etc/os-release # OpenSUSE does not have the stress tool packaged. It does have stress-ng but the stress-ng does not support # --vm-stride which this test uses. if [[ "$ID" =~ "opensuse" ]]; then echo "Skipping due to missing stress package in OpenSUSE" >>/skipped exit 77 fi 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 [[ "$(get_cgroup_hierarchy)" == "unified" ]] || echo "no cgroupsv2" >>/skipped [[ -x /usr/lib/systemd/systemd-oomd ]] || echo "no oomd" >>/skipped if [[ -s /skipped ]]; then exit 77 fi rm -rf /run/systemd/system/TEST-55-OOMD-testbloat.service.d # Activate swap file if we are in a VM if systemd-detect-virt --vm --quiet; then swapoff --all if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then btrfs filesystem mkswapfile -s 64M /swapfile else dd if=/dev/zero of=/swapfile bs=1M count=64 chmod 0600 /swapfile mkswap /swapfile fi 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/TEST-55-OOMD-testbloat.service.d/override.conf <