| 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 OLD_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" != "`/bin/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 directly 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 |
disable-scdaemon |
| 89 |
EOF |
| 90 |
|
| 91 |
cat > trustlist.txt <<EOF |
| 92 |
# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE |
| 93 |
3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S |
| 94 |
EOF |
| 95 |
|
| 96 |
# Make sure that the sample certs are available but ignore errors here |
| 97 |
# because we are not a test script. |
| 98 |
for i in ${sample_certs}; do |
| 99 |
$GPGSM --import ${srcdir}/samplekeys/$i || true |
| 100 |
done |