File: inittests

package info (click to toggle)
gnupg2 2.2.12-1+deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 47,236 kB
  • sloc: ansic: 231,709; sh: 7,598; lisp: 6,034; makefile: 1,604; awk: 126; xml: 51; python: 16; sed: 16; php: 14; perl: 13
file content (100 lines) | stat: -rwxr-xr-x 2,623 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
#     	Copyright (C) 2002 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

set -e

sample_certs='
cert_g10code_test1.pem
cert_g10code_pete1.pem
cert_g10code_theo1.pem
'

private_keys='
32100C27173EF6E9C4E9A25D3D69F86D37A4F939
'

clean_files='
gpgsm.conf gpg-agent.conf trustlist.txt pubring.kbx
msg msg.sig msg.unsig
'


[ -z "$srcdir" ] && srcdir=.
[ -z "$GPGSM" ] && GPGSM=../sm/gpgsm

if [ -d $srcdir/samplekeys ] \
   && grep TESTS_ENVIRONMENT Makefile >/dev/null 2>&1; then
 :
else
   # During make distclean the Makefile has already been removed,
   # so we need this extra test.
   if ! grep gnupg-test-directory testdir.stamp >/dev/null 2>&1; then
      echo "inittests: please cd to the tests directory first" >&2
      exit 1
   fi
fi

if [ "$1" = "--clean" ]; then
    if [ -d private-keys-v1.d ]; then
       rm private-keys-v1.d/* 2>/dev/null || true
       rmdir private-keys-v1.d
    fi
    rm ${clean_files} testdir.stamp 2>/dev/null || true
    exit 0
fi

if [ "$GNUPGHOME" != "`/bin/pwd`" ]; then
    echo "inittests: please set GNUPGHOME to the test directory" >&2
    exit 1
fi

if [ -n "$GPG_AGENT_INFO" ]; then
    echo "inittests: please unset GPG_AGENT_INFO" >&2
    exit 1
fi

# A stamp file used with --clean
echo gnupg-test-directory > testdir.stamp


# Create the private key directly if it does not exists and copy
# the sample keys.
[ -d private-keys-v1.d ] || mkdir private-keys-v1.d
for i in ${private_keys}; do
    cat ${srcdir}/samplekeys/$i.key >private-keys-v1.d/$i.key
done

# Create the configuration scripts
# Note, die to an expired test certificate, we need to use
# the faked system time option.
cat > gpgsm.conf <<EOF
no-secmem-warning
disable-crl-checks
agent-program ../agent/gpg-agent
faked-system-time 1038835799
EOF

cat > gpg-agent.conf <<EOF
no-grab
pinentry-program /home/wk/work/pinentry/gtk/pinentry-gtk
disable-scdaemon
EOF

cat > trustlist.txt <<EOF
# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE
3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S
EOF

# Make sure that the sample certs are available but ignore errors here
# because we are not a test script.
for i in ${sample_certs}; do
    $GPGSM --import ${srcdir}/samplekeys/$i || true
done