summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKarel Zak2013-03-06 14:01:41 +0100
committerKarel Zak2013-03-06 14:01:41 +0100
commit0385dcf0ad9550e721b9daf01d83e6b14e70e7c2 (patch)
tree82d58ac3abe5f8529f594e7b2c636d0c50e72cf8 /tests
parenttests: update fdisk mbr tests (diff)
downloadkernel-qcow2-util-linux-0385dcf0ad9550e721b9daf01d83e6b14e70e7c2.tar.gz
kernel-qcow2-util-linux-0385dcf0ad9550e721b9daf01d83e6b14e70e7c2.tar.xz
kernel-qcow2-util-linux-0385dcf0ad9550e721b9daf01d83e6b14e70e7c2.zip
tests: add fdisk BSD test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/expected/fdisk/bsd127
-rwxr-xr-xtests/ts/fdisk/bsd106
2 files changed, 233 insertions, 0 deletions
diff --git a/tests/expected/fdisk/bsd b/tests/expected/fdisk/bsd
new file mode 100644
index 000000000..1c35f2723
--- /dev/null
+++ b/tests/expected/fdisk/bsd
@@ -0,0 +1,127 @@
+Initialize empty image
+f1c9645dbc14efddc7d8a322685f26eb bsd.img
+Create new DOS partition table
+57e721e38d1266c2df055067c18f2cf9 bsd.img
+
+---layout----------
+__ts_dev__: 10 MB, 10485760 bytes, 20480 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
+Disk label type: dos
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+-------------------
+
+Create 1st primary partition
+ada64ace122978d00d1d1c0e5ee45d26 bsd.img
+
+---layout----------
+__ts_dev__: 10 MB, 10485760 bytes, 20480 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
+Disk label type: dos
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 4095 1024 83 Linux
+-------------------
+
+Create 2st primary partition
+1bebf87248e05d6e4e62b749da65d023 bsd.img
+Set 2nd partition type
+2d8e8dff51a88a045db233418dd73fbe bsd.img
+
+---layout----------
+__ts_dev__: 10 MB, 10485760 bytes, 20480 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
+Disk label type: dos
+Disk identifier: 0x00000001
+
+ Device Boot Start End Blocks Id System
+__ts_dev__1 2048 4095 1024 83 Linux
+__ts_dev__2 4096 20479 8192 a5 FreeBSD
+-------------------
+
+Create default BSD
+2e1cee529cb59c9341afef0443f196a1 bsd.img
+
+---layout----------
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help):
+
+BSD disklabel command (m for help):
+4 partitions:
+# start end size fstype [fsize bsize cpg]
+ c: 4096 20479 16384 unused 0 0
+ d: 0 16064 16065 unused 0 0
+
+BSD disklabel command (m for help):
+Command (m for help):
+-------------------
+
+b5c121c2091b2ff26b880551feac7112 bsd.img
+
+---layout----------
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help):
+
+BSD disklabel command (m for help):
+4 partitions:
+# start end size fstype [fsize bsize cpg]
+ a: 4096 6144 2049 4.2BSD 0 0 0
+ c: 4096 20479 16384 unused 0 0
+ d: 0 16064 16065 unused 0 0
+
+BSD disklabel command (m for help):
+Command (m for help):
+-------------------
+
+
+
+Changes will remain in memory only, until you decide to write them.
+Be careful before using the write command.
+
+
+Command (m for help):
+
+BSD disklabel command (m for help):
+ 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
+ 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
+ 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
+ 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
+ 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
+ 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
+ 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
+ 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
+ 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
+ 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
+ a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
+ b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
+ c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
+ e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
+ f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
+10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
+11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
+12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
+14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
+16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
+17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
+18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
+1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
+1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
+1e Hidden W95 FAT1 80 Old Minix
+
+BSD disklabel command (m for help): \ No newline at end of file
diff --git a/tests/ts/fdisk/bsd b/tests/ts/fdisk/bsd
new file mode 100755
index 000000000..b9b2a0fea
--- /dev/null
+++ b/tests/ts/fdisk/bsd
@@ -0,0 +1,106 @@
+#!/bin/bash
+#
+# This file is part of util-linux.
+#
+# Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+#
+# 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="nested BSD"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+FDISK_CMD_CREATE_DOSLABEL="o\n" # create dos label
+FDISK_CMD_SETID="x\ni\n0x1\nr\n" # set non-random ID
+FDISK_CMD_WRITE_CLOSE="w\nq\n" # write to image
+FDISK_CMD_CREATE_PRIMARY1="n\np\n1\n\n+1M\n" # 1st primary partition of size 1MiB
+FDISK_CMD_CREATE_PRIMARY2="n\np\n2\n\n\n" # 2nd primary partition for whole of the disk
+FDISK_CMD_CHANGE_PART2TYPE="t\n2\na5\n" # change partition type FreeBSD
+
+FDISK_CMD_BSD_CREATE="b\ny\n" # create nested BSD PT
+FDISK_CMD_BSD_LIST="b\np\nr\nq\n" # list nested BSD PT and quit
+FDISK_CMD_BSD_CREATE_PART="b\nn\na\n\n+1M\n" # add BSD partition 'a', size 1MiB
+FDISK_CMD_BSD_PARTTYPE="b\nt\na\n7\n" # set partition 'a' to type 4.2BSD
+FDISK_CMD_BSD_LIST_TYPES="b\nl\nq\n" # list supported PT types and quit
+
+#set -x
+
+function print_layout {
+ echo -ne "\n---layout----------" >> $TS_OUTPUT
+ $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} | \
+ sed 's/^.*\.img/__ts_dev__/g;
+ s/^[[:blank:]]*Device Boot/ Device Boot/g' >> $TS_OUTPUT 2>&1
+ echo -ne "-------------------\n\n" >> $TS_OUTPUT
+}
+
+function print_bsd_layout {
+ echo -ne "\n---layout----------" >> $TS_OUTPUT
+ echo -e "${FDISK_CMD_BSD_LIST}" | $TS_CMD_FDISK ${TEST_IMAGE_NAME} | \
+ sed 's/Reading .*//g;
+ s/Welcome to fdisk .*//' >> $TS_OUTPUT 2>&1
+ echo -ne "-------------------\n\n" >> $TS_OUTPUT
+}
+
+ts_log "Initialize empty image"
+TEST_IMAGE_NAME=$(ts_image_init 10)
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+ts_log "Create new DOS partition table"
+echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_SETID}${FDISK_CMD_WRITE_CLOSE}" \
+ | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create 1st primary partition"
+echo -e "${FDISK_CMD_CREATE_PRIMARY1}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create 2st primary partition"
+echo -e "${FDISK_CMD_CREATE_PRIMARY2}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+ts_log "Set 2nd partition type"
+echo -e "${FDISK_CMD_CHANGE_PART2TYPE}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_layout
+
+ts_log "Create default BSD"
+echo -e "${FDISK_CMD_BSD_CREATE}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_bsd_layout
+
+echo -e "${FDISK_CMD_BSD_CREATE_PART}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+
+echo -e "${FDISK_CMD_BSD_PARTTYPE}${FDISK_CMD_WRITE_CLOSE}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
+ts_image_md5sum >> $TS_OUTPUT 2>&1
+
+print_bsd_layout
+
+echo -e "${FDISK_CMD_BSD_LIST_TYPES}" | \
+ $TS_CMD_FDISK ${TEST_IMAGE_NAME} | \
+ sed 's/Reading .*//g; s/Welcome to fdisk .*//' >> $TS_OUTPUT 2>&1
+
+ts_finalize