summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-06-24 00:19:31 +0200
committerLuca Boccassi <bluca@debian.org>2023-06-24 12:48:51 +0200
commitf434f182ccfd17a214e4b07cec033318e6c4f7b2 (patch)
tree7cd717afb0c6de29b7e9672c666a9dfce70d0a0b
parentTEST-55-OOMD: use 'stress' to create high pressure (diff)
downloadsystemd-f434f182ccfd17a214e4b07cec033318e6c4f7b2.tar.xz
systemd-f434f182ccfd17a214e4b07cec033318e6c4f7b2.zip
TEST-55-OOMD: use swap file instead of partition
The partition seems not to work on Ubuntu for some reason, use a swap file instead
Diffstat (limited to '')
-rwxr-xr-xtest/TEST-55-OOMD/test.sh15
-rwxr-xr-xtest/units/testsuite-55.sh7
2 files changed, 14 insertions, 8 deletions
diff --git a/test/TEST-55-OOMD/test.sh b/test/TEST-55-OOMD/test.sh
index 723e80d115..64e2360b08 100755
--- a/test/TEST-55-OOMD/test.sh
+++ b/test/TEST-55-OOMD/test.sh
@@ -5,20 +5,19 @@ set -e
TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"
IMAGE_NAME="oomd"
+# Need to set up swap
+TEST_NO_NSPAWN=1
+
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
- # Create a swap device
+ # Create a swap file
(
- mkswap "${LOOPDEV:?}p2"
- image_install swapon swapoff
-
- inst_binary stress
+ image_install mkswap swapon swapoff stress
- cat >>"${initdir:?}/etc/fstab" <<EOF
-UUID=$(blkid -o value -s UUID "${LOOPDEV}p2") none swap defaults 0 0
-EOF
+ dd if=/dev/zero of="${initdir:?}/swapfile" bs=1M count=48
+ chmod 0600 "${initdir:?}/swapfile"
mkdir -p "${initdir:?}/etc/systemd/system/init.scope.d/"
cat >>"${initdir:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF
diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh
index 85ebb76732..838ba3a6a0 100755
--- a/test/units/testsuite-55.sh
+++ b/test/units/testsuite-55.sh
@@ -24,6 +24,13 @@ 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 <<EOF