blob: b0a6d1088665617598f792660a5d50e4df78b42e [file] [log] [blame]
Denis Vlasenko1c660b42007-03-05 00:27:50 +00001#!/bin/sh
2
Denis Vlasenko66d56c52008-06-05 09:07:02 +00003TOPDIR=$PWD
4
Denis Vlasenko81887e22008-02-13 18:09:56 +00005test -x ash || {
6 echo "No ./ash?! Perhaps you want to run 'ln -s ../../busybox ash'"
7 exit
8}
Denis Vlasenko1c660b42007-03-05 00:27:50 +00009test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
10test -x recho || gcc -O2 -o recho recho.c || exit $?
11test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
12
13PATH="$PWD:$PATH" # for ash and recho/zecho/printenv
14export PATH
15
16THIS_SH="$PWD/ash"
17export THIS_SH
18
19do_test()
20{
21 test -d "$1" || return 0
Denis Vlasenko0e6f6612008-02-15 15:02:15 +000022 echo do_test "$1"
Denis Vlasenko66d56c52008-06-05 09:07:02 +000023 # $1 but with / replaced by # so that it can be used as filename part
24 noslash=`echo "$1" | sed 's:/:#:g'`
Denis Vlasenko1c660b42007-03-05 00:27:50 +000025 (
26 cd "$1" || { echo "cannot cd $1!"; exit 1; }
27 for x in run-*; do
28 test -f "$x" || continue
Denis Vlasenkoc86e0522007-03-20 11:30:28 +000029 case "$x" in
Denis Vlasenko1c660b42007-03-05 00:27:50 +000030 "$0"|run-minimal|run-gprof) ;;
31 *.orig|*~) ;;
32 #*) echo $x ; sh $x ;;
33 *)
Denis Vlasenko66d56c52008-06-05 09:07:02 +000034 sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
35 { echo "$1/$x: ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo "$1/$x: fail";
Denis Vlasenko1c660b42007-03-05 00:27:50 +000036 ;;
37 esac
38 done
39 # Many bash run-XXX scripts just do this,
40 # no point in duplication it all over the place
41 for x in *.tests; do
42 test -x "$x" || continue
43 name="${x%%.tests}"
44 test -f "$name.right" || continue
45 {
46 "$THIS_SH" "./$x" >"$name.xx" 2>&1
Denis Vlasenko66d56c52008-06-05 09:07:02 +000047 diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
48 && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
Denis Vlasenko1c660b42007-03-05 00:27:50 +000049 } && echo "$1/$x: ok" || echo "$1/$x: fail"
50 done
51 )
52}
53
54# main part of this script
55# Usage: run-all [directories]
56
57if [ $# -lt 1 ]; then
58 # All sub directories
59 modules=`ls -d ash-*`
Denis Vlasenko66d56c52008-06-05 09:07:02 +000060 # If you want to test ash against hush and msh testsuites
61 # (have to copy hush_test and msh_test dirs to current dir first):
62 #modules=`ls -d ash-* hush_test/hush-* msh_test/msh-*`
Denis Vlasenko1c660b42007-03-05 00:27:50 +000063
64 for module in $modules; do
Denis Vlasenko1c660b42007-03-05 00:27:50 +000065 do_test $module
66 done
67else
68 while [ $# -ge 1 ]; do
69 if [ -d $1 ]; then
70 do_test $1
71 fi
72 shift
73 done
74fi