| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# This file is part of util-linux. |
| 5 |
# |
| 6 |
# This file is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; either version 2 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# This file is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU General Public License for more details. |
| 15 |
# |
| 16 |
|
| 17 |
|
| 18 |
TS_TOPDIR="${0%/*}/../.." |
| 19 |
TS_DESC="movedata" |
| 20 |
|
| 21 |
. "$TS_TOPDIR"/functions.sh |
| 22 |
ts_init "$*" |
| 23 |
|
| 24 |
ts_check_test_command "$TS_CMD_SFDISK" |
| 25 |
ts_check_test_command "$TS_HELPER_MD5" |
| 26 |
|
| 27 |
ts_skip_nonroot |
| 28 |
ts_check_prog "mkfs.ext4" |
| 29 |
|
| 30 |
# set global variable TS_DEVICE |
| 31 |
ts_scsi_debug_init dev_size_mb=100 sector_size=512 |
| 32 |
|
| 33 |
# create a partition |
| 34 |
echo ',10M,L' | $TS_CMD_SFDISK --no-reread ${TS_DEVICE} &> /dev/null |
| 35 |
udevadm settle |
| 36 |
|
| 37 |
mkfs.ext4 ${TS_DEVICE}1 &> /dev/null |
| 38 |
udevadm settle |
| 39 |
CHECKSUM=$("$TS_HELPER_MD5" < "${TS_DEVICE}1") |
| 40 |
|
| 41 |
function checksum() { |
| 42 |
local dev="$1" |
| 43 |
CHECK=$("$TS_HELPER_MD5" < "${dev}") |
| 44 |
if [ "$CHECKSUM" != "$CHECK" ]; then |
| 45 |
echo "Checksum does not match!" >> $TS_OUTPUT |
| 46 |
fi |
| 47 |
} |
| 48 |
|
| 49 |
ts_init_subtest "up" |
| 50 |
echo '+1000,' | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 51 |
ts_fdisk_clean $TS_DEVICE |
| 52 |
udevadm settle |
| 53 |
checksum ${TS_DEVICE}1 |
| 54 |
ts_finalize_subtest |
| 55 |
|
| 56 |
udevadm settle |
| 57 |
|
| 58 |
ts_init_subtest "down" |
| 59 |
echo "-500," | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 60 |
ts_fdisk_clean $TS_DEVICE |
| 61 |
udevadm settle |
| 62 |
checksum ${TS_DEVICE}1 |
| 63 |
ts_finalize_subtest |
| 64 |
|
| 65 |
udevadm settle |
| 66 |
|
| 67 |
ts_init_subtest "non-overlay" |
| 68 |
echo "+30M," | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 69 |
ts_fdisk_clean $TS_DEVICE |
| 70 |
udevadm settle |
| 71 |
checksum ${TS_DEVICE}1 |
| 72 |
ts_finalize_subtest |
| 73 |
|
| 74 |
|
| 75 |
ts_finalize |