diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-13 22:23:57 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-13 22:23:57 +0000 |
commit | 8d0a734d91ff197a86ce0b8fc892e24a15783395 (patch) | |
tree | 6d120200aaec21430b677dca9559c1b09ccdf187 /testsuite | |
parent | 3d461676a90eecf584dc07317cdb52eba96aa2d9 (diff) | |
download | busybox-w32-8d0a734d91ff197a86ce0b8fc892e24a15783395.tar.gz busybox-w32-8d0a734d91ff197a86ce0b8fc892e24a15783395.tar.bz2 busybox-w32-8d0a734d91ff197a86ce0b8fc892e24a15783395.zip |
tr: more of code shrink (getopt32-ification)
runtest: cleanup. Method of getting $applets was truly bizarre
function old new delta
tr_main 655 527 -128
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/runtest | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/testsuite/runtest b/testsuite/runtest index 279f51fbd..4946cbd0d 100755 --- a/testsuite/runtest +++ b/testsuite/runtest | |||
@@ -1,9 +1,5 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | [ -n "$srcdir" ] || srcdir=$(pwd) | ||
4 | [ -n "$bindir" ] || bindir=$(dirname $(pwd)) | ||
5 | PATH=$bindir:$PATH | ||
6 | |||
7 | # Run old-style test. | 3 | # Run old-style test. |
8 | 4 | ||
9 | run_applet_testcase() | 5 | run_applet_testcase() |
@@ -35,9 +31,9 @@ run_applet_testcase() | |||
35 | mkdir -p tmp | 31 | mkdir -p tmp |
36 | pushd tmp > /dev/null | 32 | pushd tmp > /dev/null |
37 | 33 | ||
38 | d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1 || status=$? | 34 | d=$tsdir sh -x -e $testcase >.logfile.txt 2>&1 || status=$? |
39 | 35 | ||
40 | if [ $status -ne 0 ] ; then | 36 | if [ $status -ne 0 ]; then |
41 | echo FAIL: $testname | 37 | echo FAIL: $testname |
42 | if [ $verbose -gt 0 ]; then | 38 | if [ $verbose -gt 0 ]; then |
43 | cat .logfile.txt | 39 | cat .logfile.txt |
@@ -61,14 +57,11 @@ run_applet_tests() | |||
61 | 57 | ||
62 | local status=0 | 58 | local status=0 |
63 | 59 | ||
64 | for testcase in $srcdir/$applet/*; do | 60 | for testcase in $tsdir/$applet/*; do |
65 | if [ "$testcase" = "$srcdir/$applet/CVS" ]; then | 61 | if [ "$testcase" = "$tsdir/$applet/CVS" ]; then |
66 | continue | 62 | continue |
67 | fi | 63 | fi |
68 | 64 | if ! run_applet_testcase $applet $testcase; then | |
69 | if run_applet_testcase $applet $testcase; then | ||
70 | : | ||
71 | else | ||
72 | status=1 | 65 | status=1 |
73 | fi | 66 | fi |
74 | done | 67 | done |
@@ -80,64 +73,61 @@ run_applet_tests() | |||
80 | status=0 | 73 | status=0 |
81 | verbose=0 | 74 | verbose=0 |
82 | 75 | ||
76 | [ -n "$tsdir" ] || tsdir=$(pwd) | ||
77 | [ -n "$bindir" ] || bindir=$(dirname $(pwd)) | ||
78 | PATH="$bindir:$PATH" | ||
79 | |||
83 | if [ x"$1" = x"-v" ]; then | 80 | if [ x"$1" = x"-v" ]; then |
84 | verbose=1 | 81 | verbose=1 |
85 | export VERBOSE=$verbose | 82 | export VERBOSE=$verbose |
86 | shift | 83 | shift |
87 | fi | 84 | fi |
88 | 85 | ||
86 | implemented=$( | ||
87 | $bindir/busybox 2>&1 | | ||
88 | while read line; do | ||
89 | if test x"$line" = x"Currently defined functions:"; then | ||
90 | xargs | sed 's/,//g' | ||
91 | break | ||
92 | fi | ||
93 | done | ||
94 | ) | ||
95 | |||
96 | applets="$implemented" | ||
89 | if [ $# -ne 0 ]; then | 97 | if [ $# -ne 0 ]; then |
90 | applets=$(cd $srcdir ; for i in $@; do ls ${i}* ; done) | 98 | applets="$@" |
91 | else | ||
92 | applets=$(ls $srcdir) | ||
93 | fi | 99 | fi |
94 | 100 | ||
95 | # Populate a directory with links to all busybox applets | 101 | # Populate a directory with links to all busybox applets |
96 | 102 | ||
97 | LINKSDIR="$bindir/runtest-tempdir-links" | 103 | LINKSDIR="$bindir/runtest-tempdir-links" |
98 | implemented=$($bindir/busybox 2>&1 | | ||
99 | while read line | ||
100 | do | ||
101 | if test x"$line" = x"Currently defined functions:" | ||
102 | then | ||
103 | xargs | sed 's/,//g' | ||
104 | break | ||
105 | fi | ||
106 | done | ||
107 | ) | ||
108 | rm -rf "$LINKSDIR" 2>/dev/null | 104 | rm -rf "$LINKSDIR" 2>/dev/null |
109 | mkdir "$LINKSDIR" | 105 | mkdir "$LINKSDIR" |
110 | for i in $implemented | 106 | for i in $implemented; do |
111 | do | ||
112 | ln -s $bindir/busybox "$LINKSDIR"/$i | 107 | ln -s $bindir/busybox "$LINKSDIR"/$i |
113 | done | 108 | done |
114 | 109 | ||
115 | # Set up option flags so tests can be selective. | 110 | # Set up option flags so tests can be selective. |
116 | 111 | ||
117 | configfile=${bindir:-../../}/.config | 112 | configfile=${bindir}/.config |
118 | export OPTIONFLAGS=:$(echo $(sed -nr 's/^CONFIG_(.*)=.*/\1/p' $configfile) | sed 's/ /:/g') | 113 | export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_(.*)=.*/\1/p' $configfile | xargs | sed 's/ /:/g') |
119 | 114 | ||
120 | for applet in $applets; do | 115 | for applet in $applets; do |
121 | if [ "$applet" = "links" ]; then continue; fi | 116 | if [ "$applet" = "links" ]; then continue; fi |
122 | if [ "$applet" != "CVS" -a -d "$srcdir/$applet" ]; then | 117 | if [ "$applet" != "CVS" -a -d "$tsdir/$applet" ]; then |
123 | if run_applet_tests $applet; then | 118 | if ! run_applet_tests $applet; then |
124 | : | ||
125 | else | ||
126 | status=1 | 119 | status=1 |
127 | fi | 120 | fi |
128 | fi | 121 | fi |
129 | 122 | ||
130 | # Is this a new-style test? | 123 | # Is this a new-style test? |
131 | applet=$(echo "$applet" | sed -n 's/\.tests$//p') | 124 | if [ -f ${applet}.tests ]; then |
132 | if [ ${#applet} -ne 0 ] | 125 | if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ]; then |
133 | then | ||
134 | if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ] | ||
135 | then | ||
136 | echo "SKIPPED: $applet (not built)" | 126 | echo "SKIPPED: $applet (not built)" |
137 | continue | 127 | continue |
138 | fi | 128 | fi |
139 | if PATH="$LINKSDIR":$srcdir:$bindir:$PATH \ | 129 | if PATH="$LINKSDIR":$tsdir:$bindir:$PATH \ |
140 | "${srcdir:-.}/$applet".tests | 130 | "${tsdir:-.}/$applet".tests |
141 | then | 131 | then |
142 | : | 132 | : |
143 | else | 133 | else |