blob: 6ba334bcee0b863e99e4cc01c7bc49f46f374b4c [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
Eric Andersen7daa0762004-10-08 07:46:08 +000093 if [ "$applet" != CVS -a -d "$srcdir/$applet" ]; then
Matt Kraai38890782001-10-30 23:11:20 +000094 if run_applet_tests $applet; then
95 :
96 else
97 status=1
98 fi
99 fi
100done
101
102exit $status