summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2014-04-23 09:27:13 +0200
committerKarel Zak <kzak@redhat.com>2014-04-23 11:55:09 +0200
commit7af42d8439ef8bb1034cb6a35fa50e2a0b121851 (patch)
tree88ca01c994ffd7b46392afe48654daf667c1f5cf
parent7125179cb2a4bb52466d37a46e839328fc900212 (diff)
downloadutil-linux-7af42d8439ef8bb1034cb6a35fa50e2a0b121851.tar.gz
tests: add fdisk 'f' command MBR test
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--tests/expected/fdisk/mbr-sort77
-rwxr-xr-xtests/ts/fdisk/mbr-sort79
2 files changed, 156 insertions, 0 deletions
diff --git a/tests/expected/fdisk/mbr-sort b/tests/expected/fdisk/mbr-sort
new file mode 100644
index 000000000..fb897a386
--- /dev/null
+++ b/tests/expected/fdisk/mbr-sort
@@ -0,0 +1,77 @@
+Initialize empty image
+Create new DOS partition table
+
+---layout----------
+Disk <removed>: 20 MiB, 20971520 bytes, 40960 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+
+-------------------
+
+Create primary partitions
+
+---layout----------
+Disk <removed>: 20 MiB, 20971520 bytes, 40960 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 4096 6143 2048 1M 83 Linux
+<removed>2 2048 4095 2048 1M 83 Linux
+<removed>3 6144 8191 2048 1M 83 Linux
+<removed>4 8192 40959 32768 16M 5 Extended
+
+Partition table entries are not in disk order.
+
+-------------------
+
+Create logical partitions
+
+---layout----------
+Disk <removed>: 20 MiB, 20971520 bytes, 40960 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 4096 6143 2048 1M 83 Linux
+<removed>2 2048 4095 2048 1M 83 Linux
+<removed>3 6144 8191 2048 1M 83 Linux
+<removed>4 8192 40959 32768 16M 5 Extended
+<removed>5 14336 16383 2048 1M 83 Linux
+<removed>6 22528 24575 2048 1M 83 Linux
+<removed>7 18432 20479 2048 1M 83 Linux
+<removed>8 10240 12287 2048 1M 83 Linux
+
+Partition table entries are not in disk order.
+
+-------------------
+
+Fix order.
+
+---layout----------
+Disk <removed>: 20 MiB, 20971520 bytes, 40960 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 512 bytes
+I/O size (minimum/optimal): 512 bytes / 512 bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 4095 2048 1M 83 Linux
+<removed>2 4096 6143 2048 1M 83 Linux
+<removed>3 6144 8191 2048 1M 83 Linux
+<removed>4 8192 40959 32768 16M 5 Extended
+<removed>5 10240 12287 2048 1M 83 Linux
+<removed>6 14336 16383 2048 1M 83 Linux
+<removed>7 18432 20479 2048 1M 83 Linux
+<removed>8 22528 24575 2048 1M 83 Linux
+
+-------------------
+
diff --git a/tests/ts/fdisk/mbr-sort b/tests/ts/fdisk/mbr-sort
new file mode 100755
index 000000000..3166d867b
--- /dev/null
+++ b/tests/ts/fdisk/mbr-sort
@@ -0,0 +1,79 @@
+#!/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="MBR - sort"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+
+# cmd to changes system id to 0x1
+FDISK_CMD_WRITE_CLOSE="w\nq\n"
+FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label
+
+FDISK_CMD_CREATE_1PRIMARY="n\np\n1\n4096\n6143\n"
+FDISK_CMD_CREATE_2PRIMARY="n\np\n2\n2048\n4095\n"
+FDISK_CMD_CREATE_3PRIMARY="n\np\n3\n6144\n8191\n"
+FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n"
+
+FDISK_CMD_CREATE_1LOGICAL="n\n14336\n16383\n"
+FDISK_CMD_CREATE_2LOGICAL="n\n22528\n24575\n"
+FDISK_CMD_CREATE_3LOGICAL="n\n18432\n20479\n"
+FDISK_CMD_CREATE_4LOGICAL="n\n10240\n12287\n"
+
+FDISK_CMD_EXPERT_SORT="x\nf\nr\n"
+
+function print_layout {
+ echo -ne "\n---layout----------" >> $TS_OUTPUT
+ $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} >> $TS_OUTPUT
+ echo -ne "-------------------\n\n" >> $TS_OUTPUT
+}
+
+#set -x
+
+ts_log "Initialize empty image"
+TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB
+
+ts_log "Create new DOS partition table"
+echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+
+print_layout
+
+ts_log "Create primary partitions"
+echo -e "${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_CREATE_3PRIMARY}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+
+print_layout
+
+
+ts_log "Create logical partitions"
+echo -e "${FDISK_CMD_CREATE_1LOGICAL}${FDISK_CMD_CREATE_2LOGICAL}${FDISK_CMD_CREATE_3LOGICAL}${FDISK_CMD_CREATE_4LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+
+print_layout
+
+
+ts_log "Fix order."
+echo -e "${FDISK_CMD_EXPERT_SORT}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+
+print_layout
+
+ts_fdisk_clean ${TEST_IMAGE_NAME}
+ts_finalize