Debian Codegraph @

shell/ash_test/run-all

raw symbols SCIP
1 #!/bin/sh
2
3 unset LANG LANGUAGE
4 unset LC_COLLATE
5 unset LC_CTYPE
6 unset LC_MONETARY
7 unset LC_MESSAGES
8 unset LC_NUMERIC
9 unset LC_TIME
10 unset LC_ALL
11
12 TOPDIR=`pwd`
13
14 if test ! -x ash; then
15 if test ! -x ../../busybox; then
16 echo "Can't run tests. Put ash binary into this directory (`pwd`)"
17 exit 1
18 fi
19 echo "No ./ash - creating a link to ../../busybox"
20 ln -s ../../busybox ash
21 fi
22 if test ! -f .config; then
23 if test ! -f ../../.config; then
24 echo "Missing .config file"
25 exit 1
26 fi
27 cp ../../.config . || exit 1
28 fi
29
30 eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
31
32 test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
33 test -x recho || gcc -O2 -o recho recho.c || exit $?
34 test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
35
36 PATH="`pwd`:$PATH" # for ash and recho/zecho/printenv
37 export PATH
38
39 THIS_SH="`pwd`/ash"
40 export THIS_SH
41
42 do_test()
43 {
44 test -d "$1" || return 0
45 d=${d%/}
46 # echo Running tests in directory "$1"
47 # $1 but with / replaced by # so that it can be used as filename part
48 noslash=`echo "$1" | sed 's:/:#:g'`
49 (
50 tret=0
51 cd "$1" || { echo "cannot cd $1!"; exit 1; }
52 for x in run-*; do
53 test -f "$x" || continue
54 case "$x" in
55 "$0"|run-minimal|run-gprof) ;;
56 *.orig|*~) ;;
57 #*) echo $x ; sh $x ;;
58 *)
59 echo -n "$1/$x:"
60 sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
61 { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
62 ;;
63 esac
64 done
65 # Many bash run-XXX scripts just do this,
66 # no point in duplication it all over the place
67 for x in *.tests; do
68 test -x "$x" || continue
69 name="${x%%.tests}"
70 test -f "$name.right" || continue
71 # echo Running test: "$x"
72 echo -n "$1/$x:"
73 (
74 "$THIS_SH" "./$x" 2>&1 | \
75 grep -va "^ash: using fallback suid method$" >"$name.xx"
76 r=$?
77 # filter C library differences
78 sed -i \
79 -e "/: invalid option /s:'::g" \
80 "$name.xx"
81 test $r -eq 77 && rm -f "$TOPDIR/$noslash-$x.fail" && exit 77
82 diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
83 && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
84 )
85 case $? in
86 0) echo " ok";;
87 77) echo " skip (feature disabled)";;
88 *) echo " fail ($?)"; tret=1;;
89 esac
90 done
91 exit $tret
92 )
93 }
94
95 # Main part of this script
96 # Usage: run-all [directories]
97
98 ret=0
99
100 if [ $# -lt 1 ]; then
101 # All sub directories
102 modules=`ls -d ash-*`
103 # If you want to test ash against hush testsuite
104 # (have to copy hush_test dir to current dir first):
105 #modules=`ls -d ash-* hush_test/hush-*`
106
107 for module in $modules; do
108 do_test $module || ret=1
109 done
110 else
111 while [ $# -ge 1 ]; do
112 if [ -d $1 ]; then
113 do_test $1 || ret=1
114 fi
115 shift
116 done
117 fi
118
119 exit $ret