Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 1 | #!/bin/sh |
2 | |||||
Eric Andersen | 7daa076 | 2004-10-08 07:46:08 +0000 | [diff] [blame] | 3 | [ -n "$srcdir" ] || srcdir=$(pwd) |
4 | [ -n "$bindir" ] || bindir=$(dirname $(pwd)) | ||||
5 | PATH=$bindir:$PATH | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 6 | |
7 | run_applet_testcase () | ||||
8 | { | ||||
9 | local applet=$1 | ||||
10 | local testcase=$2 | ||||
11 | |||||
12 | local status=0 | ||||
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame] | 13 | local RES= |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 14 | |
15 | local uc_applet=$(echo $applet | tr a-z A-Z) | ||||
16 | local testname=$(basename $testcase) | ||||
17 | |||||
Eric Andersen | 7daa076 | 2004-10-08 07:46:08 +0000 | [diff] [blame] | 18 | if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then |
Eric Andersen | 650fe63 | 2004-04-06 11:10:30 +0000 | [diff] [blame] | 19 | echo UNTESTED: $testname |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 20 | return 0 |
21 | fi | ||||
22 | |||||
Matt Kraai | 6b140ea | 2002-02-19 23:43:08 +0000 | [diff] [blame] | 23 | if grep -q "^# FEATURE: " $testcase; then |
24 | local feature=`sed -ne 's/^# FEATURE: //p' $testcase` | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 25 | |
Eric Andersen | 7daa076 | 2004-10-08 07:46:08 +0000 | [diff] [blame] | 26 | if grep -q "^# ${feature} is not set$" $bindir/.config; then |
Eric Andersen | 650fe63 | 2004-04-06 11:10:30 +0000 | [diff] [blame] | 27 | echo UNTESTED: $testname |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 28 | return 0 |
29 | fi | ||||
30 | fi | ||||
31 | |||||
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame] | 32 | rm -rf tmp |
33 | mkdir -p tmp | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 34 | pushd tmp >/dev/null |
35 | |||||
Eric Andersen | 7daa076 | 2004-10-08 07:46:08 +0000 | [diff] [blame] | 36 | d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1 |
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame] | 37 | |
38 | if [ $? != 0 ] ; then | ||||
Eric Andersen | 650fe63 | 2004-04-06 11:10:30 +0000 | [diff] [blame] | 39 | echo FAIL: $testname |
Bernhard Reutner-Fischer | e34e878 | 2005-10-06 12:48:03 +0000 | [diff] [blame] | 40 | if [ $verbose -gt 0 ]; then |
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame] | 41 | cat .logfile.txt |
Eric Andersen | 650fe63 | 2004-04-06 11:10:30 +0000 | [diff] [blame] | 42 | #exit 1; |
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame] | 43 | fi; |
Matt Kraai | 35d6042 | 2002-03-27 17:33:31 +0000 | [diff] [blame] | 44 | status=$? |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 45 | else |
Eric Andersen | 650fe63 | 2004-04-06 11:10:30 +0000 | [diff] [blame] | 46 | echo PASS: $testname |
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame] | 47 | rm -f .logfile.txt |
Matt Kraai | 35d6042 | 2002-03-27 17:33:31 +0000 | [diff] [blame] | 48 | status=$? |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 49 | fi |
50 | |||||
51 | popd >/dev/null | ||||
52 | rm -rf tmp | ||||
53 | |||||
54 | return $status | ||||
55 | } | ||||
56 | |||||
57 | run_applet_tests () | ||||
58 | { | ||||
59 | local applet=$1 | ||||
60 | |||||
61 | local status=0 | ||||
62 | |||||
Eric Andersen | 7daa076 | 2004-10-08 07:46:08 +0000 | [diff] [blame] | 63 | for testcase in $srcdir/$applet/*; do |
64 | if [ "$testcase" = "$srcdir/$applet/CVS" ]; then | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 65 | continue |
66 | fi | ||||
67 | |||||
68 | if run_applet_testcase $applet $testcase; then | ||||
69 | : | ||||
70 | else | ||||
71 | status=1 | ||||
72 | fi | ||||
73 | done | ||||
74 | |||||
75 | return $status | ||||
76 | } | ||||
77 | |||||
78 | |||||
79 | status=0 | ||||
Bernhard Reutner-Fischer | e34e878 | 2005-10-06 12:48:03 +0000 | [diff] [blame] | 80 | verbose=0 |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 81 | |
Matt Kraai | 01d2ea9 | 2002-01-02 20:37:59 +0000 | [diff] [blame] | 82 | if [ x"$1" = x"-v" ]; then |
83 | verbose=1 | ||||
Bernhard Reutner-Fischer | e34e878 | 2005-10-06 12:48:03 +0000 | [diff] [blame] | 84 | export VERBOSE=$verbose |
Matt Kraai | 01d2ea9 | 2002-01-02 20:37:59 +0000 | [diff] [blame] | 85 | shift |
86 | fi | ||||
87 | |||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 88 | if [ $# -ne 0 ]; then |
Bernhard Reutner-Fischer | e34e878 | 2005-10-06 12:48:03 +0000 | [diff] [blame] | 89 | applets=$(cd $srcdir ; for i in $@; do ls ${i}* ; done) |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 90 | else |
Eric Andersen | 7daa076 | 2004-10-08 07:46:08 +0000 | [diff] [blame] | 91 | applets=$(ls $srcdir) |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 92 | fi |
93 | |||||
Rob Landley | 48c6157 | 2005-11-07 08:50:53 +0000 | [diff] [blame^] | 94 | # Set up option flags so tests can be selective. |
95 | |||||
96 | configfile=${bindir:-../../}/.config | ||||
97 | export OPTIONFLAGS=:$(echo $(sed -nr 's/^CONFIG_(.*)=.*/\1/p' $configfile) | sed 's/ /:/') | ||||
98 | |||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 99 | for applet in $applets; do |
Bernhard Reutner-Fischer | b47a74f | 2005-09-23 15:44:46 +0000 | [diff] [blame] | 100 | if [ "$applet" = "links" ]; then continue; fi |
101 | if [ "$applet" != "CVS" -a -d "$srcdir/$applet" ]; then | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 102 | if run_applet_tests $applet; then |
103 | : | ||||
104 | else | ||||
105 | status=1 | ||||
106 | fi | ||||
107 | fi | ||||
Rob Landley | 48c6157 | 2005-11-07 08:50:53 +0000 | [diff] [blame^] | 108 | |
109 | # Is this a new-style test? | ||||
Bernhard Reutner-Fischer | b47a74f | 2005-09-23 15:44:46 +0000 | [diff] [blame] | 110 | applet=$(echo "$applet" | sed -n 's/\.tests$//p') |
111 | if [ ${#applet} -ne 0 ] | ||||
Rob Landley | 1689075 | 2005-09-02 00:41:53 +0000 | [diff] [blame] | 112 | then |
Rob Landley | 48c6157 | 2005-11-07 08:50:53 +0000 | [diff] [blame^] | 113 | appcfg=`grep -i "^# CONFIG_$applet" $configfile` |
114 | if [ -n "$appcfg" ] | ||||
115 | then | ||||
116 | echo "SKIPPED: $applet (is configured out)" | ||||
117 | continue | ||||
118 | fi | ||||
119 | # Setup environment for test. | ||||
Bernhard Reutner-Fischer | 23bc647 | 2005-09-23 17:42:33 +0000 | [diff] [blame] | 120 | if [ -d links ]; then |
121 | rm -f links/"$applet" | ||||
122 | else | ||||
123 | mkdir links 2> /dev/null | ||||
124 | fi | ||||
Rob Landley | 52d2f4b | 2005-09-20 18:19:34 +0000 | [diff] [blame] | 125 | ln -s ${bindir:-../..}/busybox links/"$applet" |
Bernhard Reutner-Fischer | b47a74f | 2005-09-23 15:44:46 +0000 | [diff] [blame] | 126 | PATH="$srcdir:$PATH" COMMAND="links/$applet" \ |
127 | "${srcdir:-.}/$applet".tests | ||||
Rob Landley | 1689075 | 2005-09-02 00:41:53 +0000 | [diff] [blame] | 128 | if [ $? -ne 0 ]; then status=1; fi |
129 | fi | ||||
130 | |||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 131 | done |
Bernhard Reutner-Fischer | 23bc647 | 2005-09-23 17:42:33 +0000 | [diff] [blame] | 132 | rm -f links/* |
133 | rmdir links | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 134 | exit $status |