Magellan Linux

Annotation of /tags/mkinitrd-6_3_1/busybox/testsuite/runtest

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *