]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add sfdisk resize regression tests for MBR
authorKarel Zak <kzak@redhat.com>
Wed, 22 Apr 2015 15:15:39 +0000 (17:15 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 22 Apr 2015 15:31:40 +0000 (17:31 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
16 files changed:
tests/expected/sfdisk/resize [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-0-move-up-absolute [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-1-move-down-absolute [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-10-down-enlarge [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-11-absolute-move-resize [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-12-reduce-midle [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-13-max-last [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-2-move-up-relative [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-3-move-down-relative [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-4-enlarge-absolute [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-5-reduce-absolute [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-6-enlarge-relative [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-7-reduce-relative [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-8-enlarge-all [new file with mode: 0644]
tests/expected/sfdisk/resize-dos-9-up-preduce [new file with mode: 0644]
tests/ts/sfdisk/resize [new file with mode: 0755]

diff --git a/tests/expected/sfdisk/resize b/tests/expected/sfdisk/resize
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/expected/sfdisk/resize-dos-0-move-up-absolute b/tests/expected/sfdisk/resize-dos-0-move-up-absolute
new file mode 100644 (file)
index 0000000..14d1a76
--- /dev/null
@@ -0,0 +1,25 @@
+3000,
+
+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        3000 23479   20480  10M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-1-move-down-absolute b/tests/expected/sfdisk/resize-dos-1-move-down-absolute
new file mode 100644 (file)
index 0000000..feaa2b2
--- /dev/null
@@ -0,0 +1,25 @@
+2048,
+
+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        3000 23479   20480  10M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1        2048 22527   20480  10M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-10-down-enlarge b/tests/expected/sfdisk/resize-dos-10-down-enlarge
new file mode 100644 (file)
index 0000000..83eb2d8
--- /dev/null
@@ -0,0 +1,25 @@
+-10M,+10M,,*
+
+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       22528 204799  182272  89M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start    End Sectors Size Id Type
+<removed>1  *     2048 204799  202752  99M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-11-absolute-move-resize b/tests/expected/sfdisk/resize-dos-11-absolute-move-resize
new file mode 100644 (file)
index 0000000..eef18a0
--- /dev/null
@@ -0,0 +1,25 @@
+2048,10M,L
+
+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 204799  202752  99M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1  *     2048 22527   20480  10M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-12-reduce-midle b/tests/expected/sfdisk/resize-dos-12-reduce-midle
new file mode 100644 (file)
index 0000000..eaea4eb
--- /dev/null
@@ -0,0 +1,29 @@
+,-5M
+
+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>2       22528 43007   20480  10M 83 Linux
+<removed>3       43008 63487   20480  10M 83 Linux
+
+<removed>2: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1  *     2048 22527   20480  10M 83 Linux
+<removed>2       22528 32767   10240   5M 83 Linux
+<removed>3       43008 63487   20480  10M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-13-max-last b/tests/expected/sfdisk/resize-dos-13-max-last
new file mode 100644 (file)
index 0000000..af514ac
--- /dev/null
@@ -0,0 +1,29 @@
+-5M,+
+
+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>2       22528 32767   10240   5M 83 Linux
+<removed>3       43008 63487   20480  10M 83 Linux
+
+<removed>3: 
+New situation:
+
+Device     Boot Start    End Sectors Size Id Type
+<removed>1  *     2048  22527   20480  10M 83 Linux
+<removed>2       22528  32767   10240   5M 83 Linux
+<removed>3       32768 204799  172032  84M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-2-move-up-relative b/tests/expected/sfdisk/resize-dos-2-move-up-relative
new file mode 100644 (file)
index 0000000..50cc67d
--- /dev/null
@@ -0,0 +1,25 @@
++1M,
+
+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        4096 24575   20480  10M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-3-move-down-relative b/tests/expected/sfdisk/resize-dos-3-move-down-relative
new file mode 100644 (file)
index 0000000..ec51a12
--- /dev/null
@@ -0,0 +1,25 @@
+-1M,
+
+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        4096 24575   20480  10M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1        2048 22527   20480  10M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-4-enlarge-absolute b/tests/expected/sfdisk/resize-dos-4-enlarge-absolute
new file mode 100644 (file)
index 0000000..c3ce8b7
--- /dev/null
@@ -0,0 +1,25 @@
+-,15M
+
+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        2048 32767   30720  15M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-5-reduce-absolute b/tests/expected/sfdisk/resize-dos-5-reduce-absolute
new file mode 100644 (file)
index 0000000..0ee2b07
--- /dev/null
@@ -0,0 +1,25 @@
+,5M,
+
+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 32767   30720  15M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1        2048 12287   10240   5M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-6-enlarge-relative b/tests/expected/sfdisk/resize-dos-6-enlarge-relative
new file mode 100644 (file)
index 0000000..312945d
--- /dev/null
@@ -0,0 +1,25 @@
+, +10M
+
+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 12287   10240   5M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1        2048 32767   30720  15M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-7-reduce-relative b/tests/expected/sfdisk/resize-dos-7-reduce-relative
new file mode 100644 (file)
index 0000000..f01e2a9
--- /dev/null
@@ -0,0 +1,25 @@
+, -10M
+
+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 32767   30720  15M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start   End Sectors Size Id Type
+<removed>1        2048 12287   10240   5M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-8-enlarge-all b/tests/expected/sfdisk/resize-dos-8-enlarge-all
new file mode 100644 (file)
index 0000000..829dfd4
--- /dev/null
@@ -0,0 +1,25 @@
+,+
+
+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 12287   10240   5M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start    End Sectors Size Id Type
+<removed>1        2048 204799  202752  99M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/expected/sfdisk/resize-dos-9-up-preduce b/tests/expected/sfdisk/resize-dos-9-up-preduce
new file mode 100644 (file)
index 0000000..a1119f1
--- /dev/null
@@ -0,0 +1,25 @@
++10M,-10M
+
+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 204799  202752  99M 83 Linux
+
+<removed>1: 
+New situation:
+
+Device     Boot Start    End Sectors Size Id Type
+<removed>1       22528 204799  182272  89M 83 Linux
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
diff --git a/tests/ts/sfdisk/resize b/tests/ts/sfdisk/resize
new file mode 100755 (executable)
index 0000000..7083e40
--- /dev/null
@@ -0,0 +1,124 @@
+#!/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="resize"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SFDISK"
+ts_check_test_command "$TS_CMD_WIPEFS"
+
+ts_skip_nonroot
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=100 sector_size=512
+
+declare -a COMM
+declare -a NAME
+
+COMM[0]="3000,"
+NAME[0]="move-up-absolute"
+
+COMM[1]="2048,"
+NAME[1]="move-down-absolute"
+
+COMM[2]="+1M,"
+NAME[2]="move-up-relative"
+
+COMM[3]="-1M,"
+NAME[3]="move-down-relative"
+
+COMM[4]="-,15M"
+NAME[4]="enlarge-absolute"
+
+COMM[5]=",5M,"
+NAME[5]="reduce-absolute"
+
+COMM[6]=", +10M"
+NAME[6]="enlarge-relative"
+
+NAME[7]="reduce-relative"
+COMM[7]=", -10M"
+
+NAME[8]="enlarge-all"
+COMM[8]=",+"
+
+NAME[9]="up-preduce"
+COMM[9]="+10M,-10M"
+
+NAME[10]="down-enlarge"
+COMM[10]="-10M,+10M,,*"
+
+NAME[11]="absolute-move-resize"
+COMM[11]="2048,10M,L"
+
+function test_label_resize {
+       local label="$1"
+
+       $TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+       udevadm settle
+
+       # create a partition
+       echo ',10M,L' | $TS_CMD_SFDISK --label ${label} ${TS_DEVICE} &> /dev/null
+       udevadm settle
+
+       for idx in $(seq 0 $(( ${#COMM[*]} - 1 ))); do
+
+               cmd=${COMM[$idx]}
+               name=${NAME[$idx]}
+
+               ts_init_subtest "$label-$idx-$name"
+               echo -e "$cmd\n" >> $TS_OUTPUT
+               echo "$cmd" | $TS_CMD_SFDISK -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+               ts_fdisk_clean $TS_DEVICE
+               udevadm settle
+               ts_finalize_subtest
+       done
+
+       echo ',10M,L' | $TS_CMD_SFDISK --append ${TS_DEVICE} &> /dev/null
+       echo ',10M,L' | $TS_CMD_SFDISK --append ${TS_DEVICE} &> /dev/null
+       udevadm settle
+
+       idx=$(( $idx + 1 ))
+       ts_init_subtest "$label-$idx-reduce-midle"
+       cmd=',-5M'
+       echo -e "$cmd\n" >> $TS_OUTPUT
+       echo "$cmd" | $TS_CMD_SFDISK -N2 ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+       ts_fdisk_clean $TS_DEVICE
+       udevadm settle
+       ts_finalize_subtest
+
+       idx=$(( $idx + 1 ))
+       ts_init_subtest "$label-$idx-max-last"
+       cmd='-5M,+'
+       echo -e "$cmd\n" >> $TS_OUTPUT
+       echo $cmd | $TS_CMD_SFDISK -N3 ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+       ts_fdisk_clean $TS_DEVICE
+       udevadm settle
+       ts_finalize_subtest
+}
+
+# MBR
+test_label_resize dos
+
+# GPT
+#test_label_resize gpt
+
+rmmod scsi_debug
+ts_finalize