From: Karel Zak Date: Wed, 9 Sep 2015 12:43:31 +0000 (+0200) Subject: tests: add sfdisk --move-data test X-Git-Tag: v2.28-rc1~350 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=161f399f132a504f3acb273a56a39e2758d88616;p=thirdparty%2Futil-linux.git tests: add sfdisk --move-data test Signed-off-by: Karel Zak --- diff --git a/tests/expected/sfdisk/movedata-down b/tests/expected/sfdisk/movedata-down new file mode 100644 index 0000000000..227cf8cbc3 --- /dev/null +++ b/tests/expected/sfdisk/movedata-down @@ -0,0 +1,27 @@ +Checking that no-one is using this disk right now ... OK + +Disk : 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: + +Old situation: + +Device Boot Start End Sectors Size Id Type +1 3048 23527 20480 10M 83 Linux + +1: +New situation: + +Device Boot Start End Sectors Size Id Type +1 2548 23027 20480 10M 83 Linux + +Data move: + typescript file . + 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 0000000000..6a07831b98 --- /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 : 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: + +Old situation: + +Device Boot Start End Sectors Size Id Type +1 2548 23027 20480 10M 83 Linux + +1: +New situation: + +Device Boot Start End Sectors Size Id Type +1 63988 84467 20480 10M 83 Linux + +Data move: + typescript file . + 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 0000000000..e68d33bf22 --- /dev/null +++ b/tests/expected/sfdisk/movedata-up @@ -0,0 +1,27 @@ +Checking that no-one is using this disk right now ... OK + +Disk : 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: + +Old situation: + +Device Boot Start End Sectors Size Id Type +1 2048 22527 20480 10M 83 Linux + +1: +New situation: + +Device Boot Start End Sectors Size Id Type +1 3048 23527 20480 10M 83 Linux + +Data move: + typescript file . + 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 438ca3a2f9..e84661b0c0 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}::g" $TS_OUTPUT + sed -i -e "s:${DEVNAME}::g;" $TS_OUTPUT fi sed -i -e 's/Disk identifier:.*/Disk identifier: /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 ./g' \ + -e 's/typescript file.*/typescript file ./g' \ $TS_OUTPUT } diff --git a/tests/ts/sfdisk/movedata b/tests/ts/sfdisk/movedata new file mode 100755 index 0000000000..97f3f2bd04 --- /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