From 4a61c960cedf861a08f6966688ba6adfc7974f6c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 11 Jul 2017 14:26:33 +0200 Subject: [PATCH] tests: use sample-fdisk-mkpart-fullspec Signed-off-by: Karel Zak --- tests/commands.sh | 1 + tests/expected/libfdisk/mkpart-full | 0 tests/expected/libfdisk/mkpart-full-gpt | 30 +++ .../libfdisk/mkpart-full-gpt-err-overlap | 14 ++ .../libfdisk/mkpart-full-gpt-partno-gap | 30 +++ .../libfdisk/mkpart-full-gpt-space-gap | 24 +++ .../libfdisk/mkpart-full-mbr-err-logical | 18 ++ .../libfdisk/mkpart-full-mbr-err-nospace | 12 ++ .../libfdisk/mkpart-full-mbr-err-primary | 12 ++ .../expected/libfdisk/mkpart-full-mbr-logical | 33 ++++ .../libfdisk/mkpart-full-mbr-partno-gap | 26 +++ .../expected/libfdisk/mkpart-full-mbr-primary | 21 ++ .../libfdisk/mkpart-full-mbr-space-gap | 18 ++ tests/ts/libfdisk/mkpart-full | 181 ++++++++++++++++++ 14 files changed, 420 insertions(+) create mode 100644 tests/expected/libfdisk/mkpart-full create mode 100644 tests/expected/libfdisk/mkpart-full-gpt create mode 100644 tests/expected/libfdisk/mkpart-full-gpt-err-overlap create mode 100644 tests/expected/libfdisk/mkpart-full-gpt-partno-gap create mode 100644 tests/expected/libfdisk/mkpart-full-gpt-space-gap create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-err-logical create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-err-nospace create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-err-primary create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-logical create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-partno-gap create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-primary create mode 100644 tests/expected/libfdisk/mkpart-full-mbr-space-gap create mode 100755 tests/ts/libfdisk/mkpart-full diff --git a/tests/commands.sh b/tests/commands.sh index 6190582073..efa0278c15 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -10,6 +10,7 @@ TS_HELPER_ISMOUNTED="$top_builddir/test_ismounted" TS_HELPER_LIBFDISK_GPT="$top_builddir/test_fdisk_gpt" TS_HELPER_LIBFDISK_MKPART="$top_builddir/sample-fdisk-mkpart" TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/test_mount_context" +TS_HELPER_LIBFDISK_MKPART_FULLSPEC="$top_builddir/sample-fdisk-mkpart-fullspec" TS_HELPER_LIBMOUNT_LOCK="$top_builddir/test_mount_lock" TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/test_mount_optstr" TS_HELPER_LIBMOUNT_TABDIFF="$top_builddir/test_mount_tab_diff" diff --git a/tests/expected/libfdisk/mkpart-full b/tests/expected/libfdisk/mkpart-full new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/libfdisk/mkpart-full-gpt b/tests/expected/libfdisk/mkpart-full-gpt new file mode 100644 index 0000000000..d33483ac6c --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-gpt @@ -0,0 +1,30 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: gpt +Disk identifier: + +Device Start End Sectors Size Type +1 2048 4095 2048 1M Linux filesystem +2 4096 6143 2048 1M Linux filesystem +3 6144 8191 2048 1M Linux filesystem +4 8192 10239 2048 1M Linux filesystem +5 10240 12287 2048 1M Linux filesystem +6 12288 14335 2048 1M Linux filesystem +7 14336 16383 2048 1M Linux filesystem diff --git a/tests/expected/libfdisk/mkpart-full-gpt-err-overlap b/tests/expected/libfdisk/mkpart-full-gpt-err-overlap new file mode 100644 index 0000000000..aea49cd5a2 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-gpt-err-overlap @@ -0,0 +1,14 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Sector 5000 already used. +sample-fdisk-mkpart-fullspec: failed to add #4 partition: Numerical result out of range +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes diff --git a/tests/expected/libfdisk/mkpart-full-gpt-partno-gap b/tests/expected/libfdisk/mkpart-full-gpt-partno-gap new file mode 100644 index 0000000000..b142b5efe3 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-gpt-partno-gap @@ -0,0 +1,30 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: gpt +Disk identifier: + +Device Start End Sectors Size Type +1 2048 4095 2048 1M Linux filesystem +2 4096 6143 2048 1M Linux filesystem +4 6144 8191 2048 1M Linux filesystem +5 8192 10239 2048 1M Linux filesystem +7 10240 12287 2048 1M Linux filesystem +8 12288 14335 2048 1M Linux filesystem +9 14336 16383 2048 1M Linux filesystem diff --git a/tests/expected/libfdisk/mkpart-full-gpt-space-gap b/tests/expected/libfdisk/mkpart-full-gpt-space-gap new file mode 100644 index 0000000000..c26f2896ba --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-gpt-space-gap @@ -0,0 +1,24 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: gpt +Disk identifier: + +Device Start End Sectors Size Type +1 2048 4095 2048 1M Linux filesystem +2 6144 8191 2048 1M Linux filesystem +3 8192 10239 2048 1M Linux filesystem +4 12288 14335 2048 1M Linux filesystem +5 14336 16383 2048 1M Linux filesystem diff --git a/tests/expected/libfdisk/mkpart-full-mbr-err-logical b/tests/expected/libfdisk/mkpart-full-mbr-err-logical new file mode 100644 index 0000000000..b2249c8678 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-err-logical @@ -0,0 +1,18 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +sample-fdisk-mkpart-fullspec: failed to add #6 partition: Invalid argument +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Adding logical partition 5 +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-err-nospace b/tests/expected/libfdisk/mkpart-full-mbr-err-nospace new file mode 100644 index 0000000000..cc243befb9 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-err-nospace @@ -0,0 +1,12 @@ +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Start sector 4096 out of range. +sample-fdisk-mkpart-fullspec: failed to add #3 partition: Numerical result out of range +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-err-primary b/tests/expected/libfdisk/mkpart-full-mbr-err-primary new file mode 100644 index 0000000000..aeb4bc7d8d --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-err-primary @@ -0,0 +1,12 @@ +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Extended partition does not exists. Failed to add logical partition. +sample-fdisk-mkpart-fullspec: failed to add #7 partition: Invalid argument +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes diff --git a/tests/expected/libfdisk/mkpart-full-mbr-logical b/tests/expected/libfdisk/mkpart-full-mbr-logical new file mode 100644 index 0000000000..97e7a4a540 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-logical @@ -0,0 +1,33 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Adding logical partition 5 +Created a new . +Adding logical partition 6 +Created a new . +Adding logical partition 7 +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: dos +Disk identifier: + +Device Boot Start End Sectors Size Id Type +1 2048 4095 2048 1M 83 Linux +2 4096 6143 2048 1M 83 Linux +3 6144 8191 2048 1M 83 Linux +4 8192 30719 22528 11M 5 Extended +5 10240 12287 2048 1M 83 Linux +6 14336 16383 2048 1M 83 Linux +7 18432 30719 12288 6M 83 Linux diff --git a/tests/expected/libfdisk/mkpart-full-mbr-partno-gap b/tests/expected/libfdisk/mkpart-full-mbr-partno-gap new file mode 100644 index 0000000000..7f5fab5c53 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-partno-gap @@ -0,0 +1,26 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Adding logical partition 5 +Created a new . +Adding logical partition 6 +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: dos +Disk identifier: + +Device Boot Start End Sectors Size Id Type +1 2048 4095 2048 1M 83 Linux +3 4096 6143 2048 1M 83 Linux +4 6144 30719 24576 12M 5 Extended +5 10240 12287 2048 1M 83 Linux +6 14336 16383 2048 1M 83 Linux diff --git a/tests/expected/libfdisk/mkpart-full-mbr-primary b/tests/expected/libfdisk/mkpart-full-mbr-primary new file mode 100644 index 0000000000..31e84344d4 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-primary @@ -0,0 +1,21 @@ +Requested partition: +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: dos +Disk identifier: + +Device Boot Start End Sectors Size Id Type +1 2048 4095 2048 1M 83 Linux +2 4096 6143 2048 1M 83 Linux +3 6144 8191 2048 1M 83 Linux +4 8192 30719 22528 11M 83 Linux diff --git a/tests/expected/libfdisk/mkpart-full-mbr-space-gap b/tests/expected/libfdisk/mkpart-full-mbr-space-gap new file mode 100644 index 0000000000..45d45071fe --- /dev/null +++ b/tests/expected/libfdisk/mkpart-full-mbr-space-gap @@ -0,0 +1,18 @@ +Requested partition: +Requested partition: +Requested partition: +Created a new . +Created a new . +Created a new . +Created a new . +Disk : 15 MiB, 15728640 bytes, 30720 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / bytes +Disklabel type: dos +Disk identifier: + +Device Boot Start End Sectors Size Id Type +1 2048 4095 2048 1M 83 Linux +2 6144 8191 2048 1M 83 Linux +3 8192 10239 2048 1M 83 Linux diff --git a/tests/ts/libfdisk/mkpart-full b/tests/ts/libfdisk/mkpart-full new file mode 100755 index 0000000000..0b7cfcb0c6 --- /dev/null +++ b/tests/ts/libfdisk/mkpart-full @@ -0,0 +1,181 @@ +#!/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" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,22528 \ + >> $TS_OUTPUT 2>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 7,6144,2048 \ + >> $TS_OUTPUT 2>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,4096,2048 \ + >> $TS_OUTPUT 2>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + +$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null + + +ts_init_subtest "mbr-logical" +$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>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$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>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1,2048,2048 \ + 2,6144,2048 \ + 3,8192,2048 \ + >> $TS_OUTPUT 2>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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} \ + 1,2048,2048 \ + 2,4096,2048 \ + 3,6144,2048 \ + 4,8192,2048 \ + 5,10240,2048 \ + 6,12288,2048 \ + 7,14336,2048 \ + >> $TS_OUTPUT 2>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$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>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$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>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +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" +$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>&1 +$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>&1 +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize_subtest + + + +ts_finalize -- 2.47.2