blob: 96703ef127f7d5ee5fad0f7b01733ee0183f2c99 [file] [log] [blame]
Denis Vlasenko1c660b42007-03-05 00:27:50 +00001#!/bin/sh
2
Denys Vlasenkobcff3a72021-09-07 18:24:08 +02003unset LANG LANGUAGE
4unset LC_COLLATE
5unset LC_CTYPE
6unset LC_MONETARY
7unset LC_MESSAGES
8unset LC_NUMERIC
9unset LC_TIME
10unset LC_ALL
11
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020012TOPDIR=`pwd`
Denis Vlasenko66d56c52008-06-05 09:07:02 +000013
Denys Vlasenkoe34dbc42017-07-24 02:49:56 +020014if 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
21fi
22if 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
28fi
29
30eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
31
Denis Vlasenko1c660b42007-03-05 00:27:50 +000032test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
33test -x recho || gcc -O2 -o recho recho.c || exit $?
34test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
35
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020036PATH="`pwd`:$PATH" # for ash and recho/zecho/printenv
Denis Vlasenko1c660b42007-03-05 00:27:50 +000037export PATH
38
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020039THIS_SH="`pwd`/ash"
Denis Vlasenko1c660b42007-03-05 00:27:50 +000040export THIS_SH
41
42do_test()
43{
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020044 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 cd "$1" || { echo "cannot cd $1!"; exit 1; }
51 for x in run-*; do
52 test -f "$x" || continue
53 case "$x" in
54 "$0"|run-minimal|run-gprof) ;;
55 *.orig|*~) ;;
56 #*) echo $x ; sh $x ;;
57 *)
58 echo -n "$1/$x:"
59 sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
60 { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
61 ;;
62 esac
63 done
64 # Many bash run-XXX scripts just do this,
65 # no point in duplication it all over the place
66 for x in *.tests; do
67 test -x "$x" || continue
68 name="${x%%.tests}"
69 test -f "$name.right" || continue
70# echo Running test: "$x"
71 echo -n "$1/$x:"
72 {
Denys Vlasenko0d7dfa92021-09-07 17:34:58 +020073 "$THIS_SH" "./$x" 2>&1 | \
74 grep -va "^ash: using fallback suid method$" >"$name.xx"
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020075 diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
76 && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
77 } && echo " ok" || echo " fail"
Denys Vlasenkobcff3a72021-09-07 18:24:08 +020078 done
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020079 )
Denis Vlasenko1c660b42007-03-05 00:27:50 +000080}
81
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020082# Main part of this script
Denis Vlasenko1c660b42007-03-05 00:27:50 +000083# Usage: run-all [directories]
84
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020085ret=0
Denis Vlasenko1c660b42007-03-05 00:27:50 +000086
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020087if [ $# -lt 1 ]; then
88 # All sub directories
89 modules=`ls -d ash-*`
90 # If you want to test ash against hush testsuite
91 # (have to copy hush_test dir to current dir first):
92 #modules=`ls -d ash-* hush_test/hush-*`
93
94 for module in $modules; do
95 do_test $module || ret=1
96 done
Denis Vlasenko1c660b42007-03-05 00:27:50 +000097else
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020098 while [ $# -ge 1 ]; do
Denis Vlasenko1c660b42007-03-05 00:27:50 +000099 if [ -d $1 ]; then
Denys Vlasenko9a8ece52017-07-06 17:59:25 +0200100 do_test $1 || ret=1
Denis Vlasenko1c660b42007-03-05 00:27:50 +0000101 fi
102 shift
Denys Vlasenko9a8ece52017-07-06 17:59:25 +0200103 done
Denis Vlasenko1c660b42007-03-05 00:27:50 +0000104fi
Denys Vlasenko9a8ece52017-07-06 17:59:25 +0200105
106exit ${ret}