From 9e9b1afd397b8a0fce306adc3c226ceacee47f71 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 11 Jul 2017 13:33:52 +0200 Subject: [PATCH] tests: use sample-fdisk-mkpart Signed-off-by: Karel Zak --- tests/commands.sh | 1 + tests/expected/libfdisk/mkpart | 0 tests/expected/libfdisk/mkpart-gpt | 23 ++++++++++ tests/expected/libfdisk/mkpart-mbr | 17 +++++++ tests/expected/libfdisk/mkpart-mbr-logic | 26 +++++++++++ tests/ts/libfdisk/mkpart | 57 ++++++++++++++++++++++++ 6 files changed, 124 insertions(+) create mode 100644 tests/expected/libfdisk/mkpart create mode 100644 tests/expected/libfdisk/mkpart-gpt create mode 100644 tests/expected/libfdisk/mkpart-mbr create mode 100644 tests/expected/libfdisk/mkpart-mbr-logic create mode 100755 tests/ts/libfdisk/mkpart diff --git a/tests/commands.sh b/tests/commands.sh index 2d9e3b8ea3..6190582073 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -8,6 +8,7 @@ TS_HELPER_DMESG="$top_builddir/test_dmesg" TS_HELPER_ISLOCAL="$top_builddir/test_islocal" 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_LIBMOUNT_LOCK="$top_builddir/test_mount_lock" TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/test_mount_optstr" diff --git a/tests/expected/libfdisk/mkpart b/tests/expected/libfdisk/mkpart new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/expected/libfdisk/mkpart-gpt b/tests/expected/libfdisk/mkpart-gpt new file mode 100644 index 0000000000..3634695f97 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-gpt @@ -0,0 +1,23 @@ +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 30686 16351 8M Linux filesystem diff --git a/tests/expected/libfdisk/mkpart-mbr b/tests/expected/libfdisk/mkpart-mbr new file mode 100644 index 0000000000..0212000e32 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-mbr @@ -0,0 +1,17 @@ +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-mbr-logic b/tests/expected/libfdisk/mkpart-mbr-logic new file mode 100644 index 0000000000..178eaf2f23 --- /dev/null +++ b/tests/expected/libfdisk/mkpart-mbr-logic @@ -0,0 +1,26 @@ +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/ts/libfdisk/mkpart b/tests/ts/libfdisk/mkpart new file mode 100755 index 0000000000..850b1c5aae --- /dev/null +++ b/tests/ts/libfdisk/mkpart @@ -0,0 +1,57 @@ +#!/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>&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-logic" +$TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \ + 1M 1M 1M - 1M 1M ->> $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} \ + 1M 1M 1M 1M 1M 1M - >> $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