blob: 32ff462d7c57c0fa1e5fb0a9940d566dc0511610 [file] [log] [blame]
Matt Kraai38890782001-10-30 23:11:20 +00001#!/bin/sh
2
Eric Andersen7daa0762004-10-08 07:46:08 +00003[ -n "$srcdir" ] || srcdir=$(pwd)
4[ -n "$bindir" ] || bindir=$(dirname $(pwd))
5PATH=$bindir:$PATH
Matt Kraai38890782001-10-30 23:11:20 +00006
7run_applet_testcase ()
8{
9 local applet=$1
10 local testcase=$2
11
12 local status=0
Eric Andersenc354f6e2004-04-06 00:41:39 +000013 local RES=
Matt Kraai38890782001-10-30 23:11:20 +000014
15 local uc_applet=$(echo $applet | tr a-z A-Z)
16 local testname=$(basename $testcase)
17
Eric Andersen7daa0762004-10-08 07:46:08 +000018 if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then
Eric Andersen650fe632004-04-06 11:10:30 +000019 echo UNTESTED: $testname
Matt Kraai38890782001-10-30 23:11:20 +000020 return 0
21 fi
22
Matt Kraai6b140ea2002-02-19 23:43:08 +000023 if grep -q "^# FEATURE: " $testcase; then
24 local feature=`sed -ne 's/^# FEATURE: //p' $testcase`
Matt Kraai38890782001-10-30 23:11:20 +000025
Eric Andersen7daa0762004-10-08 07:46:08 +000026 if grep -q "^# ${feature} is not set$" $bindir/.config; then
Eric Andersen650fe632004-04-06 11:10:30 +000027 echo UNTESTED: $testname
Matt Kraai38890782001-10-30 23:11:20 +000028 return 0
29 fi
30 fi
31
Eric Andersenc354f6e2004-04-06 00:41:39 +000032 rm -rf tmp
33 mkdir -p tmp
Matt Kraai38890782001-10-30 23:11:20 +000034 pushd tmp >/dev/null
35
Eric Andersen7daa0762004-10-08 07:46:08 +000036 d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1
Eric Andersenc354f6e2004-04-06 00:41:39 +000037
38 if [ $? != 0 ] ; then
Eric Andersen650fe632004-04-06 11:10:30 +000039 echo FAIL: $testname
40 if [ "$verbose" = 1 ]; then
Eric Andersenc354f6e2004-04-06 00:41:39 +000041 cat .logfile.txt
Eric Andersen650fe632004-04-06 11:10:30 +000042 #exit 1;
Eric Andersenc354f6e2004-04-06 00:41:39 +000043 fi;
Matt Kraai35d60422002-03-27 17:33:31 +000044 status=$?
Matt Kraai38890782001-10-30 23:11:20 +000045 else
Eric Andersen650fe632004-04-06 11:10:30 +000046 echo PASS: $testname
Eric Andersenc354f6e2004-04-06 00:41:39 +000047 rm -f .logfile.txt
Matt Kraai35d60422002-03-27 17:33:31 +000048 status=$?
Matt Kraai38890782001-10-30 23:11:20 +000049 fi
50
51 popd >/dev/null
52 rm -rf tmp
53
54 return $status
55}
56
57run_applet_tests ()
58{
59 local applet=$1
60
61 local status=0
62
Eric Andersen7daa0762004-10-08 07:46:08 +000063 for testcase in $srcdir/$applet/*; do
64 if [ "$testcase" = "$srcdir/$applet/CVS" ]; then
Matt Kraai38890782001-10-30 23:11:20 +000065 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
79status=0
80
Matt Kraai01d2ea92002-01-02 20:37:59 +000081if [ x"$1" = x"-v" ]; then
82 verbose=1
83 shift
84fi
85
Matt Kraai38890782001-10-30 23:11:20 +000086if [ $# -ne 0 ]; then
87 applets="$@"
88else
Eric Andersen7daa0762004-10-08 07:46:08 +000089 applets=$(ls $srcdir)
Matt Kraai38890782001-10-30 23:11:20 +000090fi
91
92for applet in $applets; do
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +000093 if [ "$applet" = "links" ]; then continue; fi
94 if [ "$applet" != "CVS" -a -d "$srcdir/$applet" ]; then
Matt Kraai38890782001-10-30 23:11:20 +000095 if run_applet_tests $applet; then
96 :
97 else
98 status=1
99 fi
100 fi
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +0000101 applet=$(echo "$applet" | sed -n 's/\.tests$//p')
102 if [ ${#applet} -ne 0 ]
Rob Landley16890752005-09-02 00:41:53 +0000103 then
Rob Landley90252bb2005-09-20 14:09:57 +0000104 mkdir links 2>/dev/null
Rob Landley16890752005-09-02 00:41:53 +0000105 rm -f links/"$applet"
Rob Landley52d2f4b2005-09-20 18:19:34 +0000106 ln -s ${bindir:-../..}/busybox links/"$applet"
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +0000107 PATH="$srcdir:$PATH" COMMAND="links/$applet" \
108 "${srcdir:-.}/$applet".tests
Rob Landley16890752005-09-02 00:41:53 +0000109 if [ $? -ne 0 ]; then status=1; fi
110 fi
111
112
Matt Kraai38890782001-10-30 23:11:20 +0000113done
114
115exit $status