From 2fb0836622aafcdcb7da511c3890a28887a36754 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 29 May 2008 11:21:05 +0200 Subject: [PATCH] test for improved DOS-partition-table recognition * tests/t2200-dos-label-recog.sh: New file. * tests/Makefile.am (TESTS): Add t2200-dos-label-recog.sh. --- tests/Makefile.am | 1 + tests/t2200-dos-label-recog.sh | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 tests/t2200-dos-label-recog.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index d9b0878..e41b5ae 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,6 +6,7 @@ TESTS = \ t1500-small-ext2.sh \ t2000-mkfs.sh \ t2100-mkswap.sh \ + t2200-dos-label-recog.sh \ t3000-constraints.sh \ t3100-resize-ext2-partion.sh \ t4100-msdos-partition-limits.sh \ diff --git a/tests/t2200-dos-label-recog.sh b/tests/t2200-dos-label-recog.sh new file mode 100755 index 0000000..d5d2670 --- /dev/null +++ b/tests/t2200-dos-label-recog.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# Copyright (C) 2008 Free Software Foundation, Inc. + +# This program 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 3 of the License, or +# (at your option) any later version. + +# This program 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. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +test_description='improved MSDOS partition-table recognition' + +. ./init.sh + +###################################################################### +# With vestiges of a preceding FAT file system boot sector in the MBR, +# parted 1.8.8.1.29 and earlier would fail to recognize a DOS +# partition table. +###################################################################### +N=100k +dev=loop-file +test_expect_success \ + 'create a file to simulate the underlying device' \ + 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null' + +test_expect_success \ + 'label the test disk' \ + 'parted -s $dev mklabel msdos > out 2>&1' +test_expect_success 'expect no output' '$compare out /dev/null' + +test_expect_success \ + 'create two partition' \ + ' + parted -s $dev mkpart primary 1s 40s > out 2>&1 && + parted -s $dev mkpart primary 41s 80s > out 2>&1 + + ' +test_expect_success 'expect no output' '$compare out /dev/null' + +test_expect_success \ + 'write "FAT" where it would cause trouble' \ + 'printf FAT|dd bs=1c seek=82 count=3 of=$dev conv=notrunc' + +test_expect_success \ + 'print the partition table' \ + ' + parted -m -s $dev unit s p > out && + tail -2 out > k && mv k out && + printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp + + ' +test_expect_success 'expect two partitions' '$compare out exp' + +test_done -- 2.11.0