blob: 9fd2d0f13dabb5c1151d3bc03512461b93abd900 [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
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +000040 if [ $verbose -gt 0 ]; 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
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +000080verbose=0
Matt Kraai38890782001-10-30 23:11:20 +000081
Matt Kraai01d2ea92002-01-02 20:37:59 +000082if [ x"$1" = x"-v" ]; then
83 verbose=1
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +000084 export VERBOSE=$verbose
Matt Kraai01d2ea92002-01-02 20:37:59 +000085 shift
86fi
87
Matt Kraai38890782001-10-30 23:11:20 +000088if [ $# -ne 0 ]; then
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +000089 applets=$(cd $srcdir ; for i in $@; do ls ${i}* ; done)
Matt Kraai38890782001-10-30 23:11:20 +000090else
Eric Andersen7daa0762004-10-08 07:46:08 +000091 applets=$(ls $srcdir)
Matt Kraai38890782001-10-30 23:11:20 +000092fi
93
94for applet in $applets; do
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +000095 if [ "$applet" = "links" ]; then continue; fi
96 if [ "$applet" != "CVS" -a -d "$srcdir/$applet" ]; then
Matt Kraai38890782001-10-30 23:11:20 +000097 if run_applet_tests $applet; then
98 :
99 else
100 status=1
101 fi
102 fi
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +0000103 applet=$(echo "$applet" | sed -n 's/\.tests$//p')
104 if [ ${#applet} -ne 0 ]
Rob Landley16890752005-09-02 00:41:53 +0000105 then
Bernhard Reutner-Fischer23bc6472005-09-23 17:42:33 +0000106 if [ -d links ]; then
107 rm -f links/"$applet"
108 else
109 mkdir links 2> /dev/null
110 fi
Rob Landley52d2f4b2005-09-20 18:19:34 +0000111 ln -s ${bindir:-../..}/busybox links/"$applet"
Bernhard Reutner-Fischerb47a74f2005-09-23 15:44:46 +0000112 PATH="$srcdir:$PATH" COMMAND="links/$applet" \
113 "${srcdir:-.}/$applet".tests
Rob Landley16890752005-09-02 00:41:53 +0000114 if [ $? -ne 0 ]; then status=1; fi
115 fi
116
Matt Kraai38890782001-10-30 23:11:20 +0000117done
Bernhard Reutner-Fischer23bc6472005-09-23 17:42:33 +0000118rm -f links/*
119rmdir links
Matt Kraai38890782001-10-30 23:11:20 +0000120exit $status