[PATCH] test for the s/PED_MAX/PED_MIN/ partition-number fix
Jim Meyering
meyering at redhat.com
Tue Jul 8 08:48:07 UTC 2008
* tests/t4200-partprobe.sh: New file. Test for today's fix.
* tests/Makefile.am (TESTS): Add t4200-partprobe.sh.
(init.sh): Now that we test partprobe,
add $(abs_top_builddir)/partprobe to PATH.
* tests/test-lib.sh: Honor new dvhtool_required_ variable.
Based on a reproducer from Petr Uzel.
---
tests/Makefile.am | 7 ++++-
tests/t4200-partprobe.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++
tests/test-lib.sh | 10 +++++++
3 files changed, 81 insertions(+), 1 deletions(-)
create mode 100755 tests/t4200-partprobe.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fbcad7c..b9db0b1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,6 +11,7 @@ TESTS = \
t3100-resize-ext2-partion.sh \
t4100-msdos-partition-limits.sh \
t4100-dvh-partition-limits.sh \
+ t4200-partprobe.sh \
t5000-tags.sh \
t6000-dm.sh \
t7000-scripting.sh
@@ -18,13 +19,17 @@ TESTS = \
EXTRA_DIST = \
$(TESTS) test-lib.sh lvm-utils.sh
+parted_dir = $(abs_top_builddir)/parted
+pp_dir = $(abs_top_builddir)/partprobe
+sep = $(PATH_SEPARATOR)
+
CLEANFILES = init.sh
all: init.sh
init.sh: Makefile.in
rm -f $@-t $@
echo 'PARTED_USABLE_TEST_DIR=$(PARTED_USABLE_TEST_DIR)' > $@-t
echo 'abs_top_srcdir=$(abs_top_srcdir)' >> $@-t
- echo 'PATH=$(abs_top_builddir)/parted$(PATH_SEPARATOR)$$PATH' >> $@-t
+ echo 'PATH=$(parted_dir)$(sep)$(pp_dir)$(sep)$$PATH' >> $@-t
echo 'export PATH' >> $@-t
chmod a-w $@-t
mv $@-t $@
diff --git a/tests/t4200-partprobe.sh b/tests/t4200-partprobe.sh
new file mode 100755
index 0000000..db10c49
--- /dev/null
+++ b/tests/t4200-partprobe.sh
@@ -0,0 +1,65 @@
+#!/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 <http://www.gnu.org/licenses/>.
+
+test_description='partprobe must not examine more than 16 partitions'
+
+privileges_required_=1
+erasable_device_required_=1
+dvhtool_required_=1
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+dev=$DEVICE_TO_ERASE
+
+test_expect_success \
+ "setup: create a DVH partition table on $dev" \
+ '
+ dd if=/dev/zero of=$dev bs=512 count=1 seek=10000 &&
+ parted -s $dev mklabel dvh
+ '
+
+test_expect_success \
+ "setup: use dvhtool to create a 17th (invalid?) partition" \
+ '
+ dd if=/dev/zero of=d bs=1 count=4k &&
+ dvhtool -d $dev --unix-to-vh d data
+ '
+
+# Here's sample output from the parted...print command below:
+# BYT;
+# /dev/sdd:128880s:scsi:512:512:dvh: Flash Disk;
+# 9:0s:4095s:4096s:::;
+# 17:4s:11s:8s::data:;
+
+test_expect_success \
+ "ensure that dvhtool did what we want" \
+ '
+ parted -m -s $dev unit s print > out 2>&1 &&
+ grep "^17:.*::data:;\$" out
+ '
+
+# Parted 1.8.9 and earlier would mistakenly try to access partition #17.
+test_expect_success \
+ "ensure that partprobe succeeds and produces no output" \
+ '
+ partprobe -s $dev > out 2>err &&
+ $compare err /dev/null &&
+ echo "$dev: dvh partitions 9 <17>" > exp &&
+ $compare out exp
+ '
+
+test_done
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 621d1b0..3a9a815 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -203,6 +203,16 @@ if test "$privileges_required_" != ''; then
fi
fi
+# If $dvhtool_required_ is nonempty, and you lack the dvhtool program,
+# then skip this test.
+if test "$dvhtool_required_" != ''; then
+ (dvhtool --help) > /dev/null 2>&1 || {
+ SKIP_TESTS="$SKIP_TESTS $this_test"
+ say "you lack dvhtool, which is required for test $this_test"
+ skip_=1
+ }
+fi
+
emit_superuser_warning()
{
uid=`id -u` || uid=1
--
1.5.6.2.222.gf3584
More information about the parted-devel
mailing list