blob: caf03357715b49e20e0e75bf6aa8835b25ae0ec6 [file] [log] [blame]
Denis Vlasenko1c660b42007-03-05 00:27:50 +00001#!/bin/sh
2
Denys Vlasenko9a8ece52017-07-06 17:59:25 +02003TOPDIR=`pwd`
Denis Vlasenko66d56c52008-06-05 09:07:02 +00004
Denys Vlasenkoe34dbc42017-07-24 02:49:56 +02005if test ! -x ash; then
6 if test ! -x ../../busybox; then
7 echo "Can't run tests. Put ash binary into this directory (`pwd`)"
8 exit 1
9 fi
10 echo "No ./ash - creating a link to ../../busybox"
11 ln -s ../../busybox ash
12fi
13if test ! -f .config; then
14 if test ! -f ../../.config; then
15 echo "Missing .config file"
16 exit 1
17 fi
18 cp ../../.config . || exit 1
19fi
20
21eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
22
Denis Vlasenko1c660b42007-03-05 00:27:50 +000023test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
24test -x recho || gcc -O2 -o recho recho.c || exit $?
25test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
26
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020027PATH="`pwd`:$PATH" # for ash and recho/zecho/printenv
Denis Vlasenko1c660b42007-03-05 00:27:50 +000028export PATH
29
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020030THIS_SH="`pwd`/ash"
Denis Vlasenko1c660b42007-03-05 00:27:50 +000031export THIS_SH
32
33do_test()
34{
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020035 test -d "$1" || return 0
36 d=${d%/}
37# echo Running tests in directory "$1"
38 # $1 but with / replaced by # so that it can be used as filename part
39 noslash=`echo "$1" | sed 's:/:#:g'`
40 (
41 cd "$1" || { echo "cannot cd $1!"; exit 1; }
42 for x in run-*; do
43 test -f "$x" || continue
44 case "$x" in
45 "$0"|run-minimal|run-gprof) ;;
46 *.orig|*~) ;;
47 #*) echo $x ; sh $x ;;
48 *)
49 echo -n "$1/$x:"
50 sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
51 { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
52 ;;
53 esac
54 done
55 # Many bash run-XXX scripts just do this,
56 # no point in duplication it all over the place
57 for x in *.tests; do
58 test -x "$x" || continue
59 name="${x%%.tests}"
60 test -f "$name.right" || continue
61# echo Running test: "$x"
62 echo -n "$1/$x:"
63 {
64 "$THIS_SH" "./$x" >"$name.xx" 2>&1
65 diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
66 && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
67 } && echo " ok" || echo " fail"
68 done
69 )
Denis Vlasenko1c660b42007-03-05 00:27:50 +000070}
71
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020072# Main part of this script
Denis Vlasenko1c660b42007-03-05 00:27:50 +000073# Usage: run-all [directories]
74
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020075ret=0
Denis Vlasenko1c660b42007-03-05 00:27:50 +000076
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020077if [ $# -lt 1 ]; then
78 # All sub directories
79 modules=`ls -d ash-*`
80 # If you want to test ash against hush testsuite
81 # (have to copy hush_test dir to current dir first):
82 #modules=`ls -d ash-* hush_test/hush-*`
83
84 for module in $modules; do
85 do_test $module || ret=1
86 done
Denis Vlasenko1c660b42007-03-05 00:27:50 +000087else
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020088 while [ $# -ge 1 ]; do
Denis Vlasenko1c660b42007-03-05 00:27:50 +000089 if [ -d $1 ]; then
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020090 do_test $1 || ret=1
Denis Vlasenko1c660b42007-03-05 00:27:50 +000091 fi
92 shift
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020093 done
Denis Vlasenko1c660b42007-03-05 00:27:50 +000094fi
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020095
96exit ${ret}