[PATCH] tests: use "compare", not "$compare"

Jim Meyering meyering at redhat.com
Mon Feb 16 16:58:50 UTC 2009


* test-lib.sh (compare): Define "compare" as a function, not a variable.
* tests/t*.sh: use "compare", not "$compare"
---
 tests/t0000-basic.sh               |    6 +++---
 tests/t0100-print.sh               |    2 +-
 tests/t1000-mkpartfs.sh            |    8 ++++----
 tests/t1100-busy-label.sh          |    6 +++---
 tests/t1500-small-ext2.sh          |    8 ++++----
 tests/t2000-mkfs.sh                |   12 ++++++------
 tests/t2100-mkswap.sh              |    8 ++++----
 tests/t2200-dos-label-recog.sh     |    6 +++---
 tests/t3000-constraints.sh         |    2 +-
 tests/t3100-resize-ext2-partion.sh |    6 +++---
 tests/t4000-sun-raid-type.sh       |   10 +++++-----
 tests/t4200-partprobe.sh           |    4 ++--
 tests/t5000-tags.sh                |    2 +-
 tests/t6000-dm.sh                  |    8 ++++----
 tests/t7000-scripting.sh           |    4 ++--
 tests/t8000-loop.sh                |    4 ++--
 tests/test-lib.sh                  |    6 +++---
 17 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index 202a70b..4d7f2ee 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -41,7 +41,7 @@ test_expect_success \
 test_expect_success \
     'run parted -s FILE mklabel msdos' \
     'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 # ----------------------------------------------
 # Now, ensure that a simple mklabel command succeeds.
@@ -62,7 +62,7 @@ test_expect_success \

 test_expect_success \
     'check its "interactive" output' \
-    '$compare out exp 1>&2'
+    'compare out exp 1>&2'

 test_expect_success 'create interactive input' 'printf "y\n\n" > in'

@@ -94,6 +94,6 @@ test_expect_success \

 test_expect_success \
     'check its output -- slightly different here, due to prompts' \
-    '$compare out exp'
+    'compare out exp'

 test_done
diff --git a/tests/t0100-print.sh b/tests/t0100-print.sh
index a765a90..7dd2618 100755
--- a/tests/t0100-print.sh
+++ b/tests/t0100-print.sh
@@ -60,6 +60,6 @@ test_expect_success \
     'test $fail =3D 0 &&
      mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'

-test_expect_success 'check for expected output' '$compare out exp'
+test_expect_success 'check for expected output' 'compare out exp'

 test_done
diff --git a/tests/t1000-mkpartfs.sh b/tests/t1000-mkpartfs.sh
index f57a330..c10b49c 100755
--- a/tests/t1000-mkpartfs.sh
+++ b/tests/t1000-mkpartfs.sh
@@ -29,7 +29,7 @@ test_expect_success \
 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_expect_success 'expect no output' 'compare out /dev/null'

 # Expect parted's mkpartfs command to fail.
 test_expect_failure \
@@ -42,7 +42,7 @@ test_expect_success \

 test_expect_success \
     'check for expected failure diagnostic' \
-    '$compare out exp'
+    'compare out exp'

 test_expect_success 'clean up, preparing for next test' 'rm $dev out'

@@ -57,12 +57,12 @@ test_expect_success \
 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_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'create an msdos file system' \
     'parted -s $dev mkpartfs primary fat32 1 40 > out 2>&1'

-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 test_done
diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh
index 6ed0334..cc9e8e2 100755
--- a/tests/t1100-busy-label.sh
+++ b/tests/t1100-busy-label.sh
@@ -29,7 +29,7 @@ test_expect_success \
     'dd if=3D/dev/zero "of=3D$dev" bs=3D1k count=3D1 2> /dev/null &&
      parted -s "$dev" mklabel msdos                > out 2>&1 &&
      parted -s "$dev" mkpartfs primary fat32 1 40 >> out 2>&1'
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 mount_point=3D"`pwd`/mnt"

@@ -55,7 +55,7 @@ test_expect_success \
     'echo "Error: Partition(s) on $dev are being used." > exp'
 test_expect_success \
     'check for expected failure diagnostic' \
-    '$compare out exp'
+    'compare out exp'

 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
 # Now, test it in interactive mode.
@@ -80,6 +80,6 @@ test_expect_success \

 test_expect_success \
     'check for expected failure diagnostic' \
-    '$compare out exp'
+    'compare out exp'

 test_done
diff --git a/tests/t1500-small-ext2.sh b/tests/t1500-small-ext2.sh
index 6e1ac9f..d2e2ef6 100755
--- a/tests/t1500-small-ext2.sh
+++ b/tests/t1500-small-ext2.sh
@@ -33,12 +33,12 @@ test_expect_failure \
 test_expect_success \
     'check for expected diagnostic' '
     echo Error: File system too small for ext2. > exp &&
-    $compare out exp'
+    compare out exp'

 test_expect_success \
     'create the smallest ext2 partition' '
     parted -s $dev mkpartfs primary ext2 10KB 29696B > out 2>&1
-    $compare out /dev/null'
+    compare out /dev/null'

 # Restore $dev to initial state by writing 1KB of zeroes at the beginnin=
g.
 # Then relabel.
@@ -50,13 +50,13 @@ test_expect_success \
 test_expect_success \
     'create another ext2 file system (this would fail for parted-1.8.7)'=
 '
     parted -s $dev mkpartfs primary ext2 2 10 > out 2>&1'
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'create a smaller one; this would succeed for parted-1.8.7' '
     dd if=3D/dev/zero of=3D$dev bs=3D1K count=3D1 conv=3Dnotrunc 2> /dev=
/null &&
     parted -s $dev mklabel msdos &&
     parted -s $dev mkpartfs primary ext2 2 9 > out 2>&1'
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 test_done
diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh
index ab0d8ed..abf8950 100755
--- a/tests/t2000-mkfs.sh
+++ b/tests/t2000-mkfs.sh
@@ -29,7 +29,7 @@ test_expect_success \
 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_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'create a partition' \
@@ -39,7 +39,7 @@ test_expect_success \
     'create an msdos file system' \
     'parted -s $dev mkfs 1 fat32 > out 2>&1'

-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 N=3D10M
 test_expect_success \
@@ -49,7 +49,7 @@ test_expect_success \
 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_expect_success 'expect no output' 'compare out /dev/null'

 # test if can create a partition and a filesystem in the same session.
 fail=3D0
@@ -77,7 +77,7 @@ test_expect_success \
     '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'
+     compare out2 exp'

 #############################################################
 # Ensure that an invalid file system type elicits a diagnostic.
@@ -103,7 +103,7 @@ test_expect_success \
     'check for expected diagnostic' \
     '{ echo "parted: invalid token: bogus"
        echo "Error: Expecting a file system type."; } > exp &&
-     $compare out exp'
+     compare out exp'

 #############################################################
 # Demonstrate 3-block-group failure for 16+MB EXT2 file system.
@@ -122,7 +122,7 @@ mkfs()
   test_expect_success \
       "try to create an ext2 file system of size $size" \
       'parted -s $dev mkpartfs primary ext2 0 ${size}B >out 2>&1'
-  test_expect_success 'check for empty output' '$compare out /dev/null'
+  test_expect_success 'check for empty output' 'compare out /dev/null'
 }


diff --git a/tests/t2100-mkswap.sh b/tests/t2100-mkswap.sh
index 148ea05..420c250 100755
--- a/tests/t2100-mkswap.sh
+++ b/tests/t2100-mkswap.sh
@@ -34,22 +34,22 @@ test_expect_success \
 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_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'create a partition' \
     'parted -s $dev mkpart primary 0 1 > out 2>&1'
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'create a linux-swap file system' \
     'parted -s $dev mkfs 1 "linux-swap(new)" > out 2>&1'
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 # Extract the byte at offset 451.  It must be 0x82, not 0x83.
 test_expect_success \
     'extract byte 451 (fs-type)' \
     'od -t x1 -An -j450 -N1 $dev > out && echo " 82" > exp'
-test_expect_success 'expect it to be 82, not 83' '$compare out exp'
+test_expect_success 'expect it to be 82, not 83' 'compare out exp'

 test_done
diff --git a/tests/t2200-dos-label-recog.sh b/tests/t2200-dos-label-recog=
.sh
index dd7b905..b4d5511 100755
--- a/tests/t2200-dos-label-recog.sh
+++ b/tests/t2200-dos-label-recog.sh
@@ -34,7 +34,7 @@ test_expect_success \
 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_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'create two partition' \
@@ -43,7 +43,7 @@ test_expect_success \
     parted -s $dev mkpart primary 41s 80s > out 2>&1

     '
-test_expect_success 'expect no output' '$compare out /dev/null'
+test_expect_success 'expect no output' 'compare out /dev/null'

 test_expect_success \
     'write "FAT" where it would cause trouble' \
@@ -57,6 +57,6 @@ test_expect_success \
     printf "1:1s:40s:40s:::;\n2:41s:80s:40s:::;\n" > exp

     '
-test_expect_success 'expect two partitions' '$compare out exp'
+test_expect_success 'expect two partitions' 'compare out exp'

 test_done
diff --git a/tests/t3000-constraints.sh b/tests/t3000-constraints.sh
index 7dc5341..881a913 100755
--- a/tests/t3000-constraints.sh
+++ b/tests/t3000-constraints.sh
@@ -47,6 +47,6 @@ test_expect_success \
     'normalize the actual output' \
     'sed "s,=0D   *=0D,,;s, $,," out > o2 && mv -f o2 out'

-test_expect_success 'check for expected output' '$compare out exp'
+test_expect_success 'check for expected output' 'compare out exp'

 test_done
diff --git a/tests/t3100-resize-ext2-partion.sh b/tests/t3100-resize-ext2=
-partion.sh
index b893e0c..59bb586 100755
--- a/tests/t3100-resize-ext2-partion.sh
+++ b/tests/t3100-resize-ext2-partion.sh
@@ -38,16 +38,16 @@ test_expect_success \
 test_expect_success \
     'run parted -s FILE mklabel msdos' \
     'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     'make an ext2 primary partition' \
     'parted -s $dev mkpartfs primary ext2 0 $ORIG_SIZE > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     'resize ext2 primary partition' \
     'parted -s $dev resize 1 0 $NEW_SIZE > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_done
diff --git a/tests/t4000-sun-raid-type.sh b/tests/t4000-sun-raid-type.sh
index 34c56ee..5e4a437 100755
--- a/tests/t4000-sun-raid-type.sh
+++ b/tests/t4000-sun-raid-type.sh
@@ -33,12 +33,12 @@ test_expect_success \
 test_expect_success \
     'label the test disk as a sun disk' \
     'parted -s $dev mklabel sun > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     'create a single partition' \
     'parted -s $dev unit s mkpart ext2 0s 50s > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     'print the partition data in machine readable format' \
@@ -48,12 +48,12 @@ test_expect_success \
 test_expect_success \
     'check for expected values for the partition' '
     printf "$exp:::;\n" > exp &&
-    $compare out exp'
+    compare out exp'

 test_expect_success \
     'set the raid flag' \
     'parted -s $dev set 1 raid >out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     'print the partition data in machine readable format again' \
@@ -63,6 +63,6 @@ test_expect_success \
 test_expect_success \
     'check for expected values (including raid flag) for the partition' =
'
     printf "$exp:::raid;\n" > exp &&
-    $compare out exp'
+    compare out exp'

 test_done
diff --git a/tests/t4200-partprobe.sh b/tests/t4200-partprobe.sh
index db10c49..36c15ae 100755
--- a/tests/t4200-partprobe.sh
+++ b/tests/t4200-partprobe.sh
@@ -57,9 +57,9 @@ test_expect_success \
     "ensure that partprobe succeeds and produces no output" \
     '
     partprobe -s $dev > out 2>err &&
-    $compare err /dev/null &&
+    compare err /dev/null &&
     echo "$dev: dvh partitions 9 <17>" > exp &&
-    $compare out exp
+    compare out exp
     '

 test_done
diff --git a/tests/t5000-tags.sh b/tests/t5000-tags.sh
index 3096123..bb4c6d3 100755
--- a/tests/t5000-tags.sh
+++ b/tests/t5000-tags.sh
@@ -77,6 +77,6 @@ test_expect_success \
     'test $fail =3D 0 &&
      mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'

-test_expect_success 'check for expected output' '$compare out exp'
+test_expect_success 'check for expected output' 'compare out exp'

 test_done
diff --git a/tests/t6000-dm.sh b/tests/t6000-dm.sh
index db139df..bda600b 100755
--- a/tests/t6000-dm.sh
+++ b/tests/t6000-dm.sh
@@ -62,7 +62,7 @@ test_expect_success \
 test_expect_success \
     'run parted -s "$dev" mklabel msdos' \
     'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     "determine the map type" \
@@ -86,7 +86,7 @@ test_expect_success \

 test_expect_success \
     'check its output' \
-    '$compare out exp'
+    'compare out exp'

 #
 # Multipath Map
@@ -101,7 +101,7 @@ test_expect_success \
 test_expect_success \
     'run parted -s "$dev" mklabel msdos' \
     'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_success \
     "determine the map type" \
@@ -125,6 +125,6 @@ test_expect_success \

 test_expect_success \
     'check its output' \
-    '$compare out exp'
+    'compare out exp'

 test_done
diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index ba4ddc4..fed3649 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -43,7 +43,7 @@ for mkpart in mkpart mkpartfs; do

   test_expect_success \
       'Compare the real error and the expected one' \
-      '$compare out errS'
+      'compare out errS'

   # Test mkpart/mkpartfsin interactive mode.
   test_expect_success \
@@ -65,7 +65,7 @@ for mkpart in mkpart mkpartfs; do

   test_expect_success \
       'Compare the real error and the expected one' \
-      '$compare out errI'
+      'compare out errI'

 done
 test_done
diff --git a/tests/t8000-loop.sh b/tests/t8000-loop.sh
index 016c715..b7d39b8 100755
--- a/tests/t8000-loop.sh
+++ b/tests/t8000-loop.sh
@@ -42,7 +42,7 @@ test_expect_success \
 test_expect_success \
     'run parted -s "$d1" mklabel msdos' \
     'parted -s $d1 mklabel msdos > out 2>&1'
-test_expect_success 'check for empty output' '$compare out /dev/null'
+test_expect_success 'check for empty output' 'compare out /dev/null'

 test_expect_failure \
     'run parted -s "$d1" mkpart primary 1 10' \
@@ -50,6 +50,6 @@ test_expect_failure \
 test_expect_success 'prepare actual/expected output' \
     'emit_expected_diagnostic > exp &&
      cut -b1-64 out > k && mv k out'
-test_expect_success 'check for expected output' '$compare exp out'
+test_expect_success 'check for expected output' 'compare exp out'

 test_done
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 3a9a815..7fa81ce 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -311,9 +311,9 @@ trap '(exit $?); exit $?' 1 2 13 15
 cd "$test_dir_rand_" || error "failed to cd to $test_dir_rand_"

 if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
-  compare=3D'diff -u'
+  compare() { diff -u "$@"; }
 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; the=
n
-  compare=3D'cmp -s'
+  compare() { cmp -s "$@"; }
 else
-  compare=3Dcmp
+  compare() { cmp "$@"; }
 fi
--
1.6.2.rc0.264.g60787



More information about the parted-devel mailing list