ifupdown: save some 100+ bytes of code in addstr()
[oweals/busybox.git] / testsuite / testing.sh
index bec5976e1e4439befc076e323a6496d7f66adf00..e253e1aa6baffbbb8c1fb0fd8a7a98717697dbb7 100755 (executable)
@@ -6,9 +6,6 @@
 
 # This file defines two functions, "testing" and "optionflag"
 
-# The "testing" function must have the following environment variable set:
-#    COMMAND = command to execute
-#
 # The following environment variables may be set to enable optional behavior
 # in "testing":
 #    VERBOSE - Print the diff -u of each failed test case.
@@ -17,8 +14,8 @@
 #
 # The "testing" function takes five arguments:
 #      $1) Description to display when running command
-#      $2) Command line arguments to command"
-#      $3) Expected result (on stdout)"
+#      $2) Command line arguments to command
+#      $3) Expected result (on stdout)
 #      $4) Data written to file "input"
 #      $5) Data written to stdin
 #
@@ -75,7 +72,7 @@ testing ()
 
   echo -ne "$3" > expected
   echo -ne "$4" > input
-  [ -z "$VERBOSE" ] || echo "echo '$5' | $COMMAND $2"
+  [ -z "$VERBOSE" ] || echo "echo '$5' | $2"
   echo -ne "$5" | eval "$2" > actual
   RETVAL=$?
 
@@ -110,13 +107,16 @@ function mkchroot
   shift
   for i in "$@"
   do
-    if [ "${i:0:1}" == "/" ]
+    [ "${i:0:1}" == "/" ] || i=$(which $i)
+    [ -f "$dest/$i" ] && continue
+    if [ -e "$i" ]
     then
-      [ -f "$dest/$i" ] && continue
       d=`echo "$i" | grep -o '.*/'` &&
       mkdir -p "$dest/$d" &&
       cat "$i" > "$dest/$i" &&
       chmod +x "$dest/$i"
+    else
+      echo "Not found: $i"
     fi
     mkchroot "$dest" $(ldd "$i" | egrep -o '/.* ')
   done