diff options
Diffstat (limited to 'tests/pkits/common.sh')
-rw-r--r-- | tests/pkits/common.sh | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/tests/pkits/common.sh b/tests/pkits/common.sh index 09fb62bc8..241a0faf7 100644 --- a/tests/pkits/common.sh +++ b/tests/pkits/common.sh @@ -1,12 +1,12 @@ #!/bin/sh # common.sh - common defs for all tests -*- sh -*- -# Copyright (C) 2004 Free Software Foundation, Inc. +# Copyright (C) 2004, 2008 Free Software Foundation, Inc. # # This file is part of GnuPG. # # GnuPG is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # GnuPG is distributed in the hope that it will be useful, @@ -15,9 +15,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # reset some environment variables because we do not want to test locals export LANG=C @@ -29,7 +27,7 @@ export LC_ALL=C [ -z "$srcdir" ] && srcdir="." [ -z "$top_srcdir" ] && top_srcdir=".." [ -z "$GPGSM" ] && GPGSM="../../sm/gpgsm" - +[ -z "$silent" ] && silent=no if [ "$GNUPGHOME" != "`pwd`" ]; then echo "inittests: please set GNUPGHOME to the tests/pkits directory" >&2 @@ -42,7 +40,6 @@ if [ -n "$GPG_AGENT_INFO" ]; then fi - #-------------------------------- #------ utility functions ------- #-------------------------------- @@ -68,46 +65,92 @@ echo_n () { echo $echo_n_n "${1}$echo_n_c" } +setup_output () { + if [ -z "$first_section_set" ]; then + first_section_set=$section + fi + section_out="$(echo $section)" + if [ -z "$section_out" ]; then + section_out="-" + fi +} + fatal () { echo "$pgmname: fatal:" $* >&2 + if [ "$silent" != "yes" ]; then + echo "$section_out ERROR: $* (fatal)" + fi exit 1; } error () { echo "$pgmname:" $* >&2 + if [ "$silent" != "yes" ]; then + echo "$section_out ERROR: $*" + fi exit 1 } info () { + setup_output echo "$pgmname:" $* >&2 + if [ "$silent" != "yes" ]; then + echo "$section_out ____ $*" + fi } info_n () { - $echo_n "$pgmname:" $* >&2 + setup_output + echo_n "$pgmname:" $* >&2 } pass () { + setup_output echo "PASS: " $* >&2 pass_count=`expr ${pass_count} + 1` + if [ "$silent" != "yes" ]; then + echo_n "$section_out PASS" + [ -n "$description" ] && echo_n " ($description)" + echo + fi } fail () { + setup_output echo "FAIL: " $* >&2 fail_count=`expr ${fail_count} + 1` + if [ "$silent" != "yes" ]; then + echo_n "$section_out FAIL" + [ -n "$description" ] && echo_n " ($description)" + echo + fi } unresolved () { + setup_output echo "UNRESOLVED: " $* >&2 unresolved_count=`expr ${unresolved_count} + 1` + if [ "$silent" != "yes" ]; then + echo_n "$section_out UNRESOLVED" + [ -n "$description" ] && echo_n " ($description)" + echo + fi } unsupported () { + setup_output echo "UNSUPPORTED: " $* >&2 unsupported_count=`expr ${unsupported_count} + 1` + if [ "$silent" != "yes" ]; then + echo_n "$section_out UNSUPPORTED" + [ -n "$description" ] && echo_n " ($description)" + echo + fi } final_result () { + section=$first_section_set [ $pass_count = 0 ] || info "$pass_count tests passed" [ $fail_count = 0 ] || info "$fail_count tests failed" [ $unresolved_count = 0 ] || info "$unresolved_count tests unresolved" @@ -127,7 +170,10 @@ pass_count=0 fail_count=0 unresolved_count=0 unsupported_count=0 - +first_section_set="" +section_out="" +section="" +description="" #trap cleanup SIGHUP SIGINT SIGQUIT exec 2> ${pgmname}.log |