1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
samba-mirror/ctdb/tests/scripts/run_tests
Martin Schwenke dba6c1ca77 Fix the run_tests script so that the number of columns is never 0.
Sometimes "stty size" reports 0, for example when running in a shell
under Emacs.  In this case, we just change it to 80.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit e309cb3f95efcf6cff7d7c19713d7b161a138383)
2009-07-03 17:58:38 +10:00

65 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# The ability of ctdb_test_env to take tests on the command-line is
# nice, but here we need to hack around it with that colon to reset
# the arguments that it sees.
. $(dirname $0)/ctdb_test_env :
. ctdb_test_functions.bash
usage() {
cat <<EOF
Usage: run_tests [OPTIONS] [TESTS]
EOF
exit 1
}
######################################################################
with_summary=false
temp=$(getopt -n "$prog" -o "xhs" -l help -- "$@")
[ $? != 0 ] && usage
eval set -- "$temp"
while true ; do
case "$1" in
-x) set -x; shift ;;
-s) with_summary=true ; shift ;;
--) shift ; break ;;
*) usage ;;
esac
done
######################################################################
tests_total=0
tests_passed=0
summary=""
rows=$(if tty -s ; then stty size ; else echo x 80 ; fi | sed -e 's@.* @@' -e 's@^0$@80@')
ww=$((rows - 7))
for f; do
[ -x $f ] || fail "test \"$f\" is not executable"
tests_total=$(($tests_total + 1))
if ctdb_test_run "$f" ; then
tests_passed=$(($tests_passed + 1))
t="PASSED"
else
t="FAILED"
fi
summary=$(printf "%s\n%-${ww}s%s" "$summary" "$f" "$t")
done
if $with_summary ; then
echo "$summary"
echo
echo "${tests_passed}/${tests_total} tests passed"
fi
test_exit