summaryrefslogtreecommitdiffstats
path: root/tests/ts/swapon/fixpgsz
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
commit30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch)
tree9b788335f92174baf7ee18f03ca8330b8c19ce2b /tests/ts/swapon/fixpgsz
parentInitial commit. (diff)
downloadutil-linux-upstream.tar.xz
util-linux-upstream.zip
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtests/ts/swapon/fixpgsz49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/ts/swapon/fixpgsz b/tests/ts/swapon/fixpgsz
new file mode 100755
index 0000000..4479cd8
--- /dev/null
+++ b/tests/ts/swapon/fixpgsz
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="fix page size"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_MKSWAP"
+ts_check_test_command "$TS_CMD_SWAPON"
+ts_check_test_command "$TS_CMD_SWAPOFF"
+ts_check_test_command "$TS_HELPER_SYSINFO"
+
+ts_skip_nonroot
+ts_check_losetup
+
+PAGESIZE=$($TS_HELPER_SYSINFO pagesize)
+
+#
+# Create a swap-area with incompatible page size
+#
+[ "$?" == 0 ] || ts_die "Cannot init device"
+
+if [ $(( 64 * 1024 )) -ne $PAGESIZE ]; then
+ BADSIZE=$(( 64 * 1024 ))
+else
+ BADSIZE=4096
+fi
+
+ts_device_init
+DEVICE=$TS_LODEV
+
+$TS_CMD_MKSWAP -L MyFooBarLabel --pagesize $BADSIZE $DEVICE > /dev/null &> /dev/null \
+ || ts_die "Cannot make swap $DEVICE"
+
+ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE"
+
+#
+# Swapon
+#
+$TS_CMD_SWAPON --fixpgsz $DEVICE &> /dev/null
+
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+
+$TS_CMD_SWAPOFF $DEVICE
+
+ts_log "Success"
+ts_finalize
+