remove unrequired dependences
[oweals/busybox.git] / testsuite / runtest
1 #!/bin/sh
2
3 [ -n "$srcdir" ] || srcdir=$(pwd)
4 [ -n "$bindir" ] || bindir=$(dirname $(pwd))
5 PATH=$bindir:$PATH
6
7 run_applet_testcase ()
8 {
9         local applet=$1
10         local testcase=$2
11
12         local status=0
13         local RES=
14
15         local uc_applet=$(echo $applet | tr a-z A-Z)
16         local testname=$(basename $testcase)
17
18         if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then
19                 echo UNTESTED: $testname
20                 return 0
21         fi
22
23         if grep -q "^# FEATURE: " $testcase; then
24                 local feature=`sed -ne 's/^# FEATURE: //p' $testcase`
25
26                 if grep -q "^# ${feature} is not set$" $bindir/.config; then
27                         echo UNTESTED: $testname
28                         return 0
29                 fi
30         fi
31
32         rm -rf tmp
33         mkdir -p tmp
34         pushd tmp >/dev/null
35
36         d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1
37
38         if [ $? != 0 ] ; then
39                 echo FAIL: $testname
40                 if [ "$verbose" = 1 ]; then
41                         cat .logfile.txt
42                         #exit 1;
43                 fi;
44                 status=$?
45         else
46                 echo PASS: $testname
47                 rm -f .logfile.txt
48                 status=$?
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
63         for testcase in $srcdir/$applet/*; do
64                 if [ "$testcase" = "$srcdir/$applet/CVS" ]; then
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
80
81 if [ x"$1" = x"-v" ]; then
82         verbose=1
83         shift
84 fi
85
86 if [ $# -ne 0 ]; then
87         applets="$@"
88 else
89         applets=$(ls $srcdir)
90 fi
91
92 for applet in $applets; do
93         if [ "$applet" != CVS -a -d "$srcdir/$applet" ]; then
94                 if run_applet_tests $applet; then
95                         :
96                 else
97                         status=1
98                 fi
99         fi
100         applet=`echo "$applet" | sed -n 's/\.tests$//p'`
101         if [ ${#applet} != 0 ]
102         then
103                 rm -f links/"$applet"
104                 ln -s ../../busybox links/"$applet"
105                 PATH=links:$PATH ./"$applet".tests
106                 if [ $? -ne 0 ]; then status=1; fi
107         fi
108
109
110 done
111
112 exit $status