summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2021-04-22 16:26:25 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-23 14:36:14 +0200
commit6f47e45c67ad6a6b1a86ad631cd985c7301fed61 (patch)
tree3c335322a037ac1ab1c59f0e6a14439abe873ad1 /test
parent3a1e9d8083b83f611a23cc84ba69a8175e659629 (diff)
downloadsystemd-6f47e45c67ad6a6b1a86ad631cd985c7301fed61.tar.gz
test: configure swap for TEST-55-OOMD
oomd works way better with swap, so let's make the test less flaky by configuring a swap device for it. This also allows us to drop the ugly `cat`s from the load-generating script.
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-55-OOMD/test.sh13
-rwxr-xr-xtest/units/testsuite-55-slowgrowth.sh6
2 files changed, 15 insertions, 4 deletions
diff --git a/test/TEST-55-OOMD/test.sh b/test/TEST-55-OOMD/test.sh
index afc6706e32..9f7a11aea4 100755
--- a/test/TEST-55-OOMD/test.sh
+++ b/test/TEST-55-OOMD/test.sh
@@ -2,10 +2,23 @@
set -e
TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"
+IMAGE_NAME="oomd"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
+test_append_files() {
+ # Create a swap device
+ (
+ mkswap "${LOOPDEV:?}p2"
+ dracut_install swapon swapoff
+
+ cat >>"${initdir:?}/etc/fstab" <<EOF
+UUID=$(blkid -o value -s UUID "${LOOPDEV}p2") none swap defaults 0 0
+EOF
+ )
+}
+
check_result_nspawn() {
local workspace="${1:?}"
local ret=1
diff --git a/test/units/testsuite-55-slowgrowth.sh b/test/units/testsuite-55-slowgrowth.sh
index 68bffad454..d1595ad150 100755
--- a/test/units/testsuite-55-slowgrowth.sh
+++ b/test/units/testsuite-55-slowgrowth.sh
@@ -12,9 +12,7 @@ PID="$$"
function bloat {
local set_size mem_usage target_mem_size
- # Following `| cat` weirdness is intentional to generate some reclaim
- # activity in case there's no swap available.
- set_size=$(cut -d " " -f2 "/proc/$PID/statm" | cat)
+ set_size=$(cut -d " " -f2 "/proc/$PID/statm")
mem_usage=$((set_size * PAGE_SIZE))
target_mem_size=$((mem_usage + $1))
@@ -23,7 +21,7 @@ function bloat {
echo "target $target_mem_size"
echo "mem usage $mem_usage"
BLOAT_HOLDER+=("$(printf "=%0.s" {1..1000000})")
- set_size=$(cut -d " " -f2 "/proc/$PID/statm" | cat)
+ set_size=$(cut -d " " -f2 "/proc/$PID/statm")
mem_usage=$((set_size * PAGE_SIZE))
done
}