1# Makefile.am for the tests of the Python bindings.
2# Copyright (C) 2016 g10 Code GmbH
3#
4# This file is part of GPGME.
5#
6# GPGME is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# GPGME is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14# Public License for more details.
15#
16# You should have received a copy of the GNU Lesser General Public
17# License along with this program; if not, see <https://www.gnu.org/licenses/>.
18
19GPG = gpg
20GPG_AGENT = gpg-agent
21
22test_srcdir = $(top_srcdir)/tests/gpg
23
24GNUPGHOME=$(abs_builddir)
25TESTS_ENVIRONMENT = GNUPGHOME=$(GNUPGHOME) \
26	LC_ALL=C GPG_AGENT_INFO= \
27	top_srcdir=$(top_srcdir) \
28	srcdir=$(srcdir) \
29	LD_LIBRARY_PATH="../../../src/.libs:$(LD_LIBRARY_PATH)"
30
31py_tests ?= t-wrapper.py \
32	t-callbacks.py \
33	t-data.py \
34	t-encrypt.py \
35	t-encrypt-sym.py \
36	t-encrypt-sign.py \
37	t-sign.py \
38	t-signers.py \
39	t-decrypt.py \
40	t-verify.py \
41	t-decrypt-verify.py \
42	t-sig-notation.py \
43	t-export.py \
44	t-import.py \
45	t-edit.py \
46	t-keylist.py \
47	t-keylist-from-data.py \
48	t-wait.py \
49	t-encrypt-large.py \
50	t-file-name.py \
51	t-idiomatic.py \
52	t-protocol-assuan.py \
53	t-quick-key-creation.py \
54	t-quick-subkey-creation.py \
55	t-quick-key-manipulation.py \
56	t-quick-key-signing.py
57
58XTESTS = initial.py $(py_tests) final.py
59EXTRA_DIST = support.py $(XTESTS) encrypt-only.asc sign-only.asc \
60             run-tests.py
61
62# XXX: Currently, one cannot override automake's 'check' target.  As a
63# workaround, we avoid defining 'TESTS', thus automake will not emit
64# the 'check' target.  For extra robustness, we merely define a
65# dependency on 'xcheck', so this hack should also work even if
66# automake would emit the 'check' target, as adding dependencies to
67# targets is okay.
68check: xcheck
69
70.PHONY: xcheck
71
72xcheck:	all
73	$(TESTS_ENVIRONMENT) $(PYTHON) $(srcdir)/run-tests.py \
74	  --interpreters="$(PYTHONS)" --srcdir=$(srcdir) $(TESTFLAGS) \
75	  $(XTESTS)
76
77CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \
78	gpg-agent.conf pubring.kbx~ gpg.conf pubring.gpg~ \
79	random_seed .gpg-v21-migrated tofu.db \
80        pubring-stamp gpg-sample.stamp
81
82private_keys = \
83        $(test_srcdir)/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD \
84        $(test_srcdir)/76F7E2B35832976B50A27A282D9B87E44577EB66 \
85        $(test_srcdir)/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD \
86        $(test_srcdir)/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F \
87        $(test_srcdir)/7A030357C0F253A5BBCD282FFC4E521B37558F5C
88
89clean-local:
90	-$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop
91	-rm -fR -- private-keys-v1.d openpgp-revocs.d S.gpg-agent sshcontrol
92
93
94BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \
95           gpg-sample.stamp
96
97gpg-sample.stamp: $(private_keys)
98	-$(TESTS_ENVIRONMENT) gpgconf --kill all
99	$(MKDIR_P) ./private-keys-v1.d
100	for k in $(private_keys); do \
101          cp $$k private-keys-v1.d/$${k#$(test_srcdir)/}.key; \
102        done
103	echo x > ./gpg-sample.stamp
104
105pubring-stamp: $(test_srcdir)/pubdemo.asc gpg-sample.stamp
106	$(TESTS_ENVIRONMENT) $(GPG) --batch --no-permission-warning \
107               --import $(test_srcdir)/pubdemo.asc
108	-$(TESTS_ENVIRONMENT) $(GPG) --batch --no-permission-warning \
109		--import $(test_srcdir)/secdemo.asc
110	echo x > ./pubring-stamp
111
112gpg.conf:
113# This is required for t-sig-notations.
114	echo no-force-v3-sigs > ./gpg.conf
115	echo default-key A0FF4590BB6122EDEF6E3C542D727CC768697734 >> ./gpg.conf
116
117gpg-agent.conf:
118# This is required for gpg2, which does not support command fd.
119	echo pinentry-program $(abs_top_srcdir)/tests/gpg/pinentry >$@
120	echo disable-scdaemon >> $@
121
122
123# end-of-file
124