diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:30:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:30:35 +0000 |
commit | 378c18e5f024ac5a8aef4cb40d7c9aa9633d144c (patch) | |
tree | 44dfb6ca500d32cabd450649b322a42e70a30683 /tests/ts/libfdisk | |
parent | Initial commit. (diff) | |
download | util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.tar.xz util-linux-378c18e5f024ac5a8aef4cb40d7c9aa9633d144c.zip |
Adding upstream version 2.38.1.upstream/2.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/libfdisk')
-rwxr-xr-x | tests/ts/libfdisk/gpt | 65 | ||||
-rwxr-xr-x | tests/ts/libfdisk/mkpart | 66 | ||||
-rwxr-xr-x | tests/ts/libfdisk/mkpart-full | 225 |
3 files changed, 356 insertions, 0 deletions
diff --git a/tests/ts/libfdisk/gpt b/tests/ts/libfdisk/gpt new file mode 100755 index 0000000..3578cd1 --- /dev/null +++ b/tests/ts/libfdisk/gpt @@ -0,0 +1,65 @@ +#!/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 "$*" + +TESTPROG="$TS_HELPER_LIBFDISK_GPT" +ts_check_test_command "$TESTPROG" +ts_check_test_command "$TS_CMD_SFDISK" + +TEST_IMAGE_NAME=$(ts_image_init 10) + +ts_init_subtest "all-defaults" +$TS_CMD_SFDISK --unit S ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: gpt +label-id: b181c399-4711-4c52-8b65-9e764541218d + +size=5M, attrs="RequiredPartition,48" +attrs="52,53,62" +EOF +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +TEST_IMAGE_NAME=$(ts_image_init 10) + +ts_init_subtest "all-defaults-with-typo" +$TS_CMD_SFDISK --unit S ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF +label: gpt +label-id: b181c399-4711-4c52-8b65-9e764541218d + +size=5M, attrs="RequiredPartiton,48" +attrs="52,53,62" +EOF +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +ts_init_subtest "getattr" +ts_run $TESTPROG --getattr ${TEST_IMAGE_NAME} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --getattr ${TEST_IMAGE_NAME} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_init_subtest "setattr" +ts_run $TESTPROG --setattr ${TEST_IMAGE_NAME} 1 0xff00000000000000 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_run $TESTPROG --setattr ${TEST_IMAGE_NAME} 2 0x4 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TEST_IMAGE_NAME} 1 >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --part-attrs ${TEST_IMAGE_NAME} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_finalize_subtest + +ts_finalize diff --git a/tests/ts/libfdisk/mkpart b/tests/ts/libfdisk/mkpart new file mode 100755 index 0000000..44029a6 --- /dev/null +++ b/tests/ts/libfdisk/mkpart @@ -0,0 +1,66 @@ +#!/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. +# +# Create partition in non-interactive mode. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkpart" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBFDISK_MKPART" +ts_check_test_command "$TESTPROG" +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +TEST_IMAGE_NAME=$(ts_image_init 15) + +ts_init_subtest "mbr" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-logic" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - 1M 1M ->> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-nopartno" +$TESTPROG --nopartno --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - 1M 1M ->> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt" +$TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M 1M 1M 1M - >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + + +ts_finalize diff --git a/tests/ts/libfdisk/mkpart-full b/tests/ts/libfdisk/mkpart-full new file mode 100755 index 0000000..05b2b47 --- /dev/null +++ b/tests/ts/libfdisk/mkpart-full @@ -0,0 +1,225 @@ +#!/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. +# +# +# Create partition in non-interactive mode; like mkpart, but partition is fully +# specifuied by partno, start and size. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="mkpart-full" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBFDISK_MKPART_FULLSPEC" +ts_check_test_command "$TESTPROG" +ts_check_test_command "$TS_CMD_SFDISK" +ts_check_test_command "$TS_CMD_WIPEFS" + +TEST_IMAGE_NAME=$(ts_image_init 15) + +ts_init_subtest "mbr-primary" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + + +ts_init_subtest "mbr-primary-nopartno" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ + -,2048,2048 \ + -,4096,2048 \ + -,6144,2048 \ + -,8192,22528 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +## no extended but partno > 4 requested +ts_init_subtest "mbr-err-primary" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 7,6144,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +## no extended but partno > 4 requested +ts_init_subtest "mbr-err-nospace" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,4096,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + + +ts_init_subtest "mbr-logical" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + 5,10240,2048 \ + 6,14336,2048 \ + 7,18432,12288 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-nopartno" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \ + -,2048,2048 \ + -,4096,2048 \ + -,6144,2048 \ + -,8192,22528 \ + -,10240,2048 \ + -,14336,2048 \ + -,18432,12288 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +### 6th partition (logical) out of extended +ts_init_subtest "mbr-err-logical" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + 5,10240,2048 \ + 6,4096,2048 \ + 7,18432,12288 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "mbr-space-gap" +ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,6144,2048 \ + 3,8192,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,2048 \ + 5,10240,2048 \ + 6,12288,2048 \ + 7,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt-nopartno" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} -- \ + -,2048,2048 \ + -,4096,2048 \ + -,6144,2048 \ + -,8192,2048 \ + -,10240,2048 \ + -,12288,2048 \ + -,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +### 4th partition overlap 4th and 5th +ts_init_subtest "gpt-err-overlap" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,5000,2048 \ + 5,10240,2048 \ + 6,12288,2048 \ + 7,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt-partno-gap" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 4,6144,2048 \ + 5,8192,2048 \ + 7,10240,2048 \ + 8,12288,2048 \ + 9,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + +ts_init_subtest "gpt-space-gap" +ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,6144,2048 \ + 3,8192,2048 \ + 4,12288,2048 \ + 5,14336,2048 \ + >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +ts_finalize |