This test try to reproduce the issue reported in Debian bug #582818[1]. 1. http://bugs.debian.org/582818
Basically it does: * create two primary partitions * mount the second one * remove the first (must works) * try to remove the second (must fail) * tests/t1101-busy-partition.sh: new file. * tests/Makefile.am: add the new test in check target. --- tests/Makefile.am | 1 + tests/t1101-busy-partition.sh | 73 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-) create mode 100755 tests/t1101-busy-partition.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index aa67f99..a1ab0d8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,6 +19,7 @@ TESTS = \ t0400-loop-clobber-infloop.sh \ t0500-dup-clobber.sh \ t1100-busy-label.sh \ + t1101-busy-partition.sh \ t1700-ext-probe.sh \ t2100-mkswap.sh \ t2200-dos-label-recog.sh \ diff --git a/tests/t1101-busy-partition.sh b/tests/t1101-busy-partition.sh new file mode 100755 index 0000000..8d80f7d --- /dev/null +++ b/tests/t1101-busy-partition.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# Copyright (C) 2010 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 <http://www.gnu.org/licenses/>. + +# This is a test for Debian bug #582818 (http://bugs.debian.org/582818). + +test_description='partitioning (parted -s DEV rm 2) a busy disk must fail.' + +privileges_required_=1 +erasable_device_required_=1 + +: ${srcdir=.} +. $srcdir/test-lib.sh +require_512_byte_sector_size_ +dev=$DEVICE_TO_ERASE + +test_expect_success \ + "setup: create a fat32 file system on $dev" \ + 'dd if=/dev/zero "of=$dev" bs=1k count=1 2> /dev/null && + parted -s "$dev" mklabel msdos > out 2>&1 && + parted -s "$dev" mkpartfs primary fat32 1 40 >> out 2>&1 && + parted -s "$dev" mkpartfs primary fat32 40 80 >> out 2>&1' +test_expect_success 'expect no output' 'compare out /dev/null' + +mount_point="`pwd`/mnt" + +# Be sure to unmount upon interrupt, failure, etc. +cleanup_() { umount "${dev}2" > /dev/null 2>&1; } + +# There's a race condition here: on udev-based systems, the partition#1 +# device, ${dev}1 (i.e., /dev/sdd1) is not created immediately, and +# without some delay, this mount command would fail. Using a flash card +# as $dev, the loop below typically iterates 7-20 times. +test_expect_success \ + 'create mount point dir. and mount the just-created partition on it' \ + 'mkdir $mount_point && + i=0; while :; do test -e "${dev}2" && break; test $i = 90 && break; + i=$(expr $i + 1); done; + mount "${dev}2" $mount_point' + +test_expect_success \ + 'now that a partition 2 is mounted, rm 1 must work' \ + 'parted -s "$dev" rm 1 > out 2>&1' + + +test_expect_failure \ + 'now that a partition 1 is removed, rm 2 attempt must fail' \ + 'parted -s "$dev" rm 2 > out 2>&1' + +fail=0 +cat <<EOF > exp || fail=1 +Error: Partition ${dev}2 is being used. You must unmount it before you modify it with Parted. +EOF +test_expect_success 'create expected output file' 'test $fail = 0' + +test_expect_success \ + 'check for expected failure diagnostic' \ + 'compare out exp' + +test_done -- 1.7.1.569.g6f426 _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

