From: Karel Zak Date: Tue, 7 Oct 2014 12:54:58 +0000 (+0200) Subject: tests: add sfdisk test X-Git-Tag: v2.26-rc1~410 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f176957297578382b825ed8636342d4a10b9389;p=thirdparty%2Futil-linux.git tests: add sfdisk test Signed-off-by: Karel Zak --- diff --git a/tests/commands.sh b/tests/commands.sh index 0a3062872b..4c7455e4ca 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -38,6 +38,7 @@ TS_CMD_DMESG=${TS_CMD_DMESG-"$top_builddir/dmesg"} TS_CMD_EJECT=${TS_CMD_EJECT-"$top_builddir/eject"} TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"$top_builddir/fallocate"} TS_CMD_FDISK=${TS_CMD_FDISK-"$top_builddir/fdisk"} +TS_CMD_SFDISK=${TS_CMD_SFDISK-"$top_builddir/sfdisk"} TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"$top_builddir/findmnt"} TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"$top_builddir/fsck.cramfs"} TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"$top_builddir/fsck.minix"} diff --git a/tests/expected/sfdisk/dos b/tests/expected/sfdisk/dos new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/sfdisk/dos-activate b/tests/expected/sfdisk/dos-activate new file mode 100644 index 0000000000..23be9ee6aa --- /dev/null +++ b/tests/expected/sfdisk/dos-activate @@ -0,0 +1,11 @@ + +Disk : 100 cylinders, 32 heads, 32 sectors/track +Units: sectors of 512 bytes, counting from 0 + + Device Boot Start End #sectors Id System +1 * 2048 8191 6144 83 Linux +2 8192 14335 6144 82 Linux swap / Solaris +3 14336 20479 6144 83 Linux +4 20480 102399 81920 5 Extended +5 20481 26624 6144 83 Linux +6 26626 102399 75774 83 Linux diff --git a/tests/expected/sfdisk/dos-read-dump b/tests/expected/sfdisk/dos-read-dump new file mode 100644 index 0000000000..c463a0e47f --- /dev/null +++ b/tests/expected/sfdisk/dos-read-dump @@ -0,0 +1,26 @@ +sfdisk: Checking that no-one is using this disk right now ... +sfdisk: OK +sfdisk: : unrecognized partition table type +sfdisk: No partitions found +sfdisk: Warning: partition 5 does not end at a cylinder boundary +sfdisk: Warning: partition [6] does not start at a cylinder boundary + +Disk : 100 cylinders, 32 heads, 32 sectors/track +Old situation: +New situation: +Units: sectors of 512 bytes, counting from 0 + + Device Boot Start End #sectors Id System +1 * 2048 8191 6144 83 Linux +2 8192 14335 6144 82 Linux swap / Solaris +3 14336 20479 6144 83 Linux +4 20480 102399 81920 5 Extended +5 20481 26624 6144 83 Linux +6 26626 102399 75774 83 Linux +Successfully wrote the new partition table + +sfdisk: If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) +to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 +(See fdisk(8).) +Re-reading the partition table ... + diff --git a/tests/expected/sfdisk/dos-simple-commas b/tests/expected/sfdisk/dos-simple-commas new file mode 100644 index 0000000000..4c41f50f30 --- /dev/null +++ b/tests/expected/sfdisk/dos-simple-commas @@ -0,0 +1,28 @@ +sfdisk: Checking that no-one is using this disk right now ... +sfdisk: OK +sfdisk: : unrecognized partition table type +sfdisk: No partitions found +sfdisk: Warning: partition 5 does not end at a cylinder boundary +sfdisk: Warning: partition [6] does not start at a cylinder boundary +sfdisk: Warning: no primary partition is marked bootable (active) +This does not matter for LILO, but the DOS MBR will not boot this disk. + +Disk : 100 cylinders, 32 heads, 32 sectors/track +Old situation: +New situation: +Units: sectors of 512 bytes, counting from 0 + + Device Boot Start End #sectors Id System +1 2048 8191 6144 83 Linux +2 8192 14335 6144 82 Linux swap / Solaris +3 14336 20479 6144 83 Linux +4 20480 102399 81920 5 Extended +5 20481 26624 6144 83 Linux +6 26626 102399 75774 83 Linux +Successfully wrote the new partition table + +sfdisk: If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) +to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 +(See fdisk(8).) +Re-reading the partition table ... + diff --git a/tests/expected/sfdisk/dos-simple-space b/tests/expected/sfdisk/dos-simple-space new file mode 100644 index 0000000000..137130f054 --- /dev/null +++ b/tests/expected/sfdisk/dos-simple-space @@ -0,0 +1,24 @@ +sfdisk: Checking that no-one is using this disk right now ... +sfdisk: OK +sfdisk: : unrecognized partition table type +sfdisk: No partitions found +sfdisk: Warning: no primary partition is marked bootable (active) +This does not matter for LILO, but the DOS MBR will not boot this disk. + +Disk : 100 cylinders, 32 heads, 32 sectors/track +Old situation: +New situation: +Units: sectors of 512 bytes, counting from 0 + + Device Boot Start End #sectors Id System +1 2048 8191 6144 83 Linux +2 8192 14335 6144 82 Linux swap / Solaris +3 1 2047 2047 83 Linux +4 0 - 0 0 Empty +Successfully wrote the new partition table + +sfdisk: If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) +to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 +(See fdisk(8).) +Re-reading the partition table ... + diff --git a/tests/expected/sfdisk/dos-write-dump b/tests/expected/sfdisk/dos-write-dump new file mode 100644 index 0000000000..4d069d21f5 --- /dev/null +++ b/tests/expected/sfdisk/dos-write-dump @@ -0,0 +1,9 @@ +# partition table of +unit: sectors + +1 : start= 2048, size= 6144, Id=83, bootable +2 : start= 8192, size= 6144, Id=82 +3 : start= 14336, size= 6144, Id=83 +4 : start= 20480, size= 81920, Id= 5 +5 : start= 20481, size= 6144, Id=83 +6 : start= 26626, size= 75774, Id=83 diff --git a/tests/ts/sfdisk/dos b/tests/ts/sfdisk/dos new file mode 100755 index 0000000000..26126f0582 --- /dev/null +++ b/tests/ts/sfdisk/dos @@ -0,0 +1,90 @@ +#!/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" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 + + +ts_init_subtest "simple-commas" +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>&1 <> $TS_OUTPUT 2>&1 +$TS_CMD_SFDISK --unit S --list ${TS_DEVICE} >> $TS_OUTPUT 2>&1 +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "simple-space" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>&1 < /dev/null +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>&1 <> $TS_OUTPUT 2>&1 +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +rmmod scsi_debug +ts_finalize