diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2009-11-30 19:01:31 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2010-01-15 16:28:05 +0000 |
commit | e8ac4a79f17b741e46980d1db8ca8815b060d39e (patch) | |
tree | b01b037087ac7a3ee20202bff88222057b9c4417 /tests/test-lib.sh | |
parent | Fix compilation of virt-aa-helper.c (diff) | |
download | libvirt-e8ac4a79f17b741e46980d1db8ca8815b060d39e.tar.gz libvirt-e8ac4a79f17b741e46980d1db8ca8815b060d39e.tar.bz2 libvirt-e8ac4a79f17b741e46980d1db8ca8815b060d39e.zip |
Make test suite output less verbose
Only print out '.' for each test case, full test output can be
re-enabled with VIR_TEST_VERBOSE=1, or VIR_TEST_DEBUG=XXXX
Sample output now looks like
TEST: statstest
........................................ 40
................................... 75 OK
PASS: statstest
TEST: qparamtest
................................ 32 OK
PASS: qparamtest
TEST:
............ 12 OK
Diffstat (limited to 'tests/test-lib.sh')
-rw-r--r-- | tests/test-lib.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test-lib.sh b/tests/test-lib.sh index a007109b8..43265f3a9 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -1,5 +1,11 @@ # source this file; set up for tests +test -z "$abs_srcdir" && abs_srcdir=$(pwd) +test -z "$abs_builddir" && abs_builddir=$(pwd) +test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. +test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/.. +test -z "$LC_ALL" && LC_ALL=C + # Skip this test if the shell lacks support for functions. unset function_test eval 'function_test() { return 11; }; function_test' @@ -8,6 +14,59 @@ if test $? != 11; then (exit 77); exit 77 fi +test_intro() +{ + name=$1 + if test "$verbose" = "0" ; then + echo "TEST: $name" + echo -n " " + fi +} + +test_result() +{ + counter=$1 + name=$2 + status=$3 + if test "$verbose" = "0" ; then + mod=`eval "expr \( $counter - 1 \) % 40"` + if test "$counter" != 1 -a "$mod" = 0 ; then + printf " %-3d\n" `eval "expr $counter - 1"` + echo -n " " + fi + if test "$status" = "0" ; then + echo -n "." + else + echo -n "!" + fi + else + if test "$status" = "0" ; then + printf "%3d) %-60s ... OK\n" "$counter" "$name" + else + printf "%3d) %-60s ... FAILED\n" "$counter" "$name" + fi + fi +} + +test_final() +{ + counter=$1 + status=$2 + + if test "$verbose" = "0" ; then + mod=`eval "expr \( $counter + 1 \) % 40"` + for i in `seq $mod 40` + do + echo -n " " + done + if test "$status" = "0" ; then + printf " %-3d OK\n" $counter + else + printf " %-3d FAILED\n" $counter + fi + fi +} + skip_test_() { echo "$0: skipping test: $@" 1>&2 @@ -137,6 +196,11 @@ test_dir_=$(pwd) this_test_() { echo "./$0" | sed 's,.*/,,'; } this_test=$(this_test_) +verbose=0 +if test -n "$VIR_TEST_DEBUG" -o -n "$VIR_TEST_VERBOSE" ; then + verbose=1 +fi + # This is a stub function that is run upon trap (upon regular exit and # interrupt). Override it with a per-test function, e.g., to unmount # a partition, or to undo any other global state changes. |