diff options
-rw-r--r-- | tests/expected/sfdisk/movedata-down | 27 | ||||
-rw-r--r-- | tests/expected/sfdisk/movedata-non-overlay | 27 | ||||
-rw-r--r-- | tests/expected/sfdisk/movedata-up | 27 | ||||
-rw-r--r-- | tests/functions.sh | 3 | ||||
-rwxr-xr-x | tests/ts/sfdisk/movedata | 74 |
5 files changed, 157 insertions, 1 deletions
diff --git a/tests/expected/sfdisk/movedata-down b/tests/expected/sfdisk/movedata-down new file mode 100644 index 000000000..227cf8cbc --- /dev/null +++ b/tests/expected/sfdisk/movedata-down @@ -0,0 +1,27 @@ +Checking that no-one is using this disk right now ... OK + +Disk <removed>: 100 MiB, 104857600 bytes, 204800 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 32768 bytes +Disklabel type: dos +Disk identifier: <removed> + +Old situation: + +Device Boot Start End Sectors Size Id Type +<removed>1 3048 23527 20480 10M 83 Linux + +<removed>1: +New situation: + +Device Boot Start End Sectors Size Id Type +<removed>1 2548 23027 20480 10M 83 Linux + +Data move: + typescript file <removed>. + old start: 3048, new start: 2548 (move 20480 sectors) + +The partition table has been altered. +Calling ioctl() to re-read partition table. +Syncing disks. diff --git a/tests/expected/sfdisk/movedata-non-overlay b/tests/expected/sfdisk/movedata-non-overlay new file mode 100644 index 000000000..6a07831b9 --- /dev/null +++ b/tests/expected/sfdisk/movedata-non-overlay @@ -0,0 +1,27 @@ +Checking that no-one is using this disk right now ... OK + +Disk <removed>: 100 MiB, 104857600 bytes, 204800 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 32768 bytes +Disklabel type: dos +Disk identifier: <removed> + +Old situation: + +Device Boot Start End Sectors Size Id Type +<removed>1 2548 23027 20480 10M 83 Linux + +<removed>1: +New situation: + +Device Boot Start End Sectors Size Id Type +<removed>1 63988 84467 20480 10M 83 Linux + +Data move: + typescript file <removed>. + old start: 2548, new start: 63988 (move 20480 sectors) + +The partition table has been altered. +Calling ioctl() to re-read partition table. +Syncing disks. diff --git a/tests/expected/sfdisk/movedata-up b/tests/expected/sfdisk/movedata-up new file mode 100644 index 000000000..e68d33bf2 --- /dev/null +++ b/tests/expected/sfdisk/movedata-up @@ -0,0 +1,27 @@ +Checking that no-one is using this disk right now ... OK + +Disk <removed>: 100 MiB, 104857600 bytes, 204800 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 32768 bytes +Disklabel type: dos +Disk identifier: <removed> + +Old situation: + +Device Boot Start End Sectors Size Id Type +<removed>1 2048 22527 20480 10M 83 Linux + +<removed>1: +New situation: + +Device Boot Start End Sectors Size Id Type +<removed>1 3048 23527 20480 10M 83 Linux + +Data move: + typescript file <removed>. + old start: 2048, new start: 3048 (move 20480 sectors) + +The partition table has been altered. +Calling ioctl() to re-read partition table. +Syncing disks. diff --git a/tests/functions.sh b/tests/functions.sh index 438ca3a2f..e84661b0c 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -609,7 +609,7 @@ function ts_fdisk_clean { # remove non comparable parts of fdisk output if [ x"${DEVNAME}" != x"" ]; then - sed -i -e "s:${DEVNAME}:<removed>:g" $TS_OUTPUT + sed -i -e "s:${DEVNAME}:<removed>:g;" $TS_OUTPUT fi sed -i -e 's/Disk identifier:.*/Disk identifier: <removed>/g' \ @@ -618,6 +618,7 @@ function ts_fdisk_clean { -e 's/^Device[[:blank:]]*Boot/Device Boot/g' \ -e 's/^Device[[:blank:]]*Flag/Device Flag/g' \ -e 's/Welcome to fdisk.*/Welcome to fdisk <removed>./g' \ + -e 's/typescript file.*/typescript file <removed>./g' \ $TS_OUTPUT } diff --git a/tests/ts/sfdisk/movedata b/tests/ts/sfdisk/movedata new file mode 100755 index 000000000..97f3f2bd0 --- /dev/null +++ b/tests/ts/sfdisk/movedata @@ -0,0 +1,74 @@ +#!/bin/bash + +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="movedata" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 sector_size=512 + +# create a partition +echo ',10M,L' | $TS_CMD_SFDISK ${TS_DEVICE} &> /dev/null +udevadm settle + +mkfs.ext4 ${TS_DEVICE}1 &> /dev/null +udevadm settle +CHECKSUM=$(md5sum ${TS_DEVICE}1 | awk '{print $1}') + +function checksum() { + local dev="$1" + CHECK=$(md5sum ${dev} | awk '{print $1}') + if [ "$CHECKSUM" != "$CHECK" ]; then + echo "Checksum does not match!" >> $TS_OUTPUT + fi +} + +ts_init_subtest "up" +echo '+1000,' | $TS_CMD_SFDISK --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>&1 +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "down" +echo "-500," | $TS_CMD_SFDISK --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>&1 +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "non-overlay" +echo "+30M," | $TS_CMD_SFDISK --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>&1 +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + + +rmmod scsi_debug +ts_finalize |