summaryrefslogblamecommitdiffstats
path: root/tests/ts/swapon/fixsig
blob: a4d04110c0ad9f77b13ec634633be805200133f8 (plain) (tree)
1
2
3
4
5
6
7

           
                         



                         




                                       




























                                                                                             
                                   


                                                                                  
                       




                        
#!/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_skip_nonroot

set -o pipefail

PAGESIZE=$($TS_HELPER_SYSINFO pagesize)

#
# Create a swap-area
#
DEVICE=$(ts_device_init)
[ "$?" == 0 ] || ts_die "Cannot init device"

$TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \
 || ts_die "Cannot make swap $DEVICE" $DEVICE

ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" $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" $DEVICE

#
# Swapon
#
$TS_CMD_SWAPON $DEVICE &> /dev/null

grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE

$TS_CMD_SWAPOFF $DEVICE
ts_device_deinit $DEVICE

ts_log "Success"
ts_finalize