diff options
Diffstat (limited to '')
-rwxr-xr-x | tests/ts/sfdisk/dos | 263 | ||||
-rwxr-xr-x | tests/ts/sfdisk/dump | 87 | ||||
-rw-r--r-- | tests/ts/sfdisk/files/dump-gaps | 7 | ||||
-rw-r--r-- | tests/ts/sfdisk/files/dump-old | 7 | ||||
-rwxr-xr-x | tests/ts/sfdisk/gpt | 206 | ||||
-rwxr-xr-x | tests/ts/sfdisk/movedata | 75 | ||||
-rwxr-xr-x | tests/ts/sfdisk/resize | 154 | ||||
-rwxr-xr-x | tests/ts/sfdisk/script | 157 | ||||
-rwxr-xr-x | tests/ts/sfdisk/wipe | 104 |
9 files changed, 1060 insertions, 0 deletions
diff --git a/tests/ts/sfdisk/dos b/tests/ts/sfdisk/dos new file mode 100755 index 0000000..a2fd728 --- /dev/null +++ b/tests/ts/sfdisk/dos @@ -0,0 +1,263 @@ +#!/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_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +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>> $TS_ERRLOG <<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>> $TS_ERRLOG +$TS_CMD_SFDISK --unit S --list ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "simple-space" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF + 2048 6144 L +8192 6144 S +,, +EOF +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "read-dump-case" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label-id: 0x1ddc8a79 + +${TS_DEVICE}1 : stArt= 2048, sIZe= 6144, id=83, bootAble +EOF +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "read-dump" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label-id: 0x1ddc8a79 + +${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>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "write-json" +$TS_CMD_SFDISK --json ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +# +# Test first LBA smaller than libfdisk default (~1MiB) and small gaps between +# logical partitions (just only one sector for EBR). +# +ts_init_subtest "explicit-size" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: dos +1, 1000, L +1001, 1000, S +2001, 1000 +3001,,E +3002,1000,L +4003,1000,L +5004,,L +EOF +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "resize" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <<EOF +label: dos +,10M,S,* +EOF +udevadm settle +echo ',+' | $TS_CMD_SFDISK --no-reread -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "resize-empty-extended" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <<EOF +label: dos +,1M +,2M,E +EOF +udevadm settle +echo ',+' | $TS_CMD_SFDISK --no-reread -N2 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "reduce-empty-extended" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <<EOF +label: dos +,1M +,5M,E +EOF +udevadm settle +echo ',-2M' | $TS_CMD_SFDISK --no-reread -N2 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + +ts_init_subtest "resize-extended" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <<EOF +label: dos +,1M +,1M +,1M +,5M,E +,1M +,1M +EOF +udevadm settle +echo ',+' | $TS_CMD_SFDISK --no-reread -N4 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "resize-logical" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <<EOF +label: dos +,1M +,1M +,1M +,10M,E +,1M +,1M +EOF +udevadm settle +echo ',+' | $TS_CMD_SFDISK --no-reread -N6 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "dump-old" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} < $TS_SELF/files/dump-old >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "dump-gaps" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} < $TS_SELF/files/dump-gaps >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "default-vs-gap1" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +3MiB 5MiB L +- 6MiB L +EOF +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "default-vs-gap2" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +4MiB 3MiB L +13MiB 5MiB L +- 4MiB L +- 2MiB L +- - L +EOF +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/sfdisk/dump b/tests/ts/sfdisk/dump new file mode 100755 index 0000000..09a1267 --- /dev/null +++ b/tests/ts/sfdisk/dump @@ -0,0 +1,87 @@ +#!/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="script" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 sector_size=512 physblk_exp=3 + +ts_init_subtest "v2.32" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: gpt +label-id: 613005F9-1C8C-E141-8AEB-F32E8E296C75 +device: ${TS_DEVICE} +unit: sectors +first-lba: 2048 +last-lba: 204766 + +${TS_DEVICE}1 : start= 2048, size= 20480, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=28A432A3-8D63-3142-B9F5-68A2BF2BC60B +${TS_DEVICE}2 : start= 22528, size= 22528, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=6A7D17FC-7252-564A-9B68-5E2107999BF1 +${TS_DEVICE}3 : start= 45056, size= 24576, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=26C303E4-0321-3346-B9EF-BDD39BEA1166 +${TS_DEVICE}4 : start= 69632, size= 135135, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=AF79D434-C8B3-2445-80FB-317AB157447C +EOF +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "v2.35" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: gpt +label-id: 613005F9-1C8C-E141-8AEB-F32E8E296C75 +device: ${TS_DEVICE} +unit: sectors +first-lba: 2048 +last-lba: 204766 +sector-size: 512 + +${TS_DEVICE}1 : start= 2048, size= 20480, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=28A432A3-8D63-3142-B9F5-68A2BF2BC60B +${TS_DEVICE}2 : start= 22528, size= 22528, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=6A7D17FC-7252-564A-9B68-5E2107999BF1 +${TS_DEVICE}3 : start= 45056, size= 24576, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=26C303E4-0321-3346-B9EF-BDD39BEA1166 +${TS_DEVICE}4 : start= 69632, size= 135135, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=AF79D434-C8B3-2445-80FB-317AB157447C +EOF +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "current" +$TS_CMD_SFDISK --dump ${TS_DEVICE} > $TS_OUTPUT.dump 2>> $TS_ERRLOG +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +cat $TS_OUTPUT.dump | $TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/sfdisk/files/dump-gaps b/tests/ts/sfdisk/files/dump-gaps new file mode 100644 index 0000000..3aff9ca --- /dev/null +++ b/tests/ts/sfdisk/files/dump-gaps @@ -0,0 +1,7 @@ +# partition table of /dev/sdc +unit: sectors + +/dev/sdc1 : start= 2048, size= 49999, Id=83, bootable +/dev/sdc2 : start= 0, size= 0, Id= 0 +/dev/sdc3 : start= 52048, size= 49999, Id=83 +/dev/sdc4 : start= 0, size= 0, Id= 0 diff --git a/tests/ts/sfdisk/files/dump-old b/tests/ts/sfdisk/files/dump-old new file mode 100644 index 0000000..7708e5e --- /dev/null +++ b/tests/ts/sfdisk/files/dump-old @@ -0,0 +1,7 @@ +# partition table of /dev/sdc +unit: sectors + +/dev/sdc1 : start= 2048, size= 49999, Id=83, bootable +/dev/sdc2 : start= 0, size= 0, Id= 0 +/dev/sdc3 : start= 0, size= 0, Id= 0 +/dev/sdc4 : start= 0, size= 0, Id= 0 diff --git a/tests/ts/sfdisk/gpt b/tests/ts/sfdisk/gpt new file mode 100755 index 0000000..0726433 --- /dev/null +++ b/tests/ts/sfdisk/gpt @@ -0,0 +1,206 @@ +#!/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="GPT" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +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 "all-defaults" +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: gpt +label-id: b181c399-4711-4c52-8b65-9e764541218d + +,5M +, 5M, L +, 5M,S +, 5M, 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 +, , +EOF +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "uuid" +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 1 91dc657b-d7b4-4653-a367-663194ffd432 &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 2 baa08adf-327e-4177-8953-98da1a5176c4 &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 3 cead8a87-ff1a-45cb-83e5-99b08d0ebc87 &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 4 d4fcdc60-765d-4bc3-bd84-0d0b9842c6db &> /dev/null +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 5 60155bd7-bfd8-4e8c-b800-221900779373 &> /dev/null + +$TS_CMD_SFDISK --part-uuid ${TS_DEVICE} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "label" +$TS_CMD_SFDISK --part-label ${TS_DEVICE} 1 "EFI system" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-label ${TS_DEVICE} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "type" +$TS_CMD_SFDISK --part-type ${TS_DEVICE} 1 "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-type ${TS_DEVICE} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "RequiredPartition,NoBlockIOProtocol,48,51" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-space" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "RequiredPartition NoBlockIOProtocol 48 51" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-guid" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "GUID:48 GUID:51,52,63" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-with-typo" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "RequiredPartiton,NoBlockIOProtocol,48,51" >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +echo -ne 'x\nD\n' | $TS_CMD_FDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "attrs-unsupported" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "NoBlockIOProtocol FooBar 48 51" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "attrs-broken-nosep" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "NoBlockIOProtocolRequiredPartiton" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "attrs-broken-guid" +$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "GUID:NoBlockIOProtocol GUID:GUID:63 RequiredPartiton" >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "read-dump" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048, size=6144, type=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8 +${TS_DEVICE}2 : start=8192, size=6144, uuid=44b51def-5f04-465a-91aa-2889a62d8e49 +${TS_DEVICE}3 : start=14336, size=6144, uuid=643e1d0d-bc02-4ced-b83b-86121062858f +${TS_DEVICE}4 : start=20480, size=81887,uuid=d2a29b0a-fdee-40c3-9bae-b9fa782c986c, name="GPT is the best" +EOF +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "write-dump" +$TS_CMD_SFDISK --unit S --dump ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "write-json" +$TS_CMD_SFDISK --json ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "list-pmbr" +$TS_CMD_SFDISK --list --label-nested dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "resize" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <<EOF +label: gpt +,10M,S,* +EOF +udevadm settle +echo ',+' | $TS_CMD_SFDISK --no-reread -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_init_subtest "reorder" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=8192, size=6144 +${TS_DEVICE}2 : start=2048, size=6144 +${TS_DEVICE}3 : start=20480, size=81887 +${TS_DEVICE}4 : start=14336, size=6144 +EOF +udevadm settle +# why --reorder does not re-read? +$TS_CMD_SFDISK --reorder ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/sfdisk/movedata b/tests/ts/sfdisk/movedata new file mode 100755 index 0000000..239c828 --- /dev/null +++ b/tests/ts/sfdisk/movedata @@ -0,0 +1,75 @@ +#!/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="movedata" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_HELPER_MD5" + +ts_skip_nonroot +ts_check_prog "mkfs.ext4" + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 sector_size=512 + +# create a partition +echo ',10M,L' | $TS_CMD_SFDISK --no-reread ${TS_DEVICE} &> /dev/null +udevadm settle + +mkfs.ext4 ${TS_DEVICE}1 &> /dev/null +udevadm settle +CHECKSUM=$("$TS_HELPER_MD5" < "${TS_DEVICE}1") + +function checksum() { + local dev="$1" + CHECK=$("$TS_HELPER_MD5" < "${dev}") + if [ "$CHECKSUM" != "$CHECK" ]; then + echo "Checksum does not match!" >> $TS_OUTPUT + fi +} + +ts_init_subtest "up" +echo '+1000,' | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "down" +echo "-500," | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + +udevadm settle + +ts_init_subtest "non-overlay" +echo "+30M," | $TS_CMD_SFDISK --no-reread --move-data=$TS_OUTPUT.log -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +checksum ${TS_DEVICE}1 +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/sfdisk/resize b/tests/ts/sfdisk/resize new file mode 100755 index 0000000..fa11373 --- /dev/null +++ b/tests/ts/sfdisk/resize @@ -0,0 +1,154 @@ +#!/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="resize" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=100 sector_size=512 + +declare -a COMM +declare -a NAME + +COMM[0]="3000," +NAME[0]="move-up-absolute" + +COMM[1]="2048," +NAME[1]="move-down-absolute" + +COMM[2]="+1M," +NAME[2]="move-up-relative" + +COMM[3]="-1M," +NAME[3]="move-down-relative" + +COMM[4]="-,15M" +NAME[4]="enlarge-absolute" + +COMM[5]=",5M," +NAME[5]="reduce-absolute" + +COMM[6]=", +10M" +NAME[6]="enlarge-relative" + +NAME[7]="reduce-relative" +COMM[7]=", -10M" + +NAME[8]="enlarge-all" +COMM[8]=",+" + +NAME[9]="up-preduce" +COMM[9]="+10M,-10M" + +NAME[10]="down-enlarge" +COMM[10]="-10M,+10M,,*" + +NAME[11]="absolute-move-resize" +COMM[11]="2048,10M,L" + +function test_label_resize { + local label="$1" + + $TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null + udevadm settle + + # create a partition + echo ',10M,L' | $TS_CMD_SFDISK --no-reread --label ${label} ${TS_DEVICE} &> /dev/null + udevadm settle + + for idx in $(seq 0 $(( ${#COMM[*]} - 1 ))); do + + cmd=${COMM[$idx]} + name=${NAME[$idx]} + + ts_init_subtest "$label-$idx-$name" + echo -e "$cmd\n" >> $TS_OUTPUT + echo "$cmd" | $TS_CMD_SFDISK --no-reread -N1 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_fdisk_clean $TS_DEVICE + udevadm settle + ts_finalize_subtest + done + + echo ',10M,L' | $TS_CMD_SFDISK --no-reread --append ${TS_DEVICE} &> /dev/null + udevadm settle + + echo ',10M,L' | $TS_CMD_SFDISK --no-reread --append ${TS_DEVICE} &> /dev/null + udevadm settle + + idx=$(( $idx + 1 )) + ts_init_subtest "$label-$idx-reduce-midle" + cmd=',-5M' + echo -e "$cmd\n" >> $TS_OUTPUT + echo "$cmd" | $TS_CMD_SFDISK --no-reread -N2 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_fdisk_clean $TS_DEVICE + udevadm settle + ts_finalize_subtest + + idx=$(( $idx + 1 )) + ts_init_subtest "$label-$idx-max-last" + cmd='-5M,+' + echo -e "$cmd\n" >> $TS_OUTPUT + echo $cmd | $TS_CMD_SFDISK --no-reread -N3 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG + ts_fdisk_clean $TS_DEVICE + udevadm settle + ts_finalize_subtest +} + +# MBR +test_label_resize dos + +# GPT +test_label_resize gpt + + +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle + +ts_init_subtest "dos-unsorted" +# create layout where partition #4 is the last on disk (by offset) +# and there is freespace at the end of the disk. Note that #4 is not the last +# partno on the disk. The libfdisk has to be able to check for the free space +# independently on the partno, only offset+size matters. +$TS_CMD_SFDISK --no-reread ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: dos +label-id: 0xda2e45ac +device: ${TS_DEVICE} +unit: sectors + +${TS_DEVICE}1 : start= 2048, size= 2048, type=83 +${TS_DEVICE}2 : start= 4096, size= 2048, type=83 +${TS_DEVICE}3 : start= 6144, size= 102400, type=5 +${TS_DEVICE}4 : start= 108544, size= 2048, type=83 +${TS_DEVICE}5 : start= 8192, size= 2048, type=83 +${TS_DEVICE}6 : start= 12288, size= 96256, type=83 +EOF +udevadm settle +# enlarge to use all space behind partition #4 +echo ',+,' | $TS_CMD_SFDISK --no-reread -N 4 ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/sfdisk/script b/tests/ts/sfdisk/script new file mode 100755 index 0000000..501fce1 --- /dev/null +++ b/tests/ts/sfdisk/script @@ -0,0 +1,157 @@ +#!/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="script" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +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 "type-and-id" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048, size=6144, Id=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8 +${TS_DEVICE}2 : start=8192, size=6144, id=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=44b51def-5f04-465a-91aa-2889a62d8e49 +${TS_DEVICE}3 : start=14336, size=6144, type=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=643e1d0d-bc02-4ced-b83b-86121062858f +${TS_DEVICE}4 : start=20480, size=81887,Type=44479540-F297-41B2-9AF7-D131D5F0458A, uuid=d2a29b0a-fdee-40c3-9bae-b9fa782c986c +EOF +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + +ts_init_subtest "separator" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048 size=6144 uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8 +${TS_DEVICE}2 : start=8192,size=6144, uuid=44b51def-5f04-465a-91aa-2889a62d8e49 ,type=44479540-F297-41B2-9AF7-D131D5F0458A +${TS_DEVICE}3 : start=14336 , size=6144 ,uuid=643e1d0d-bc02-4ced-b83b-86121062858f +${TS_DEVICE}4 : start=20480; size=81887 ; uuid=d2a29b0a-fdee-40c3-9bae-b9fa782c986c +EOF +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "quotes" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048 uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144 +${TS_DEVICE}2 : start= 8192 uuid="44b51def-5f04-465a-91aa-2889a62d8e49" , size=6144 +${TS_DEVICE}3: start=14336 uuid="643e1d0d-bc02-4ced-b83b-86121062858f",size=6144 +${TS_DEVICE}4 : start=20480 uuid="d2a29b0a-fdee-40c3-9bae-b9fa782c986c", size=6144 +EOF +udevadm settle +$TS_CMD_SFDISK --list -o START,END,SIZE,UUID,TYPE,NAME ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "broken-1" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start =2048 uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144 +EOF +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "broken-2" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144 +EOF +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "broken-3" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048 uuid=,"4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144 +EOF +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "broken-4" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048 uuid="4dd6948a-44f8-4e6c-8bdc-064f740704f8 size=6144 +EOF +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +ts_init_subtest "broken-5" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +unit: sectors +label: gpt +label-id: 3b8559db-33af-43e9-befc-c331d829b539 + +${TS_DEVICE}1 : start=2048 uuid=4dd6948a-44f8-4e6c-8bdc-064f740704f8" size=6144 +EOF +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/sfdisk/wipe b/tests/ts/sfdisk/wipe new file mode 100755 index 0000000..2c930fd --- /dev/null +++ b/tests/ts/sfdisk/wipe @@ -0,0 +1,104 @@ +#!/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_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>> $TS_ERRLOG +udevadm settle +ts_separator "Create DOS" +echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --wipe=always --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_separator "Check content" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +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>> $TS_ERRLOG +udevadm settle +ts_separator "Create DOS" +echo ',,L' | $TS_CMD_SFDISK $SFDISK_OPTS --label=dos ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_separator "Check content" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + + +ts_init_subtest "fs-to-dos" +ts_separator "Create FS" +$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null +udevadm settle +$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>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +udevadm settle +ts_separator "Check content" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +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 --no-reread --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Create FS in partition" +$TS_CMD_MKSWAP ${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 --no-reread --wipe-partition=always --label=gpt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Check content (disk)" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG +udevadm settle +ts_separator "Check content (partition)" +$TS_CMD_WIPEFS -O OFFSET,TYPE ${TS_DEVICE}1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean $TS_DEVICE +ts_finalize_subtest + + +udevadm settle +ts_finalize |