]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add sfdisk test
authorKarel Zak <kzak@redhat.com>
Tue, 7 Oct 2014 12:54:58 +0000 (14:54 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 7 Oct 2014 12:54:58 +0000 (14:54 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/commands.sh
tests/expected/sfdisk/dos [new file with mode: 0644]
tests/expected/sfdisk/dos-activate [new file with mode: 0644]
tests/expected/sfdisk/dos-read-dump [new file with mode: 0644]
tests/expected/sfdisk/dos-simple-commas [new file with mode: 0644]
tests/expected/sfdisk/dos-simple-space [new file with mode: 0644]
tests/expected/sfdisk/dos-write-dump [new file with mode: 0644]
tests/ts/sfdisk/dos [new file with mode: 0755]

index 0a3062872b2ffe392f0367dbbdc1f6e9b28e8010..4c7455e4ca5f2caf03104d000fce507715c92ce4 100644 (file)
@@ -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 (file)
index 0000000..e69de29
diff --git a/tests/expected/sfdisk/dos-activate b/tests/expected/sfdisk/dos-activate
new file mode 100644 (file)
index 0000000..23be9ee
--- /dev/null
@@ -0,0 +1,11 @@
+
+Disk <removed>: 100 cylinders, 32 heads, 32 sectors/track
+Units: sectors of 512 bytes, counting from 0
+
+   Device Boot    Start       End   #sectors  Id  System
+<removed>1   *      2048      8191       6144  83  Linux
+<removed>2          8192     14335       6144  82  Linux swap / Solaris
+<removed>3         14336     20479       6144  83  Linux
+<removed>4         20480    102399      81920   5  Extended
+<removed>5         20481     26624       6144  83  Linux
+<removed>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 (file)
index 0000000..c463a0e
--- /dev/null
@@ -0,0 +1,26 @@
+sfdisk: Checking that no-one is using this disk right now ...
+sfdisk: OK
+sfdisk:  <removed>: 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 <removed>: 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
+<removed>1   *      2048      8191       6144  83  Linux
+<removed>2          8192     14335       6144  82  Linux swap / Solaris
+<removed>3         14336     20479       6144  83  Linux
+<removed>4         20480    102399      81920   5  Extended
+<removed>5         20481     26624       6144  83  Linux
+<removed>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 (file)
index 0000000..4c41f50
--- /dev/null
@@ -0,0 +1,28 @@
+sfdisk: Checking that no-one is using this disk right now ...
+sfdisk: OK
+sfdisk:  <removed>: 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 <removed>: 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
+<removed>1          2048      8191       6144  83  Linux
+<removed>2          8192     14335       6144  82  Linux swap / Solaris
+<removed>3         14336     20479       6144  83  Linux
+<removed>4         20480    102399      81920   5  Extended
+<removed>5         20481     26624       6144  83  Linux
+<removed>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 (file)
index 0000000..137130f
--- /dev/null
@@ -0,0 +1,24 @@
+sfdisk: Checking that no-one is using this disk right now ...
+sfdisk: OK
+sfdisk:  <removed>: 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 <removed>: 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
+<removed>1          2048      8191       6144  83  Linux
+<removed>2          8192     14335       6144  82  Linux swap / Solaris
+<removed>3             1      2047       2047  83  Linux
+<removed>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 (file)
index 0000000..4d069d2
--- /dev/null
@@ -0,0 +1,9 @@
+# partition table of <removed>
+unit: sectors
+
+<removed>1 : start=     2048, size=     6144, Id=83, bootable
+<removed>2 : start=     8192, size=     6144, Id=82
+<removed>3 : start=    14336, size=     6144, Id=83
+<removed>4 : start=    20480, size=    81920, Id= 5
+<removed>5 : start=    20481, size=     6144, Id=83
+<removed>6 : start=    26626, size=    75774, Id=83
diff --git a/tests/ts/sfdisk/dos b/tests/ts/sfdisk/dos
new file mode 100755 (executable)
index 0000000..26126f0
--- /dev/null
@@ -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 <<EOF
+2048,6144,L
+8192,6144,S
+14336,6144,
+20480,,E
+,6144,
+,,
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "activate"
+$TS_CMD_SFDISK --activate ${TS_DEVICE} 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 <<EOF
+2048,6144,L
+8192,6144,S
+,,
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "read-dump"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
+unit: sectors
+
+${TS_DEVICE}1 : start=     2048, size=     6144, Id=83, bootable
+${TS_DEVICE}2 : start=     8192, size=     6144, Id=82
+${TS_DEVICE}3 : start=    14336, size=     6144, Id=83
+${TS_DEVICE}4 : start=    20480, size=    81920, Id= 5
+${TS_DEVICE}5 : start=    20481, size=     6144, Id=83
+${TS_DEVICE}6 : start=    26626, size=    75774, Id=83
+EOF
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "write-dump"
+$TS_CMD_SFDISK --unit S --dump ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+
+rmmod scsi_debug
+ts_finalize