~ubuntu-branches/ubuntu/dapper/gnupg2/dapper

« back to all changes in this revision

Viewing changes to tests/inittests

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
Import upstream version 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#       Copyright (C) 2002 Free Software Foundation, Inc.
 
3
#
 
4
# This file is free software; as a special exception the author gives
 
5
# unlimited permission to copy and/or distribute it, with or without
 
6
# modifications, as long as this notice is preserved.
 
7
#
 
8
# This file is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 
10
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
11
 
 
12
set -e
 
13
 
 
14
sample_certs='
 
15
cert_g10code_test1.pem
 
16
cert_g10code_pete1.pem
 
17
cert_g10code_theo1.pem
 
18
'
 
19
 
 
20
private_keys='
 
21
32100C27173EF6E9C4E9A25D3D69F86D37A4F939
 
22
'
 
23
 
 
24
clean_files='
 
25
gpgsm.conf gpg-agent.conf trustlist.txt pubring.kbx
 
26
msg msg.sig msg.unsig
 
27
'
 
28
 
 
29
 
 
30
[ -z "$srcdir" ] && srcdir=.
 
31
[ -z "$GPGSM" ] && GPGSM=../sm/gpgsm
 
32
 
 
33
if [ -d $srcdir/samplekeys ] \
 
34
   && grep TESTS_ENVIRONMENT Makefile >/dev/null 2>&1; then
 
35
 :
 
36
else
 
37
   # During make distclean the Makefile has already been removed,
 
38
   # so we need this extra test.
 
39
   if ! grep gnupg-test-directory testdir.stamp >/dev/null 2>&1; then
 
40
      echo "inittests: please cd to the tests directory first" >&2
 
41
      exit 1
 
42
   fi
 
43
fi
 
44
 
 
45
if [ "$1" = "--clean" ]; then
 
46
    if [ -d private-keys-v1.d ]; then
 
47
       rm private-keys-v1.d/* 2>/dev/null || true
 
48
       rmdir private-keys-v1.d
 
49
    fi
 
50
    rm ${clean_files} testdir.stamp 2>/dev/null || true
 
51
    exit 0
 
52
fi
 
53
 
 
54
if [ "$GNUPGHOME" != "`pwd`" ]; then
 
55
    echo "inittests: please set GNUPGHOME to the test directory" >&2
 
56
    exit 1
 
57
fi
 
58
 
 
59
if [ -n "$GPG_AGENT_INFO" ]; then
 
60
    echo "inittests: please unset GPG_AGENT_INFO" >&2
 
61
    exit 1
 
62
fi
 
63
 
 
64
# A stamp file used with --clean
 
65
echo gnupg-test-directory > testdir.stamp
 
66
 
 
67
 
 
68
# Create the private key directy if it does not exists and copy 
 
69
# the sample keys.
 
70
[ -d private-keys-v1.d ] || mkdir private-keys-v1.d
 
71
for i in ${private_keys}; do 
 
72
    cat ${srcdir}/samplekeys/$i.key >private-keys-v1.d/$i.key
 
73
done
 
74
 
 
75
# Create the configuration scripts
 
76
# Note, die to an expired test certificate, we need to use
 
77
# the faked system time option.
 
78
cat > gpgsm.conf <<EOF
 
79
no-secmem-warning
 
80
disable-crl-checks
 
81
agent-program ../agent/gpg-agent
 
82
faked-system-time 1038835799
 
83
EOF
 
84
 
 
85
cat > gpg-agent.conf <<EOF
 
86
no-grab
 
87
pinentry-program /home/wk/work/pinentry/gtk/pinentry-gtk
 
88
EOF
 
89
 
 
90
cat > trustlist.txt <<EOF
 
91
# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE
 
92
3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S
 
93
EOF
 
94
 
 
95
# Make sure that the sample certs are available but ignore errors here
 
96
# because we are not a test script.
 
97
for i in ${sample_certs}; do 
 
98
    $GPGSM --import ${srcdir}/samplekeys/$i || true
 
99
done