Petr Uzel <[email protected]> wrote:
> attached patch adds test for Jim's fix (failed assertion when creating
> GPT label). My first parted test, so please let me know what you
> think.
Thanks!
Here's a slightly smaller (clearer to me) reproducer:
dev=file
dd if=/dev/null of=$dev seek=4001
./parted -s $dev mklabel gpt
dd if=/dev/null of=$dev seek=4000
./parted -s $dev mklabel gpt
I'm making these changes to your test:
diff --git a/tests/t0201-gpt.sh b/tests/t0201-gpt.sh
index 0974e1a..0b8a970 100755
--- a/tests/t0201-gpt.sh
+++ b/tests/t0201-gpt.sh
@@ -20,13 +20,10 @@ test_description='avoid failed assertion when creating a
GPT on top of an old on
: ${srcdir=.}
. $srcdir/test-lib.sh
-N1=10M
-N2=5M
dev=loop-file
-tmp=loop-file-tmp
test_expect_success \
- 'create a file large enough to hold a GPT partition table' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N1 2> /dev/null'
+ 'create a backing file large enough for a GPT partition table' \
+ 'dd if=/dev/null of=$dev seek=4001 2> /dev/null'
test_expect_success \
'create a GPT partition table' \
@@ -34,12 +31,12 @@ test_expect_success \
test_expect_success 'expect no output' 'compare out /dev/null'
test_expect_success \
- 'shrink the backing file' \
- 'dd if=$dev of=$tmp bs=$N2 count=1 && mv $tmp $dev'
+ 'shrink the backing file' \
+ 'dd if=/dev/null of=$dev seek=4000 2> /dev/null'
test_expect_success \
- 'create GPT on top of the shrunken backing file' \
- 'parted -s $dev mklabel gpt > out 2>&1'
+ 'create a new GPT table on top of the shrunken backing file' \
+ 'parted -s $dev mklabel gpt > out 2>&1'
test_expect_success 'expect no output' 'compare out /dev/null'
test_done
---------------------------------------
Plus I changed the log entry to be more like the others,
listing each affected file (ChangeLog style), so here's
what I expect to push:
>From d53aad51bdb88458a7405ce604056ce7c0b1168c Mon Sep 17 00:00:00 2001
From: Petr Uzel <[email protected]>
Date: Wed, 18 Feb 2009 14:43:36 +0100
Subject: [PATCH] test for the gpt_read failed-assertion fix
* tests/t0201-gpt.sh: New file.
* tests/Makefile.am (TESTS): Add it.
---
tests/Makefile.am | 1 +
tests/t0201-gpt.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
create mode 100755 tests/t0201-gpt.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 14e4862..0beedd4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,6 +2,7 @@ TESTS = \
t0000-basic.sh \
t0100-print.sh \
t0200-gpt.sh \
+ t0201-gpt.sh \
t1000-mkpartfs.sh \
t1100-busy-label.sh \
t1500-small-ext2.sh \
diff --git a/tests/t0201-gpt.sh b/tests/t0201-gpt.sh
new file mode 100755
index 0000000..0b8a970
--- /dev/null
+++ b/tests/t0201-gpt.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Copyright (C) 2009 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='avoid failed assertion when creating a GPT on top of an old
one for a larger device'
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+dev=loop-file
+test_expect_success \
+ 'create a backing file large enough for a GPT partition table' \
+ 'dd if=/dev/null of=$dev seek=4001 2> /dev/null'
+
+test_expect_success \
+ 'create a GPT partition table' \
+ 'parted -s $dev mklabel gpt > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_expect_success \
+ 'shrink the backing file' \
+ 'dd if=/dev/null of=$dev seek=4000 2> /dev/null'
+
+test_expect_success \
+ 'create a new GPT table on top of the shrunken backing file' \
+ 'parted -s $dev mklabel gpt > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_done
--
1.6.2.rc1.209.gfe624
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel