]> err.no Git - util-linux/commitdiff
fdisk: add simple test for doslabel stuff
authorZdenek Behan <rain@matfyz.cz>
Tue, 19 May 2009 14:19:32 +0000 (16:19 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 19 May 2009 14:19:32 +0000 (16:19 +0200)
Initial tests/fdisk patch to test most of the doslabel-related stuff.
Coverage of dos-related functions is about 60%, does not test the
verify/fix-PT code.

[kzak@redhat.com: - fix test design to match to
                    output/expect/diff idea]

Signed-off-by: Zdenek Behan <rain@matfyz.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/commands.sh.in
tests/expected/fdisk/doslabel [new file with mode: 0644]
tests/ts/fdisk/doslabel [new file with mode: 0755]

index c6a5e26bd9f7003ccdf7aa4c1a6c7513a183199e..3dc4192ee14a68f7edf49256c0ed77642b46acc6 100644 (file)
@@ -47,4 +47,4 @@ TS_CMD_LSCPU=${TS_CMD_LSCPU-"$TOPDIR/sys-utils/lscpu"}
 
 TS_CMD_BLKID=${TS_CMD_BLKID-"$TOPDIR/shlibs/blkid/bin/blkid"}
 
-
+TS_CMD_FDISK=${TS_CMD_FDISK-"$TOPDIR/fdisk/fdisk"}
diff --git a/tests/expected/fdisk/doslabel b/tests/expected/fdisk/doslabel
new file mode 100644 (file)
index 0000000..45dc28f
--- /dev/null
@@ -0,0 +1,18 @@
+Initialize empty image
+f1c9645dbc14efddc7d8a322685f26eb doslabel.img
+Create new DOS partition table
+57e721e38d1266c2df055067c18f2cf9 doslabel.img
+Create primary partition
+ae4f9b12f4a768849f72ea36938c30c7 doslabel.img
+Create extended partition
+76987a00b353687cd1dba3ddea9d66f9 doslabel.img
+Create logical partitions
+a1cd6708e4a6d2e5f6bc9d5c0da0cf3b doslabel.img
+Delete logical partitions
+4c6937d529ace5661fb82efb9394154a doslabel.img
+Create another logical partition
+9589eaaed698d2402945ab3e513c1eb4 doslabel.img
+Delete primary partition
+1e6d646e5df66a2664cfbbb13fa9a08a doslabel.img
+Delete extended partition
+16a9e8009ee95d2e2341e6657acee4c2 doslabel.img
diff --git a/tests/ts/fdisk/doslabel b/tests/ts/fdisk/doslabel
new file mode 100755 (executable)
index 0000000..a7ea576
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+#
+# This file is part of util-linux-ng.
+#
+# 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="$(dirname $0)/../.."
+TS_DESC="doslabel tests"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+# cmd to change number of cylinders to 1024 and changes system id to 0x1
+FDISK_CMD_INIT='x\nc\n1024\ni\n0x1\nr\n'
+FDISK_CMD_WRITE_CLOSE='w\nq\n'
+FDISK_CMD_CREATE_DOSLABEL='o\n' #create dos label
+FDISK_CMD_CREATE_PRIMARY='n\np\n1\n\n+1M\n' # create primary partition 1 of size 1MB
+FDISK_CMD_CREATE_EXTENDED='n\ne\n2\n\n+10\n' # create extended partition 2 of size 11 cylinders
+FDISK_CMD_CREATE_LOGICAL='n\nl\n\n+1\n' # create next logical partition of size 2 cyl
+FDISK_CMD_DELETE_LOGICALS='d\n6\nd\n5\nd\n6\d5\n' # delete middle, head, tail, last partitions
+FDISK_CMD_DELETE_PRIMARY='d\n1\n' # delete first primary
+FDISK_CMD_DELETE_EXTENDED='d\n2\n' # delete second primary
+
+#set -x 
+
+ts_log "Initialize empty image"
+TEST_IMAGE_NAME=$(ts_image_init 10)
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+# need to run init twice, to change system ID after new label, otherwise system
+# ID will be random and will screw up md5's
+ts_log "Create new DOS partition table"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_INIT}${FDISK_CMD_WRITE_CLOSE}" \
+        | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_log "Create primary partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_log "Create extended partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" | \
+       $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_log "Create logical partitions"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \
+       | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_log "Delete logical partitions"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_LOGICALS}${FDISK_CMD_WRITE_CLOSE}" \
+       | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_log "Create another logical partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \
+       | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum  2>&1 >> $TS_OUTPUT
+
+ts_log "Delete primary partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \
+       | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_log "Delete extended partition"
+echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \
+       | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum 2>&1 >> $TS_OUTPUT
+
+ts_finalize