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