1 # Simple test harness infrastructurei for BusyBox
3 # Copyright 2005 by Rob Landley
5 # License is GPLv2, see LICENSE in the busybox tarball for full license text.
7 # The "testing" function uses one environment variable:
8 # COMMAND = command to execute
10 # The function takes five arguments:
11 # $1) Description to display when running command
12 # $2) Command line arguments to command"
13 # $3) Expected result (on stdout)"
14 # $4) Data written to file "input"
15 # $5) Data written to stdin
17 # The exit value of testing is the exit value of the command it ran.
19 # The environment variable "FAILCOUNT" contains a cumulative total of the
27 -v|--verbose) verbose=1; shift;;
28 -d|--debug) debug=1; shift;;
29 -f|--force) force=1; shift;;
31 -*) echo "Unknown option '$x'"; exit 1;;
36 if [ -n "$VERBOSE" ] ; then
39 if [ -n "$DEBUG" ] ; then
49 local uc_what=$(echo ${1?} | tr a-z A-Z)
50 grep -q "^[ ]*CONFIG_${uc_what}" ${bindir:-..}/.config || \
51 grep -q "^[ ]*BB_CONFIG_${uc_what}" ${bindir:-..}/.config
55 # The testing function
61 echo "Test $1 has the wrong number of arguments" >&2
65 if [ $debug -eq 1 ] ; then
69 if [ -n "$_BB_CONFIG_DEP" ] && [ ${force} -eq 0 ]
71 if ! config_is_set "$_BB_CONFIG_DEP"
78 echo -ne "$3" > expected
80 echo -n -e "$5" | eval "$COMMAND $2" > actual
83 cmp expected actual > /dev/null
90 diff -u expected actual
95 rm -f input expected actual
97 if [ $debug -eq 1 ] ; then