summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/expected/sfdisk/wipe-fs-to-dos31
-rw-r--r--tests/expected/sfdisk/wipe-gpt-to-dos51
-rw-r--r--tests/expected/sfdisk/wipe-gpt-to-dos-auto58
-rw-r--r--tests/expected/sfdisk/wipe-partition52
-rw-r--r--tests/functions.sh10
-rwxr-xr-xtests/ts/sfdisk/wipe101
6 files changed, 303 insertions, 0 deletions
diff --git a/tests/expected/sfdisk/wipe-fs-to-dos b/tests/expected/sfdisk/wipe-fs-to-dos
new file mode 100644
index 000000000..ca1184ca8
--- /dev/null
+++ b/tests/expected/sfdisk/wipe-fs-to-dos
@@ -0,0 +1,31 @@
+
+=====Create FS================================
+
+=====Create DOS================================
+
+
+The old swap signature will be removed by a write command.
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+
+>>> Created a new <removed>.
+The old swap signature will be removed by a write command.
+<removed>1: Created a new <removed>.
+<removed>2: Done.
+
+New situation:
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 102399 100352 49M 83 Linux
+
+The partition table has been altered.
+
+=====Check content================================
+offset type
+----------------------------------------------------------------
+0x1fe dos [partition table]
+
diff --git a/tests/expected/sfdisk/wipe-gpt-to-dos b/tests/expected/sfdisk/wipe-gpt-to-dos
new file mode 100644
index 000000000..3831671b3
--- /dev/null
+++ b/tests/expected/sfdisk/wipe-gpt-to-dos
@@ -0,0 +1,51 @@
+
+=====Create GPT================================
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+<removed>2: Done.
+
+New situation:
+Disklabel type: gpt
+Disk identifier: <removed>
+
+Device Start End Sectors Size Type
+<removed>1 2048 102366 100319 49M Linux filesystem
+
+The partition table has been altered.
+
+=====Create DOS================================
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+Disklabel type: gpt
+Disk identifier: <removed>
+
+Old situation:
+
+Device Start End Sectors Size Type
+<removed>1 2048 102366 100319 49M Linux filesystem
+
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+<removed>2: Done.
+
+New situation:
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 102399 100352 49M 83 Linux
+
+The partition table has been altered.
+
+=====Check content================================
+offset type
+----------------------------------------------------------------
+0x1fe dos [partition table]
+
diff --git a/tests/expected/sfdisk/wipe-gpt-to-dos-auto b/tests/expected/sfdisk/wipe-gpt-to-dos-auto
new file mode 100644
index 000000000..347a3efc2
--- /dev/null
+++ b/tests/expected/sfdisk/wipe-gpt-to-dos-auto
@@ -0,0 +1,58 @@
+
+=====Create GPT================================
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+Disklabel type: dos
+Disk identifier: <removed>
+
+Old situation:
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 102399 100352 49M 83 Linux
+
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+<removed>2: Done.
+
+New situation:
+Disklabel type: gpt
+Disk identifier: <removed>
+
+Device Start End Sectors Size Type
+<removed>1 2048 102366 100319 49M Linux filesystem
+
+The partition table has been altered.
+
+=====Create DOS================================
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+Disklabel type: gpt
+Disk identifier: <removed>
+
+Old situation:
+
+Device Start End Sectors Size Type
+<removed>1 2048 102366 100319 49M Linux filesystem
+
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+<removed>2: Done.
+
+New situation:
+Disklabel type: dos
+Disk identifier: <removed>
+
+Device Boot Start End Sectors Size Id Type
+<removed>1 2048 102399 100352 49M 83 Linux
+
+The partition table has been altered.
+
+=====Check content================================
+offset type
+----------------------------------------------------------------
+0x1fe dos [partition table]
+
diff --git a/tests/expected/sfdisk/wipe-partition b/tests/expected/sfdisk/wipe-partition
new file mode 100644
index 000000000..f447c585e
--- /dev/null
+++ b/tests/expected/sfdisk/wipe-partition
@@ -0,0 +1,52 @@
+
+=====Create GPT================================
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+<removed>2: Done.
+
+New situation:
+Disklabel type: gpt
+Disk identifier: <removed>
+
+Device Start End Sectors Size Type
+<removed>1 2048 102366 100319 49M Linux filesystem
+
+The partition table has been altered.
+
+=====Create FS in partition================================
+
+=====Wipe whole-disk device================================
+
+=====Create GPT (again)================================
+Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
+Units: sectors of 1 * 512 = 512 bytes
+Sector size (logical/physical): 512 bytes / 4096 bytes
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
+
+>>> Created a new <removed>.
+<removed>1: Created a new <removed>.
+Partition #1 contains a ext4 signature.
+The signature will be removed by a write command.
+<removed>2: Done.
+
+New situation:
+Disklabel type: gpt
+Disk identifier: <removed>
+
+Device Start End Sectors Size Type
+<removed>1 2048 102366 100319 49M Linux filesystem
+
+The partition table has been altered.
+
+=====Check content (disk)================================
+offset type
+----------------------------------------------------------------
+0x200 gpt [partition table]
+
+
+=====Check content (partition)================================
diff --git a/tests/functions.sh b/tests/functions.sh
index 9239ab4f6..34d966a6e 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -45,6 +45,16 @@ function ts_cd {
fi
}
+function ts_separator {
+ local header="$1"
+ echo >> $TS_OUTPUT
+ if [ -z "$header" ]; then
+ echo "============================================" >> $TS_OUTPUT
+ else
+ echo "=====$header================================" >> $TS_OUTPUT
+ fi
+}
+
function ts_report {
local desc=
diff --git a/tests/ts/sfdisk/wipe b/tests/ts/sfdisk/wipe
new file mode 100755
index 000000000..3739e81e9
--- /dev/null
+++ b/tests/ts/sfdisk/wipe
@@ -0,0 +1,101 @@
+#!/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="wipe"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SFDISK"
+ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_test_command "$TS_CMD_MKSWAP"
+ts_check_prog "mkfs.ext4"
+
+ts_skip_nonroot
+
+SFDISK_OPTS="--no-tell-kernel --no-reread"
+
+# set global variable TS_DEVICE
+ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3
+
+
+ts_init_subtest "gpt-to-dos"
+ts_separator "Create GPT"
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+udevadm settle
+ts_separator "Create DOS"
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --wipe=always --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_separator "Check content"
+$TS_CMD_WIPEFS ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+# Same as previous test, but without --wipe=always, sfdisk has to wipe
+# the device automatically when switch from one PT to another PT
+#
+ts_init_subtest "gpt-to-dos-auto"
+ts_separator "Create GPT"
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+udevadm settle
+ts_separator "Create DOS"
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_separator "Check content"
+$TS_CMD_WIPEFS ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+
+ts_init_subtest "fs-to-dos"
+ts_separator "Create FS"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+$TS_CMD_MKSWAP ${TS_DEVICE} &> /dev/null
+udevadm settle
+ts_separator "Create DOS"
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --wipe=always --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_fdisk_clean $TS_DEVICE
+ts_separator "Check content"
+$TS_CMD_WIPEFS ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "partition"
+ts_separator "Create GPT"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+udevadm settle
+ts_separator "Create FS in partition"
+mkfs.ext4 ${TS_DEVICE}1 &> /dev/null
+udevadm settle
+ts_separator "Wipe whole-disk device"
+$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
+udevadm settle
+ts_separator "Create GPT (again)"
+echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --wipe-partition=always --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_separator "Check content (disk)"
+$TS_CMD_WIPEFS ${TS_DEVICE} >> $TS_OUTPUT 2>&1
+ts_separator "Check content (partition)"
+$TS_CMD_WIPEFS ${TS_DEVICE}1 >> $TS_OUTPUT 2>&1
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+ts_finalize