From: Jim Meyering Date: Fri, 20 Jun 2008 12:04:30 +0000 (+0200) Subject: tests: factor out duplication X-Git-Tag: android-x86-4.4-r1~872 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=bd74aaf75b6fd2544f9ded6943601092c6cff592;p=android-x86%2Fexternal-parted.git tests: factor out duplication * tests/t7000-scripting.sh: Use a loop rather than two copies of each of 7 tests. --- diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh index 72f17d6..ba4ddc4 100755 --- a/tests/t7000-scripting.sh +++ b/tests/t7000-scripting.sh @@ -30,74 +30,42 @@ EOF sed s/Error/Warning/ errS printf 'Is this still acceptable to you?\nYes/No?'; } >> errI || fail=1 -# Test for mkpart in scripting mode -test_expect_success \ - 'Create the test file' \ - 'dd if=/dev/zero of=testfile bs=512 count=100 2> /dev/null' - -test_expect_failure \ - 'Test the scripting mode of mkpart' \ - 'parted -s testfile "mklabel gpt mkpart primary ext3 1s -1s" > outS' - -test_expect_success \ - 'Compare the real error and the expected one' \ - '$compare outS errS' - -# Test for mkpart in interactive mode. -test_expect_success \ - 'Create the test file' \ - ' - rm testfile ; - dd if=/dev/zero of=testfile bs=512 count=100 2> /dev/null - ' -test_expect_failure \ - 'Test the interactive mode of mkpart' \ - 'echo n | \ - parted ---pretend-input-tty testfile \ - "mklabel gpt mkpart primary ext3 1s -1s" > out - ' -# We have to format the output before comparing. -test_expect_success \ - 'normalize the actual output' \ - 'sed "s, * ,,;s, $,," out > o2 && mv -f o2 out' - -test_expect_success \ - 'Compare the real error and the expected one' \ - '$compare out errI' - -# Test for mkpartfs in scripting mode -test_expect_success \ - 'Create the test file' \ - 'dd if=/dev/zero of=testfile bs=512 count=100 2> /dev/null' - -test_expect_failure \ - 'Test the scripting mode of mkpartfs' \ - 'parted -s testfile "mklabel gpt mkpartfs primary ext3 1s -1s" > outS' - -test_expect_success \ - 'Compare the real error and the expected one' \ - '$compare outS errS' - -# Test for mkpartfs in interactive mode. -test_expect_success \ - 'Create the test file' \ - ' - rm testfile ; - dd if=/dev/zero of=testfile bs=512 count=100 2> /dev/null - ' -test_expect_failure \ - 'Test the interactive mode of mkpartfs' \ - 'echo n | \ - parted ---pretend-input-tty testfile \ - "mklabel gpt mkpartfs primary ext3 1s -1s" > out - ' -# We have to format the output before comparing. -test_expect_success \ - 'normalize the actual output' \ - 'sed "s, * ,,;s, $,," out > o2 && mv -f o2 out' - -test_expect_success \ - 'Compare the real error and the expected one' \ - '$compare out errI' - +for mkpart in mkpart mkpartfs; do + + # Test for mkpart/mkpartfs in scripting mode + test_expect_success \ + 'Create the test file' \ + 'dd if=/dev/zero of=testfile bs=512 count=100 2> /dev/null' + + test_expect_failure \ + "Test the scripting mode of $mkpart" \ + 'parted -s testfile -- mklabel gpt '$mkpart' primary ext3 1s -1s > out' + + test_expect_success \ + 'Compare the real error and the expected one' \ + '$compare out errS' + + # Test mkpart/mkpartfsin interactive mode. + test_expect_success \ + 'Create the test file' \ + ' + rm testfile ; + dd if=/dev/zero of=testfile bs=512 count=100 2> /dev/null + ' + test_expect_failure \ + "Test the interactive mode of $mkpart" \ + 'echo n | \ + parted ---pretend-input-tty testfile \ + "mklabel gpt '$mkpart' primary ext3 1s -1s" > out + ' + # We have to format the output before comparing. + test_expect_success \ + 'normalize the actual output' \ + 'sed "s, * ,,;s, $,," out > o2 && mv -f o2 out' + + test_expect_success \ + 'Compare the real error and the expected one' \ + '$compare out errI' + +done test_done