]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use btrfs' mkswapfile on btrfs
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 14 Feb 2024 10:48:56 +0000 (11:48 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 17 Feb 2024 11:49:44 +0000 (12:49 +0100)
So it's created automagically with proper attributes.

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

index 64e2360b081a677e2426077f26564e29acb8ad05..9a9cdecf70e72c0e6838ced437657cc7d8cadd8e 100755 (executable)
@@ -15,9 +15,7 @@ test_append_files() {
     # Create a swap file
     (
         image_install mkswap swapon swapoff stress
-
-        dd if=/dev/zero of="${initdir:?}/swapfile" bs=1M count=48
-        chmod 0600 "${initdir:?}/swapfile"
+        image_install -o btrfs
 
         mkdir -p "${initdir:?}/etc/systemd/system/init.scope.d/"
         cat >>"${initdir:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF
index 2b1383ecade9239fa95d027c770be7e699d55b17..b02dd2996093793f250dbc3482f76eee4077d810 100755 (executable)
@@ -23,7 +23,14 @@ 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
+    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