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/fdisk/mbr-dos-mode | |
parent | Initial commit. (diff) | |
download | util-linux-upstream.tar.xz util-linux-upstream.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/fdisk/mbr-dos-mode')
-rwxr-xr-x | tests/ts/fdisk/mbr-dos-mode | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/tests/ts/fdisk/mbr-dos-mode b/tests/ts/fdisk/mbr-dos-mode new file mode 100755 index 0000000..cc27429 --- /dev/null +++ b/tests/ts/fdisk/mbr-dos-mode @@ -0,0 +1,145 @@ +#!/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 - dos mode" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" +ts_check_test_command "$TS_HELPER_MD5" + +FDISK_CMD_INIT="x\ni\n0x1\nr\n" +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label +FDISK_CMD_CREATE_PRIMARY="n\np\n1\n\n+1M\n" # create primary partition 1 of size 1MB +FDISK_CMD_CHANGE_PARTTYPE="t\nbf\n" # change partition type to "bf - solaris", this requires that there is only one partition to change +FDISK_CMD_SET_ACTIVE="a\n1\n" # set first partition active +FDISK_CMD_CREATE_EXTENDED="n\ne\n2\n\n+10\n" # create extended partition 2 of size 11 cylinders +FDISK_CMD_CREATE_LOGICAL="n\nl\n\n+1\n" # create next logical partition of size 2 cyl +FDISK_CMD_DELETE_LOGICALS="d\n6\nd\n5\nd\n6\n" # delete middle, head, tail, last partitions +FDISK_CMD_DELETE_PRIMARY="d\n1\n" # delete first primary +FDISK_CMD_DELETE_EXTENDED="d\n2\n" # delete second primary + +FDISK_OPTIONS="-C 1024 -c=dos -u=cylinders" + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK ${FDISK_OPTIONS} -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT + + ts_fdisk_clean ${TEST_IMAGE_NAME} +} + +# +# Note that fdisk will enlarge the disk image (to 57MB) because the logical +# partitions are out of the original range (10MB). +# +ts_init_subtest "empty-pt" +TEST_IMAGE_NAME=$(ts_image_init 10) +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_INIT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-primary-partition" +echo -e "${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-partition-type" +echo -e "${FDISK_CMD_CHANGE_PARTTYPE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "set-primary-par-active" +echo -e "${FDISK_CMD_SET_ACTIVE}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "re-create-primary-par" +echo -e "d\n${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-extended-par" +echo -e "${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" | \ + $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-logical-par" +echo -e "${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-logical-par" +echo -e "${FDISK_CMD_DELETE_LOGICALS}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "create-another-log-par" +echo -e "${FDISK_CMD_CREATE_LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-primary-par" +echo -e "${FDISK_CMD_DELETE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_init_subtest "delete-extended-par" +echo -e "${FDISK_CMD_DELETE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null +ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG + +print_layout +ts_finalize_subtest + +ts_finalize |