summaryrefslogtreecommitdiffstats
path: root/tests/ts/swapon/fixsig
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:30:35 +0000
commit378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch)
tree44dfb6ca500d32cabd450649b322a42e70a30683 /tests/ts/swapon/fixsig
parentInitial commit. (diff)
downloadutil-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.tar.xz
util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.zip
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/swapon/fixsig')
-rwxr-xr-xtests/ts/swapon/fixsig53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/ts/swapon/fixsig b/tests/ts/swapon/fixsig
new file mode 100755
index 0000000..c3104a2
--- /dev/null
+++ b/tests/ts/swapon/fixsig
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="fix signature"
+
+. $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
+#
+ts_device_init
+DEVICE=$TS_LODEV
+
+$TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \
+ || ts_die "Cannot make swap $DEVICE"
+
+ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE"
+
+#
+# Rewrite signature to swsuspend
+#
+echo "S2SUSPEND " > $TS_OUTPUT.signature
+dd if=$TS_OUTPUT.signature of=$DEVICE \
+ seek=$(( $PAGESIZE - 10 )) count=10 bs=1 conv=notrunc &> /dev/null
+
+ts_device_has "TYPE" "swsuspend" $DEVICE || ts_die "Cannot find swsuspend on $DEVICE"
+
+#
+# Swapon
+#
+$TS_CMD_SWAPON $DEVICE &> /dev/null
+
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+
+$TS_CMD_SWAPOFF $DEVICE
+
+# swapon/mkswap warns if system sets different permissions for loop devices
+sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT
+
+ts_log "Success"
+ts_finalize
+