]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: configure swap for TEST-55-OOMD
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 22 Apr 2021 14:26:25 +0000 (16:26 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Apr 2021 12:36:14 +0000 (14:36 +0200)
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.

test/TEST-55-OOMD/test.sh
test/units/testsuite-55-slowgrowth.sh

index afc6706e32f748b6770f926c57f975d305818fbc..9f7a11aea46bbd2c9390c084694547bd360d2ea4 100755 (executable)
@@ -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
index 68bffad454b53611af052f307ba879b801a22ce5..d1595ad150297a18b8d9d51e6209a7804f7a5686 100755 (executable)
@@ -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
 }