]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: shell script portability and clean-up
authorJim Meyering <meyering@redhat.com>
Wed, 24 Mar 2010 08:05:27 +0000 (09:05 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 24 Mar 2010 08:23:01 +0000 (09:23 +0100)
* tests/test-lib.sh: "echo -n" is not portable.  Use printf instead.
Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient).
Remove uses of tests' -a operator; it is not portable.
Instead, use "test cond && test cond2".
* tests/schematestutils.sh: Replace use of test's -a.

tests/schematestutils.sh
tests/test-lib.sh

index 301b9ebc649bc87ca889431019714ec2e039820b..f1728578ee7d016d5f66a51a10775fefdd981279 100644 (file)
@@ -21,7 +21,7 @@ do
     ret=$?
 
     test_result $n $(basename $(dirname $xml))"/"$(basename $xml) $ret
-    if test "$verbose" = "1" -a $ret != 0 ; then
+    if test "$verbose" = "1" && test $ret != 0 ; then
         echo -e "$cmd\n$result"
     fi
     if test "$ret" != 0 ; then
index 57fd43893dc44b79858585200ae8687dc44800dd..28b830eb31f738862a3d1985f71e432de36a2ac2 100644 (file)
@@ -19,7 +19,7 @@ test_intro()
   name=$1
   if test "$verbose" = "0" ; then
     echo "TEST: $name"
-    echo -n "      "
+    printf "      "
   fi
 }
 
@@ -29,15 +29,15 @@ test_result()
   name=$2
   status=$3
   if test "$verbose" = "0" ; then
-    mod=`eval "expr \( $counter - 1 \) % 40"`
-    if test "$counter" != 1 -a "$mod" = 0 ; then
-        printf " %-3d\n" `eval "expr $counter - 1"`
-        echo -n "      "
+    mod=`expr \( $counter + 40 - 1 \) % 40`
+    if test "$counter" != 1 && test "$mod" = 0 ; then
+        printf " %-3d\n" `expr $counter - 1`
+        printf "      "
     fi
     if test "$status" = "0" ; then
-        echo -n "."
+        printf "."
     else
-        echo -n "!"
+        printf "!"
     fi
   else
     if test "$status" = "0" ; then
@@ -54,11 +54,11 @@ test_final()
   status=$2
 
   if test "$verbose" = "0" ; then
-    mod=`eval "expr \( $counter + 1 \) % 40"`
-    if test "$mod" != "0" -a "$mod" != "1" ; then
+    mod=`expr \( $counter + 1 \) % 40`
+    if test "$mod" != "0" && test "$mod" != "1" ; then
       for i in `seq $mod 40`
       do
-        echo -n " "
+        printf " "
       done
     fi
     if test "$status" = "0" ; then