#!/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 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/testsuite-55-testbloat.service.d # Activate swap file if we are in a VM if systemd-detect-virt --vm --quiet; then 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/testsuite-55-testbloat.service.d/override.conf <