Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/testsuite/testing.sh

    r1765 r2725  
    1 # Simple test harness infrastructurei for BusyBox
     1# Simple test harness infrastructure for BusyBox
    22#
    33# Copyright 2005 by Rob Landley
     
    55# License is GPLv2, see LICENSE in the busybox tarball for full license text.
    66
    7 # This file defines two functions, "testing" and "optionflag"
     7# This file defines two functions, "testing" and "optional"
     8# and a couple more...
    89
    910# The following environment variables may be set to enable optional behavior
     
    1112#    VERBOSE - Print the diff -u of each failed test case.
    1213#    DEBUG - Enable command tracing.
    13 #    SKIP - do not perform this test (this is set by "optionflag")
     14#    SKIP - do not perform this test (this is set by "optional")
    1415#
    1516# The "testing" function takes five arguments:
    16 #   $1) Description to display when running command
    17 #   $2) Command line arguments to command
    18 #   $3) Expected result (on stdout)
    19 #   $4) Data written to file "input"
    20 #   $5) Data written to stdin
     17#   $1) Test description
     18#   $2) Command(s) to run. May have pipes, redirects, etc
     19#   $3) Expected result on stdout
     20#   $4) Data to be written to file "input"
     21#   $5) Data to be written to stdin
    2122#
    22 # The exit value of testing is the exit value of the command it ran.
     23# The exit value of testing is the exit value of $2 it ran.
    2324#
    2425# The environment variable "FAILCOUNT" contains a cumulative total of the
     
    2627
    2728# The "optional" function is used to skip certain tests, ala:
    28 #   optionflag CONFIG_FEATURE_THINGY
     29#   optional FEATURE_THINGY
    2930#
    3031# The "optional" function checks the environment variable "OPTIONFLAGS",
     
    3637export SKIP=
    3738
     39# Helper for helpers. Oh my...
     40
     41test x"$ECHO" != x"" || {
     42    ECHO="echo"
     43    test x"`echo -ne`" = x"" || {
     44        # Compile and use a replacement 'echo' which understands -e -n
     45        ECHO="$PWD/echo-ne"
     46        test -x "$ECHO" || {
     47            gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1
     48        }
     49    }
     50    export ECHO
     51}
     52
    3853# Helper functions
    3954
    4055optional()
    4156{
    42   option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"`
    43   # Not set?
    44   if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ]
    45   then
    46     SKIP=""
    47     return
    48   fi
    49   SKIP=1
     57    SKIP=
     58    while test "$1"; do
     59        if test x"${OPTIONFLAGS/*:$1:*/y}" != x"y"; then
     60            SKIP=1
     61            return
     62        fi
     63        shift
     64    done
    5065}
    5166
     
    5570{
    5671  NAME="$1"
    57   [ -z "$1" ] && NAME=$2
     72  [ -n "$1" ] || NAME="$2"
    5873
    5974  if [ $# -ne 5 ]
    6075  then
    61     echo "Test $NAME has the wrong number of arguments ($# $*)" >&2
    62     exit
     76    echo "Test $NAME has wrong number of arguments: $# (must be 5)" >&2
     77    exit 1
    6378  fi
    6479
    65   [ -n "$DEBUG" ] && set -x
     80  [ -z "$DEBUG" ] || set -x
    6681
    6782  if [ -n "$SKIP" ]
     
    7186  fi
    7287
    73   echo -ne "$3" > expected
    74   echo -ne "$4" > input
    75   [ -z "$VERBOSE" ] || echo "echo '$5' | $2"
    76   echo -ne "$5" | eval "$2" > actual
     88  $ECHO -ne "$3" > expected
     89  $ECHO -ne "$4" > input
     90  [ -z "$VERBOSE" ] || echo "echo -ne '$4' >input"
     91  [ -z "$VERBOSE" ] || echo "echo -ne '$5' | $2"
     92  $ECHO -ne "$5" | eval "$2" > actual
    7793  RETVAL=$?
    7894
    79   cmp expected actual >/dev/null 2>/dev/null
    80   if [ $? -ne 0 ]
     95  if cmp expected actual >/dev/null 2>/dev/null
    8196  then
    82     FAILCOUNT=$[$FAILCOUNT+1]
     97    echo "PASS: $NAME"
     98  else
     99    FAILCOUNT=$(($FAILCOUNT + 1))
    83100    echo "FAIL: $NAME"
    84     [ -n "$VERBOSE" ] && diff -u expected actual
    85   else
    86     echo "PASS: $NAME"
     101    [ -z "$VERBOSE" ] || diff -u expected actual
    87102  fi
    88103  rm -f input expected actual
    89104
    90   [ -n "$DEBUG" ] && set +x
     105  [ -z "$DEBUG" ] || set +x
    91106
    92107  return $RETVAL
     
    102117  [ $# -lt 2 ] && return
    103118
    104   echo -n .
     119  $ECHO -n .
    105120
    106121  dest=$1
     
    108123  for i in "$@"
    109124  do
    110     [ "${i:0:1}" == "/" ] || i=$(which $i)
     125    #bashism: [ "${i:0:1}" == "/" ] || i=$(which $i)
     126    i=$(which $i) # no-op for /bin/prog
    111127    [ -f "$dest/$i" ] && continue
    112128    if [ -e "$i" ]
     
    136152  # Copy utilities from command line arguments
    137153
    138   echo -n "Setup chroot"
     154  $ECHO -n "Setup chroot"
    139155  mkchroot tmpdir4chroot $*
    140156  echo
     
    152168  rmdir tmpdir4chroot
    153169}
    154 
Note: See TracChangeset for help on using the changeset viewer.