From 30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:14:44 +0200 Subject: Adding upstream version 2.36.1. Signed-off-by: Daniel Baumann --- tests/ts/sfdisk/dos | 263 ++++++++++++++++++++++++++++++++++++++++ tests/ts/sfdisk/dump | 87 +++++++++++++ tests/ts/sfdisk/files/dump-gaps | 7 ++ tests/ts/sfdisk/files/dump-old | 7 ++ tests/ts/sfdisk/gpt | 206 +++++++++++++++++++++++++++++++ tests/ts/sfdisk/movedata | 75 ++++++++++++ tests/ts/sfdisk/resize | 154 +++++++++++++++++++++++ tests/ts/sfdisk/script | 157 ++++++++++++++++++++++++ tests/ts/sfdisk/wipe | 104 ++++++++++++++++ 9 files changed, 1060 insertions(+) create mode 100755 tests/ts/sfdisk/dos create mode 100755 tests/ts/sfdisk/dump create mode 100644 tests/ts/sfdisk/files/dump-gaps create mode 100644 tests/ts/sfdisk/files/dump-old create mode 100755 tests/ts/sfdisk/gpt create mode 100755 tests/ts/sfdisk/movedata create mode 100755 tests/ts/sfdisk/resize create mode 100755 tests/ts/sfdisk/script create mode 100755 tests/ts/sfdisk/wipe (limited to 'tests/ts/sfdisk') 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 <> $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 < /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK --unit S ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $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 < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} > /dev/null 2>&1 <> $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 <> $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 <> $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 <> $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 <> $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 < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $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 <> $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 < /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 <> $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 <> $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 <> $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 <> $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 <> $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 <> $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 <> $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 < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG < /dev/null +udevadm settle +$TS_CMD_SFDISK ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <> $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 -- cgit v1.2.3