~ubuntu-branches/ubuntu/jaunty/gnupg2/jaunty

« back to all changes in this revision

Viewing changes to tests/pkits/common.sh

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2006-01-24 04:31:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060124043142-pbg192or6qxv3yk2
Tags: 1.9.20-1
* New Upstream version. Closes:#306890,#344530
  * Closes:#320490: gpg-protect-tool fails to decrypt PKCS-12 files 
* Depend on libopensc2-dev, not -1-. Closes:#348106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# common.sh - common defs for all tests         -*- sh -*-
 
3
# Copyright (C) 2004 Free Software Foundation, Inc.
 
4
#
 
5
# This file is part of GnuPG.
 
6
 
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.
 
11
 
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.
 
16
 
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
 
20
 
 
21
# reset some environment variables because we do not want to test locals
 
22
export LANG=C
 
23
export LANGUAGE=C
 
24
export LC_ALL=C
 
25
 
 
26
 
 
27
[ "$VERBOSE" = yes ] && set -x
 
28
[ -z "$srcdir" ] && srcdir="."
 
29
[ -z "$top_srcdir" ] && top_srcdir=".."
 
30
[ -z "$GPGSM" ] && GPGSM="../../sm/gpgsm"
 
31
 
 
32
 
 
33
if [ "$GNUPGHOME" != "`pwd`" ]; then
 
34
    echo "inittests: please set GNUPGHOME to the tests/pkits directory" >&2
 
35
    exit 1
 
36
fi
 
37
 
 
38
if [ -n "$GPG_AGENT_INFO" ]; then
 
39
    echo "inittests: please unset GPG_AGENT_INFO" >&2
 
40
    exit 1
 
41
fi
 
42
 
 
43
 
 
44
 
 
45
#--------------------------------
 
46
#------ utility functions -------
 
47
#--------------------------------
 
48
 
 
49
echo_n_init=no
 
50
echo_n () {
 
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
 
54
        echo_n_n=
 
55
        echo_n_c='
 
56
'
 
57
      else
 
58
        echo_n_n='-n'
 
59
        echo_n_c=
 
60
      fi
 
61
    else
 
62
      echo_n_n=
 
63
      echo_n_c='\c'
 
64
    fi
 
65
    echo_n_init=yes
 
66
  fi
 
67
  echo $echo_n_n "${1}$echo_n_c"
 
68
}
 
69
 
 
70
fatal () {
 
71
    echo "$pgmname: fatal:" $* >&2
 
72
    exit 1;
 
73
}
 
74
 
 
75
error () {
 
76
    echo "$pgmname:" $* >&2
 
77
    exit 1
 
78
}
 
79
 
 
80
info () {
 
81
    echo "$pgmname:" $* >&2
 
82
}
 
83
 
 
84
info_n () {
 
85
    $echo_n "$pgmname:" $* >&2
 
86
}
 
87
 
 
88
pass () {
 
89
    echo "PASS: " $* >&2
 
90
    pass_count=`expr ${pass_count} + 1`
 
91
}
 
92
 
 
93
fail () {
 
94
    echo "FAIL: " $* >&2
 
95
    fail_count=`expr ${fail_count} + 1`
 
96
}
 
97
 
 
98
unresolved () {
 
99
    echo "UNRESOLVED: " $* >&2
 
100
    unresolved_count=`expr ${unresolved_count} + 1`
 
101
}
 
102
 
 
103
unsupported () {
 
104
    echo "UNSUPPORTED: " $* >&2
 
105
    unsupported_count=`expr ${unsupported_count} + 1`
 
106
}
 
107
 
 
108
 
 
109
final_result () {
 
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"
 
116
    else
 
117
        exit 1
 
118
    fi
 
119
}
 
120
 
 
121
set -e
 
122
 
 
123
pgmname=`basename $0`
 
124
 
 
125
pass_count=0
 
126
fail_count=0
 
127
unresolved_count=0
 
128
unsupported_count=0
 
129
 
 
130
 
 
131
#trap cleanup SIGHUP SIGINT SIGQUIT
 
132
exec 2> ${pgmname}.log
 
133
 
 
134
:
 
135
# end