OSDN Git Service

tests: factor out duplication
authorJim Meyering <meyering@redhat.com>
Fri, 20 Jun 2008 12:04:30 +0000 (14:04 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 20 Jun 2008 12:06:05 +0000 (14:06 +0200)
* tests/t7000-scripting.sh: Use a loop rather than
two copies of each of 7 tests.

tests/t7000-scripting.sh

index 72f17d6..ba4ddc4 100755 (executable)
@@ -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,\r   *\r,,;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,\r   *\r,,;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,\r   *\r,,;s, $,," out > o2 && mv -f o2 out'
+
+  test_expect_success \
+      'Compare the real error and the expected one' \
+      '$compare out errI'
+
+done
 test_done