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