From bcd5feec0e916b864d004a47f36a41e2eba3b10e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 12 Oct 2021 14:30:13 +0200 Subject: [PATCH] tests: New way to make use of gpgconf.ctl in tests. * Makefile.am (all-local): New to setup symlinks. (distclean-local): New. * tests/Makefile.am: Remove the gpgconf related targets. Just keep gpgconf.ctl.in in EXTRA_DIST * tests/cms/Makefile.am (GNUPG_BUILD_ROOT): * tests/gpgme/Makefile.am (GPGSCM_PATH): * tests/openpgp/Makefile.am (GNUPG_BUILD_ROOT): * tests/pkits/Makefile.am (GNUPG_BUILD_ROOT): * tests/tpm2dtests/defs.scm (tools): Revert to the former values. * tests/openpgp/defs.scm (tools): Ditto. -- This Fixes-commit: 399ebf6d873d4178c1d527aa4df34bf16a76360e Fixes-commit: 84fcd8e6eb7e0786399e1f6461c3f60b0db2d070 because we ran into problems with the idea of first doing a test-install for the checks. "make distcheck" turned out to be too problematic. Symlinks are a better way of doing this. Also fixes GnuPG-bug-id: 5634 --- Makefile.am | 36 ++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 28 ---------------------------- tests/cms/Makefile.am | 4 ++-- tests/gpgme/Makefile.am | 2 +- tests/openpgp/Makefile.am | 2 +- tests/openpgp/README | 9 ++++----- tests/openpgp/defs.scm | 19 +++++++++---------- tests/pkits/Makefile.am | 2 +- tests/tpm2dtests/defs.scm | 14 +++++++------- 9 files changed, 61 insertions(+), 55 deletions(-) diff --git a/Makefile.am b/Makefile.am index 369316e9a..0a0c7d4de 100644 --- a/Makefile.am +++ b/Makefile.am @@ -120,6 +120,42 @@ SUBDIRS = m4 common regexp kbx \ dist_doc_DATA = README +# Create test directory etc/gnupg so that we have an +# empty sysconfdir and bin where we put out gpgconf.ctl. +# we also put symlinks to the actual binaries there. +# Unfortunately there is no all-hook, but symlinks have the +# nice property that they can be created even for not yet +# created files. +all-local: + @-$(MKDIR_P) bin etc/gnupg libexec + @cat $(srcdir)/tests/gpgconf.ctl.in > bin/gpgconf.ctl + (set -e; cd bin; \ + for i in gpg gpgv; \ + do ln -sf ../g10/$$i .; done; \ + for i in gpgsm; \ + do ln -sf ../sm/$$i .; done; \ + for i in gpg-agent; \ + do ln -sf ../agent/$$i .; done; \ + for i in dirmngr; \ + do ln -sf ../dirmngr/$$i .; done; \ + for i in gpgconf gpg-connect-agent gpgtar gpg-card; \ + do ln -sf ../tools/$$i .; done; \ + cd ../libexec ; \ + for i in keyboxd; \ + do ln -sf ../kbx/$$i .; done; \ + for i in scdaemon; \ + do ln -sf ../scd/$$i .; done; \ + for i in gpg-preset-passphrase; \ + do ln -sf ../agent/$$i .; done; \ + echo "created links to binaries" ) + + +# Clean up our test directories but take care that this is never +# called from / or /usr/local +distclean-local: + @if pwd | grep gnupg 2>/dev/null; then rm -rf etc bin libexec; fi + + dist-hook: gen-ChangeLog distcheck-hook: diff --git a/tests/Makefile.am b/tests/Makefile.am index d26ef9df1..9038ccd0b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,31 +44,3 @@ noinst_PROGRAMS = asschk endif asschk_SOURCES = asschk.c - -TESTINST_DIRS = bin sbin libexec share etc - -clean-local: clean-local-testinst - -# We do a cd ../tests here so that we make sure tha the bin dir etc -# are under our tests dir. This is failsafe thingy in case this -# Makefile rule is accidently run /. -clean-local-testinst: - -(cd ../tests && rm -rf $(TESTINST_DIRS)) - -# Before we can run any tests we need to make sure that we have a -# proper test installation with this dir (tests) as root dir. It is -# too hard to track the built files here thus we do the install step -# always. -check-recursive: bin/gpgconf.ctl - -bin/gpgconf.ctl: FORCE - @echo '==== Installing into a test root ======' - @-mkdir bin 2>/dev/null - @cat $(srcdir)/gpgconf.ctl.in > bin/gpgconf.ctl.tmp - cd .. && \ - $(MAKE) $(AM_MAKEFLAGS) install prefix=$(abs_top_builddir)/tests - @mv bin/gpgconf.ctl.tmp bin/gpgconf.ctl - @echo '==== Finished installing into a test root ======' - - -.PHONY: FORCE clean-local-testinst diff --git a/tests/cms/Makefile.am b/tests/cms/Makefile.am index 2ad29351e..8e8c2e000 100644 --- a/tests/cms/Makefile.am +++ b/tests/cms/Makefile.am @@ -32,7 +32,7 @@ AM_CFLAGS = # if the shell used for inittests would uses an internal version of # pwd which handles symlinks differently. OLD_TESTS_ENVIRONMENT = GNUPGHOME=`/bin/pwd` GPG_AGENT_INFO= LC_ALL=C \ - GNUPG_BUILD_ROOT="$(abs_top_builddir)/tests" \ + GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GPGSM="$(GPGSM)" "$(srcdir)/runtest" TESTS_ENVIRONMENT = LC_ALL=C \ @@ -40,7 +40,7 @@ TESTS_ENVIRONMENT = LC_ALL=C \ PATH="../gpgscm:$(PATH)" \ abs_top_srcdir="$(abs_top_srcdir)" \ objdir="$(abs_top_builddir)" \ - GNUPG_BUILD_ROOT="$(abs_top_builddir)/tests" \ + GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GPGSCM_PATH="$(abs_top_srcdir)/tests/gpgscm" XTESTS = \ diff --git a/tests/gpgme/Makefile.am b/tests/gpgme/Makefile.am index aa41940ca..fc1cfc328 100644 --- a/tests/gpgme/Makefile.am +++ b/tests/gpgme/Makefile.am @@ -33,7 +33,7 @@ TESTS_ENVIRONMENT = LC_ALL=C \ PATH="../gpgscm:$(PATH)" \ abs_top_srcdir=$(abs_top_srcdir) \ objdir=$(abs_top_builddir) \ - GNUPG_BUILD_ROOT="$(abs_top_builddir)/tests" \ + GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm # XXX: Currently, one cannot override automake's 'check' target. As a diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am index cecbde8cb..3d0cc9db9 100644 --- a/tests/openpgp/Makefile.am +++ b/tests/openpgp/Makefile.am @@ -38,7 +38,7 @@ TESTS_ENVIRONMENT = LC_ALL=C \ PATH="../gpgscm:$(PATH)" \ abs_top_srcdir="$(abs_top_srcdir)" \ objdir="$(abs_top_builddir)" \ - GNUPG_BUILD_ROOT="$(abs_top_builddir)/tests" \ + GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GPGSCM_PATH="$(abs_top_srcdir)/tests/gpgscm" XTESTS = \ diff --git a/tests/openpgp/README b/tests/openpgp/README index b7ec6f784..63f1886c5 100644 --- a/tests/openpgp/README +++ b/tests/openpgp/README @@ -1,4 +1,5 @@ # Emacs, this is an -*- org -*- file. +#+STARTUP: showall * How to run the test suite ** tldr: How to run all tests fast. @@ -95,11 +96,9 @@ data files. Used to locate the Scheme library as well as code used by the test suite. **** GNUPG_BUILD_ROOT -To locate the actual binaries under test the test suite requires that -those binaries and associate files are installed to a test location. -This envvar gives the root directory of the install tree. See -tests/gpgconf.ctl for the way we tell the GnuPG components this -location. Note that we can't use that envvar directlyr because this +This envvar gives the root directory of the build tree. See +tests/gpgconf.ctl.in for the way we tell the GnuPG components this +location. Note that we can't use that envvar directly because this would allow user scripts and other software to accidently mess up the used components. **** argv[0] diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm index 61e3fdbda..6795512b7 100644 --- a/tests/openpgp/defs.scm +++ b/tests/openpgp/defs.scm @@ -112,18 +112,17 @@ (assert (equal? (percent-encode "foob%61r") "foob%2561r")) ;; Note that the entry for pinentry relies on the fact that -;; GNUPG_BUILD_ROOT has the bin,libexec,share directories (where we -;; have installed versions of the tools under test) as well as the -;; openpgp directory. The second element in each list is an envvar which -;; can be used to specifiy a different tool than the installed one. +;; GNUPG_BUILD_ROOT is the top of the build root. The second element +;; in each list is an envvar which can be used to specifiy a different +;; tool than the installed one. (define tools - '((gpgv "GPGV" "bin/gpgv") - (gpg-connect-agent "GPG_CONNECT_AGENT" "bin/gpg-connect-agent") - (gpgconf "GPGCONF" "bin/gpgconf") + '((gpgv "GPGV" "g10/gpgv") + (gpg-connect-agent "GPG_CONNECT_AGENT" "tools/gpg-connect-agent") + (gpgconf "GPGCONF" "tools/gpgconf") (gpg-preset-passphrase "GPG_PRESET_PASSPHRASE" - "libexec/gpg-preset-passphrase") - (gpgtar "GPGTAR" "bin/gpgtar") - (pinentry "PINENTRY" "openpgp/fake-pinentry"))) + "agent/gpg-preset-passphrase") + (gpgtar "GPGTAR" "tools/gpgtar") + (pinentry "PINENTRY" "tests/openpgp/fake-pinentry"))) (define (tool-hardcoded which) (let ((t (assoc which tools))) diff --git a/tests/pkits/Makefile.am b/tests/pkits/Makefile.am index b85e110b5..65db8bb1e 100644 --- a/tests/pkits/Makefile.am +++ b/tests/pkits/Makefile.am @@ -21,7 +21,7 @@ GPGSM = ../../sm/gpgsm TESTS_ENVIRONMENT = GNUPGHOME=`/bin/pwd` GPG_AGENT_INFO= LC_ALL=C \ - GNUPG_BUILD_ROOT="$(abs_top_builddir)/tests" \ + GNUPG_BUILD_ROOT="$(abs_top_builddir)" \ GPGSM=$(GPGSM) silent=yes diff --git a/tests/tpm2dtests/defs.scm b/tests/tpm2dtests/defs.scm index eb840206f..0fef71806 100644 --- a/tests/tpm2dtests/defs.scm +++ b/tests/tpm2dtests/defs.scm @@ -61,14 +61,14 @@ (assert (equal? (percent-encode "foob%61r") "foob%2561r")) (define tools - '((gpgv "GPGV" "bin/gpgv") - (gpg-connect-agent "GPG_CONNECT_AGENT" "bin/gpg-connect-agent") - (gpgconf "GPGCONF" "bin/gpgconf") + '((gpgv "GPGV" "g10/gpgv") + (gpg-connect-agent "GPG_CONNECT_AGENT" "tools/gpg-connect-agent") + (gpgconf "GPGCONF" "tools/gpgconf") (gpg-preset-passphrase "GPG_PRESET_PASSPHRASE" - "libexec/gpg-preset-passphrase") - (gpgtar "GPGTAR" "bin/gpgtar") - (tpm2daemon "TPM2DAEMON" "libexec/tpm2daemon") - (pinentry "PINENTRY" "openpgp/fake-pinentry"))) + "agent/gpg-preset-passphrase") + (gpgtar "GPGTAR" "tools/gpgtar") + (tpm2daemon "TPM2DAEMON" "tpm2d/tpm2daemon") + (pinentry "PINENTRY" "tests/openpgp/fake-pinentry"))) (define with-valgrind? (not (string=? (getenv "with_valgrind") "")))