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
22 # The command line parsing is ugly and should be improved.
31 # The testing function
37 echo "Test $1 has the wrong number of arguments" >&2
42 echo -ne "$3" > expected
44 echo -n -e "$5" | eval "$COMMAND $2" > actual
47 cmp expected actual > /dev/null
50 FAILCOUNT=$[$FAILCOUNT+1]
54 diff -u expected actual
59 rm -f input expected actual