Avoid passing NULL to printf while debugging.
[gnupg.git] / tests / inittests
blob05a94eb68f2782cdf46be80946fafe51c3556ea5
1 #!/bin/sh
2 # Copyright (C) 2002 Free Software Foundation, Inc.
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.
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.
12 set -e
14 sample_certs='
15 cert_g10code_test1.pem
16 cert_g10code_pete1.pem
17 cert_g10code_theo1.pem
20 private_keys='
21 32100C27173EF6E9C4E9A25D3D69F86D37A4F939
24 clean_files='
25 gpgsm.conf gpg-agent.conf trustlist.txt pubring.kbx
26 msg msg.sig msg.unsig
30 [ -z "$srcdir" ] && srcdir=.
31 [ -z "$GPGSM" ] && GPGSM=../sm/gpgsm
33 if [ -d $srcdir/samplekeys ] \
34 && grep TESTS_ENVIRONMENT Makefile >/dev/null 2>&1; then
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
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
50 rm ${clean_files} testdir.stamp 2>/dev/null || true
51 exit 0
54 if [ "$GNUPGHOME" != "`pwd`" ]; then
55 echo "inittests: please set GNUPGHOME to the test directory" >&2
56 exit 1
59 if [ -n "$GPG_AGENT_INFO" ]; then
60 echo "inittests: please unset GPG_AGENT_INFO" >&2
61 exit 1
64 # A stamp file used with --clean
65 echo gnupg-test-directory > testdir.stamp
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
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
85 cat > gpg-agent.conf <<EOF
86 no-grab
87 pinentry-program /home/wk/work/pinentry/gtk/pinentry-gtk
88 EOF
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
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