Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 1 | #!/bin/sh |
2 | |||||
3 | PATH=$(dirname $(pwd)):$PATH | ||||
4 | |||||
Matt Kraai | 01d2ea9 | 2002-01-02 20:37:59 +0000 | [diff] [blame] | 5 | show_result () |
6 | { | ||||
7 | local resolution=$1 | ||||
8 | local testcase=$2 | ||||
9 | local status=0 | ||||
10 | |||||
Matt Kraai | fa14471 | 2002-02-19 23:54:42 +0000 | [diff] [blame] | 11 | if [ $resolution = XPASS -o $resolution = FAIL ]; then |
Matt Kraai | 01d2ea9 | 2002-01-02 20:37:59 +0000 | [diff] [blame] | 12 | status=1 |
13 | fi | ||||
14 | |||||
15 | if [ "$verbose" -o $status -eq 1 ]; then | ||||
16 | echo "$resolution: $testcase" | ||||
17 | fi | ||||
18 | |||||
19 | return $status | ||||
20 | } | ||||
21 | |||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 22 | run_applet_testcase () |
23 | { | ||||
24 | local applet=$1 | ||||
25 | local testcase=$2 | ||||
26 | |||||
27 | local status=0 | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 28 | local X= |
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame^] | 29 | local RES= |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 30 | |
31 | local uc_applet=$(echo $applet | tr a-z A-Z) | ||||
32 | local testname=$(basename $testcase) | ||||
33 | |||||
34 | if grep -q "^# CONFIG_${uc_applet} is not set$" ../.config; then | ||||
Matt Kraai | 7c71822 | 2002-02-19 23:38:08 +0000 | [diff] [blame] | 35 | show_result UNTESTED $testname |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 36 | return 0 |
37 | fi | ||||
38 | |||||
Matt Kraai | 6b140ea | 2002-02-19 23:43:08 +0000 | [diff] [blame] | 39 | if grep -q "^# FEATURE: " $testcase; then |
40 | local feature=`sed -ne 's/^# FEATURE: //p' $testcase` | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 41 | |
42 | if grep -q "^# ${feature} is not set$" ../.config; then | ||||
Matt Kraai | 7c71822 | 2002-02-19 23:38:08 +0000 | [diff] [blame] | 43 | show_result UNTESTED $testname |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 44 | return 0 |
45 | fi | ||||
46 | fi | ||||
47 | |||||
48 | if grep -q "^# XFAIL$" $testcase; then | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 49 | X=X |
50 | fi | ||||
51 | |||||
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame^] | 52 | rm -rf tmp |
53 | mkdir -p tmp | ||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 54 | pushd tmp >/dev/null |
55 | |||||
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame^] | 56 | sh -x -e ../$testcase >.logfile.txt 2>&1 |
57 | |||||
58 | if [ $? != 0 ] ; then | ||||
59 | show_result ${X}FAIL $testname | ||||
60 | if [ "$verbose" == 1 ]; then | ||||
61 | cat .logfile.txt | ||||
62 | exit 1; | ||||
63 | fi; | ||||
Matt Kraai | 35d6042 | 2002-03-27 17:33:31 +0000 | [diff] [blame] | 64 | status=$? |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 65 | else |
Eric Andersen | c354f6e | 2004-04-06 00:41:39 +0000 | [diff] [blame^] | 66 | show_result ${X}PASS $testname |
67 | rm -f .logfile.txt | ||||
Matt Kraai | 35d6042 | 2002-03-27 17:33:31 +0000 | [diff] [blame] | 68 | status=$? |
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 69 | fi |
70 | |||||
71 | popd >/dev/null | ||||
72 | rm -rf tmp | ||||
73 | |||||
74 | return $status | ||||
75 | } | ||||
76 | |||||
77 | run_applet_tests () | ||||
78 | { | ||||
79 | local applet=$1 | ||||
80 | |||||
81 | local status=0 | ||||
82 | |||||
83 | for testcase in $applet/*; do | ||||
84 | if [ "$testcase" = "$applet/CVS" ]; then | ||||
85 | continue | ||||
86 | fi | ||||
87 | |||||
88 | if run_applet_testcase $applet $testcase; then | ||||
89 | : | ||||
90 | else | ||||
91 | status=1 | ||||
92 | fi | ||||
93 | done | ||||
94 | |||||
95 | return $status | ||||
96 | } | ||||
97 | |||||
98 | |||||
99 | status=0 | ||||
100 | |||||
Matt Kraai | 01d2ea9 | 2002-01-02 20:37:59 +0000 | [diff] [blame] | 101 | if [ x"$1" = x"-v" ]; then |
102 | verbose=1 | ||||
103 | shift | ||||
104 | fi | ||||
105 | |||||
Matt Kraai | 3889078 | 2001-10-30 23:11:20 +0000 | [diff] [blame] | 106 | if [ $# -ne 0 ]; then |
107 | applets="$@" | ||||
108 | else | ||||
109 | applets="*" | ||||
110 | fi | ||||
111 | |||||
112 | for applet in $applets; do | ||||
113 | if [ "$applet" != CVS -a -d "$applet" ]; then | ||||
114 | if run_applet_tests $applet; then | ||||
115 | : | ||||
116 | else | ||||
117 | status=1 | ||||
118 | fi | ||||
119 | fi | ||||
120 | done | ||||
121 | |||||
122 | exit $status |