Contents of /trunk/mkinitrd-magellan/busybox/testsuite/runtest
Parent Directory | Revision Log
Revision 816 -
(show annotations)
(download)
Fri Apr 24 18:33:46 2009 UTC (15 years, 5 months ago) by niro
File size: 3706 byte(s)
Fri Apr 24 18:33:46 2009 UTC (15 years, 5 months ago) by niro
File size: 3706 byte(s)
-updated to busybox-1.13.4
1 | #!/bin/sh |
2 | |
3 | # Usage: |
4 | # runtest [applet1] [applet2...] |
5 | |
6 | # Helper for helpers. Oh my... |
7 | test x"$ECHO" != x"" || { |
8 | ECHO="echo" |
9 | test x"`echo -ne`" = x"" || { |
10 | # Compile and use a replacement 'echo' which understands -e -n |
11 | ECHO="$PWD/echo-ne" |
12 | test -x "$ECHO" || { |
13 | gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1 |
14 | } |
15 | } |
16 | export ECHO |
17 | } |
18 | |
19 | # Run one old-style test. |
20 | # Tests are stored in applet/testcase shell scripts. |
21 | # They are run using "sh -x -e applet/testcase". |
22 | # Option -e will make testcase stop on the first failed command. |
23 | run_applet_testcase() |
24 | { |
25 | local applet="$1" |
26 | local testcase="$2" |
27 | |
28 | local status=0 |
29 | local uc_applet=$(echo "$applet" | tr a-z A-Z) |
30 | local testname="$testcase" |
31 | |
32 | testname="${testname##*/}" # take basename |
33 | if grep "^# CONFIG_$uc_applet is not set$" "$bindir/.config" >/dev/null; then |
34 | echo "UNTESTED: $testname" |
35 | return 0 |
36 | fi |
37 | |
38 | if grep "^# FEATURE: " "$testcase" >/dev/null; then |
39 | local feature=$(sed -ne 's/^# FEATURE: //p' "$testcase") |
40 | |
41 | if grep "^# $feature is not set$" "$bindir/.config" >/dev/null; then |
42 | echo "UNTESTED: $testname" |
43 | return 0 |
44 | fi |
45 | fi |
46 | |
47 | rm -rf ".tmpdir.$applet" |
48 | mkdir -p ".tmpdir.$applet" |
49 | cd ".tmpdir.$applet" || return 1 |
50 | |
51 | # echo "Running testcase $testcase" |
52 | d="$tsdir" \ |
53 | sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1 || status=$? |
54 | if [ $status -ne 0 ]; then |
55 | echo "FAIL: $testname" |
56 | if [ x"$VERBOSE" != x ]; then |
57 | cat "$testname.stdout.txt" |
58 | fi |
59 | else |
60 | echo "PASS: $testname" |
61 | fi |
62 | |
63 | cd .. |
64 | rm -rf ".tmpdir.$applet" |
65 | |
66 | return $status |
67 | } |
68 | |
69 | # Run all old-style tests for given applet |
70 | run_oldstyle_applet_tests() |
71 | { |
72 | local applet="$1" |
73 | local status=0 |
74 | |
75 | for testcase in "$tsdir/$applet"/*; do |
76 | # switch on basename of $testcase |
77 | case "${testcase##*/}" in |
78 | .*) continue ;; # .svn, .git etc |
79 | *~) continue ;; # backup files |
80 | "CVS") continue ;; |
81 | \#*) continue ;; # CVS merge residues |
82 | *.mine) continue ;; # svn-produced junk |
83 | *.r[0-9]*) continue ;; # svn-produced junk |
84 | esac |
85 | run_applet_testcase "$applet" "$testcase" || status=1 |
86 | done |
87 | return $status |
88 | } |
89 | |
90 | |
91 | |
92 | lcwd=$(pwd) |
93 | [ x"$tsdir" != x ] || tsdir="$lcwd" |
94 | [ x"$bindir" != x ] || bindir="${lcwd%/*}" # one directory up from $lcwd |
95 | PATH="$bindir:$PATH" |
96 | |
97 | if [ x"$VERBOSE" = x ]; then |
98 | export VERBOSE= |
99 | fi |
100 | |
101 | if [ x"$1" = x"-v" ]; then |
102 | export VERBOSE=1 |
103 | shift |
104 | fi |
105 | |
106 | implemented=$( |
107 | "$bindir/busybox" 2>&1 | |
108 | while read line; do |
109 | if [ x"$line" = x"Currently defined functions:" ]; then |
110 | xargs | sed 's/,//g' |
111 | break |
112 | fi |
113 | done |
114 | ) |
115 | |
116 | applets="$implemented" |
117 | if [ $# -ne 0 ]; then |
118 | applets="$@" |
119 | fi |
120 | |
121 | # Populate a directory with links to all busybox applets |
122 | |
123 | LINKSDIR="$bindir/runtest-tempdir-links" |
124 | rm -rf "$LINKSDIR" 2>/dev/null |
125 | mkdir "$LINKSDIR" |
126 | for i in $implemented; do |
127 | ln -s "$bindir/busybox" "$LINKSDIR/$i" |
128 | done |
129 | |
130 | # Set up option flags so tests can be selective. |
131 | export OPTIONFLAGS=:$( |
132 | sed -nr 's/^CONFIG_//p' "$bindir/.config" | |
133 | sed 's/=.*//' | xargs | sed 's/ /:/g' |
134 | ) |
135 | |
136 | status=0 |
137 | for applet in $applets; do |
138 | # Any old-style tests for this applet? |
139 | if [ -d "$tsdir/$applet" ]; then |
140 | run_oldstyle_applet_tests "$applet" || status=1 |
141 | fi |
142 | |
143 | # Is this a new-style test? |
144 | if [ -f "$applet.tests" ]; then |
145 | if [ ! -h "$LINKSDIR/$applet" ]; then |
146 | # (avoiding bash'ism "${applet:0:4}") |
147 | if ! echo "$applet" | grep "^all_" >/dev/null; then |
148 | echo "SKIPPED: $applet (not built)" |
149 | continue |
150 | fi |
151 | fi |
152 | # echo "Running test $tsdir/$applet.tests" |
153 | PATH="$LINKSDIR:$tsdir:$bindir:$PATH" \ |
154 | "$tsdir/$applet.tests" || status=1 |
155 | fi |
156 | done |
157 | |
158 | # Leaving the dir makes it somewhat easier to run failed test by hand |
159 | #rm -rf "$LINKSDIR" |
160 | |
161 | if [ $status -ne 0 ] && [ x"$VERBOSE" = x ]; then |
162 | echo "Failures detected, running with -v (verbose) will give more info" |
163 | fi |
164 | exit $status |
Properties
Name | Value |
---|---|
svn:executable | * |