Hi Flavio, Thanks a lot for finding and fixing those bugs, and for adding the test case.
I've just reviewed your patch, http://sysclose.org/parted/ (copy included below -- in general, it's best to post review request + patch, to the mailing list) I've made the following two additional changes and will push the merged result to the trunk soon: >From 869b870cdaad095d296822412ed1fe63a6a5d067 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Mon, 14 May 2007 09:43:06 +0200 Subject: [PATCH] remove trailing blank Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- tests/t2000-mkfs.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh index 862ff21..aa72de5 100755 --- a/tests/t2000-mkfs.sh +++ b/tests/t2000-mkfs.sh @@ -76,7 +76,7 @@ test_expect_success \ test_expect_success \ 'normalize the actual output' \ - 'sed -n "s/.*\(Warning: The existing.*\)$/\1/p" out > out2' + 'sed -n "s/.*\(Warning: The existing.*\)$/\1/p" out > out2' test_expect_success \ 'check for expected prompt' '$compare out2 exp' -- 1.5.2.rc3.27.g43d151 >From fe097d685f9860e76cbf5fa575984f2d3294926a Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Mon, 14 May 2007 11:33:42 +0200 Subject: [PATCH] Fail if we can't create the input or expected output file. Signed-off-by: Jim Meyering <[EMAIL PROTECTED]> --- tests/t2000-mkfs.sh | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh index aa72de5..fb42f7a 100755 --- a/tests/t2000-mkfs.sh +++ b/tests/t2000-mkfs.sh @@ -64,11 +64,7 @@ mkfs No quit EOF - -# create output with expected prompt -cat <<EOF > exp || fail=1 -Warning: The existing file system will be destroyed and all data on the partition will be lost. Do you want to continue? -EOF +test_expect_success 'create input file' 'test $fail = 0' test_expect_success \ 'create a partition and a filesystem in the same session' \ @@ -79,6 +75,9 @@ test_expect_success \ 'sed -n "s/.*\(Warning: The existing.*\)$/\1/p" out > out2' test_expect_success \ - 'check for expected prompt' '$compare out2 exp' + 'check for expected prompt' \ + 'echo "Warning: The existing file system will be destroyed and all" \ + "data on the partition will be lost. Do you want to continue?" > exp && + $compare out2 exp' test_done -- 1.5.2.rc3.27.g43d151 For the record, here's a copy of the patch, http://sysclose.org/parted/ ---------------------------------- >From e9c43085675b8d4fdd18f26b71bcb3e0fc94b292 Mon Sep 17 00:00:00 2001 From: Flavio Leitner <[EMAIL PROTECTED]> Date: Sun, 13 May 2007 14:29:57 -0300 Subject: [PATCH] [parted] Fix ped exception handling in mkpart and mkpartfs Parted mkpart and mkpartfs commands does: ... ped_exception_fetch_all(); if (!ped_disk_add_partition (disk, part, final_constraint)) { ped_exception_leave_all(); ... } ... In mkpart if the ped_disk_add_partition() returns true it skips ped_exception_leave_all() leaving ex_fetch_count = 1. In mkpartfs if the ped_disk_add_partition() returns false it will call ped_exception_leave_all() leaving ex_fetch_count negative. The wrong count in ex_fetch_count will prevent next commands to correctly handle exceptions, failing to prompt users for example. Note: test script t2000-mkfs.sh improved to verify against this issue. Signed-off-by: Flavio Leitner <[EMAIL PROTECTED]> --- parted/parted.c | 5 ++++- tests/t2000-mkfs.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletions(-) diff --git a/parted/parted.c b/parted/parted.c index c7b3e22..202558a 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -784,6 +784,8 @@ do_mkpart (PedDevice** dev) } else { goto error_remove_part; } + } else { + ped_exception_leave_all(); } ped_exception_catch(); @@ -952,9 +954,10 @@ do_mkpartfs (PedDevice** dev) } else { goto error_remove_part; } + } else { + ped_exception_leave_all(); } ped_exception_catch(); - ped_exception_leave_all(); /* set LBA flag automatically if available */ if (ped_partition_is_flag_available (part, PED_PARTITION_LBA)) diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh index 14140f6..862ff21 100755 --- a/tests/t2000-mkfs.sh +++ b/tests/t2000-mkfs.sh @@ -42,4 +42,43 @@ test_expect_success \ test_expect_success 'expect no output' '$compare out /dev/null' +N=10M +test_expect_success \ + 'create a file large enough to hold a fat32 file system' \ + 'dd if=/dev/zero of=$dev bs=$N count=1 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 if can create a partition and a filesystem in the same session. +fail=0 +cat <<EOF >in || fail=1 +mkpart +primary +ext2 +0 +10 +mkfs +No +quit +EOF + +# create output with expected prompt +cat <<EOF > exp || fail=1 +Warning: The existing file system will be destroyed and all data on the partition will be lost. Do you want to continue? +EOF + +test_expect_success \ + 'create a partition and a filesystem in the same session' \ + 'parted ---pretend-input-tty $dev < in > out 2>&1' + +test_expect_success \ + 'normalize the actual output' \ + 'sed -n "s/.*\(Warning: The existing.*\)$/\1/p" out > out2' + +test_expect_success \ + 'check for expected prompt' '$compare out2 exp' + test_done -- 1.5.0.6 _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

