busybox/shell/hush_test/run-all
Denis Vlasenko cd418a2670 hush: fix a bunch of obscure while/until/continue bugs
function                                             old     new   delta
run_list                                            1159    1214     +55
done_pipe                                            106     123     +17
done_command                                          86      98     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 84/0)               Total: 84 bytes
2009-04-06 18:08:35 +00:00

81 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
unset LANG LANGUAGE
unset LC_COLLATE
unset LC_CTYPE
unset LC_MONETARY
unset LC_MESSAGES
unset LC_NUMERIC
unset LC_TIME
unset LC_ALL
test -x hush || {
echo "No ./hush - creating a link to ../../busybox"
ln -s ../../busybox hush
}
PATH="$PWD:$PATH" # for hush and recho/zecho/printenv
export PATH
THIS_SH="$PWD/hush"
export THIS_SH
do_test()
{
test -d "$1" || return 0
d=${d%/}
# echo Running tests in directory "$1"
(
tret=0
cd "$1" || { echo "cannot cd $1!"; exit 1; }
for x in run-*; do
test -f "$x" || continue
case "$x" in
"$0"|run-minimal|run-gprof) ;;
*.orig|*~) ;;
#*) echo $x ; sh $x ;;
*)
sh "$x" >"../$1-$x.fail" 2>&1 && \
{ echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
;;
esac
done
# Many bash run-XXX scripts just do this,
# no point in duplication it all over the place
for x in *.tests; do
test -x "$x" || continue
name="${x%%.tests}"
test -f "$name.right" || continue
# echo Running test: "$x"
{
"$THIS_SH" "./$x" >"$name.xx" 2>&1
diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
} && echo "$1/$x: ok" || { echo "$1/$x: fail"; tret=1; }
done
exit ${tret}
)
}
# Main part of this script
# Usage: run-all [directories]
ret=0
if [ $# -lt 1 ]; then
# All sub directories
modules=`ls -d hush-*`
for module in $modules; do
do_test $module || ret=1
done
else
while [ $# -ge 1 ]; do
if [ -d $1 ]; then
do_test $1 || ret=1
fi
shift
done
fi
exit ${ret}