blob: 983e6d184c6106aabfe48ea86253a8607b06ae9f [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
Denis Vlasenko81887e22008-02-13 18:09:56 +00005test -x ash || {
Denis Vlasenko5a867312008-07-24 19:46:38 +00006 echo "No ./ash - creating a link to ../../busybox"
7 ln -s ../../busybox ash
Denis Vlasenko81887e22008-02-13 18:09:56 +00008}
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
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020013PATH="`pwd`:$PATH" # for ash and recho/zecho/printenv
Denis Vlasenko1c660b42007-03-05 00:27:50 +000014export PATH
15
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020016THIS_SH="`pwd`/ash"
Denis Vlasenko1c660b42007-03-05 00:27:50 +000017export THIS_SH
18
19do_test()
20{
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020021 test -d "$1" || return 0
22 d=${d%/}
23# echo Running tests in directory "$1"
24 # $1 but with / replaced by # so that it can be used as filename part
25 noslash=`echo "$1" | sed 's:/:#:g'`
26 (
27 cd "$1" || { echo "cannot cd $1!"; exit 1; }
28 for x in run-*; do
29 test -f "$x" || continue
30 case "$x" in
31 "$0"|run-minimal|run-gprof) ;;
32 *.orig|*~) ;;
33 #*) echo $x ; sh $x ;;
34 *)
35 echo -n "$1/$x:"
36 sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
37 { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
38 ;;
39 esac
40 done
41 # Many bash run-XXX scripts just do this,
42 # no point in duplication it all over the place
43 for x in *.tests; do
44 test -x "$x" || continue
45 name="${x%%.tests}"
46 test -f "$name.right" || continue
47# echo Running test: "$x"
48 echo -n "$1/$x:"
49 {
50 "$THIS_SH" "./$x" >"$name.xx" 2>&1
51 diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
52 && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
53 } && echo " ok" || echo " fail"
54 done
55 )
Denis Vlasenko1c660b42007-03-05 00:27:50 +000056}
57
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020058# Main part of this script
Denis Vlasenko1c660b42007-03-05 00:27:50 +000059# Usage: run-all [directories]
60
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020061ret=0
Denis Vlasenko1c660b42007-03-05 00:27:50 +000062
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020063if [ $# -lt 1 ]; then
64 # All sub directories
65 modules=`ls -d ash-*`
66 # If you want to test ash against hush testsuite
67 # (have to copy hush_test dir to current dir first):
68 #modules=`ls -d ash-* hush_test/hush-*`
69
70 for module in $modules; do
71 do_test $module || ret=1
72 done
Denis Vlasenko1c660b42007-03-05 00:27:50 +000073else
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020074 while [ $# -ge 1 ]; do
Denis Vlasenko1c660b42007-03-05 00:27:50 +000075 if [ -d $1 ]; then
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020076 do_test $1 || ret=1
Denis Vlasenko1c660b42007-03-05 00:27:50 +000077 fi
78 shift
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020079 done
Denis Vlasenko1c660b42007-03-05 00:27:50 +000080fi
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020081
82exit ${ret}