2
# common.sh - common defs for all tests -*- sh -*-
3
# Copyright (C) 2004 Free Software Foundation, Inc.
5
# This file is part of GnuPG.
7
# GnuPG is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# GnuPG is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21
# reset some environment variables because we do not want to test locals
27
[ "$VERBOSE" = yes ] && set -x
28
[ -z "$srcdir" ] && srcdir="."
29
[ -z "$top_srcdir" ] && top_srcdir=".."
30
[ -z "$GPGSM" ] && GPGSM="../../sm/gpgsm"
33
if [ "$GNUPGHOME" != "`pwd`" ]; then
34
echo "inittests: please set GNUPGHOME to the tests/pkits directory" >&2
38
if [ -n "$GPG_AGENT_INFO" ]; then
39
echo "inittests: please unset GPG_AGENT_INFO" >&2
45
#--------------------------------
46
#------ utility functions -------
47
#--------------------------------
51
if test "$echo_n_init" = "no"; then
52
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
53
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
67
echo $echo_n_n "${1}$echo_n_c"
71
echo "$pgmname: fatal:" $* >&2
76
echo "$pgmname:" $* >&2
81
echo "$pgmname:" $* >&2
85
$echo_n "$pgmname:" $* >&2
90
pass_count=`expr ${pass_count} + 1`
95
fail_count=`expr ${fail_count} + 1`
99
echo "UNRESOLVED: " $* >&2
100
unresolved_count=`expr ${unresolved_count} + 1`
104
echo "UNSUPPORTED: " $* >&2
105
unsupported_count=`expr ${unsupported_count} + 1`
110
[ $pass_count = 0 ] || info "$pass_count tests passed"
111
[ $fail_count = 0 ] || info "$fail_count tests failed"
112
[ $unresolved_count = 0 ] || info "$unresolved_count tests unresolved"
113
[ $unsupported_count = 0 ] || info "$unsupported_count tests unsupported"
114
if [ $fail_count = 0 ]; then
115
info "all tests passed"
123
pgmname=`basename $0`
131
#trap cleanup SIGHUP SIGINT SIGQUIT
132
exec 2> ${pgmname}.log