[git] GnuPG - branch, master, updated. gnupg-2.1.16-119-g948cca9

by Justus Winter cvs at cvs.gnupg.org
Wed Dec 14 16:53:44 CET 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  948cca9c99e701a1668bb5fd6e25f07e35381b4d (commit)
       via  ca1e9749bfb069d90aa44efbf6f3d611b6104c1b (commit)
       via  55dc81125abc43cd3cc8db951fc3b8a81767942d (commit)
       via  d6e332422f7a8adc01a45685b067b977e28444e2 (commit)
      from  d34a2bb410c7c770d26430d69ff77bd83fc407f1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 948cca9c99e701a1668bb5fd6e25f07e35381b4d
Author: Justus Winter <justus at g10code.com>
Date:   Thu Nov 17 13:11:48 2016 +0100

    tests: Reuse GPGME's tests.
    
    * configure.ac (AC_CONFIG_FILES): Add new Makefile.
    * tests/Makefile.am (SUBDIRS): Add new directory.
    * tests/gpgme/Makefile.am: New file.
    * tests/gpgme/gpgme-defs.scm: Likewise.
    * tests/gpgme/run-tests.scm: Likewise.
    * tests/gpgme/setup.scm: Likewise.
    * tests/gpgme/wrap.scm: Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/configure.ac b/configure.ac
index 066e963..1c467bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1888,6 +1888,7 @@ tests/Makefile
 tests/gpgscm/Makefile
 tests/openpgp/Makefile
 tests/migrations/Makefile
+tests/gpgme/Makefile
 tests/pkits/Makefile
 g10/gpg.w32-manifest
 ])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2fbdc7f..c022e2a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,7 +18,7 @@
 
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = gpgscm openpgp migrations pkits .
+SUBDIRS = gpgscm openpgp migrations gpgme pkits .
 
 GPGSM = ../sm/gpgsm
 
diff --git a/tests/gpgme/Makefile.am b/tests/gpgme/Makefile.am
new file mode 100644
index 0000000..21e0e14
--- /dev/null
+++ b/tests/gpgme/Makefile.am
@@ -0,0 +1,58 @@
+# Makefile.am - For tests/gpgme
+# Copyright (C) 2016 g10 Code GmbH
+#
+# This file is part of GnuPG.
+#
+# GnuPG is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# GnuPG is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
+# Process this file with automake to create Makefile.in
+
+
+# Programs required before we can run these tests.
+required_pgms = ../../g10/gpg$(EXEEXT) ../../agent/gpg-agent$(EXEEXT) \
+                ../../tools/gpg-connect-agent$(EXEEXT) \
+		../gpgscm/gpgscm$(EXEEXT)
+
+AM_CPPFLAGS = -I$(top_srcdir)/common
+include $(top_srcdir)/am/cmacros.am
+
+AM_CFLAGS =
+
+TMP ?= /tmp
+
+TESTS_ENVIRONMENT = LC_ALL=C \
+	EXEEXT=$(EXEEXT) \
+	PATH=../gpgscm:$(PATH) \
+	TMP=$(TMP) \
+	srcdir=$(abs_srcdir) \
+	objdir=$(abs_top_builddir) \
+	GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp:$(abs_top_srcdir)/tests/gpgme
+
+# XXX: Currently, one cannot override automake's 'check' target.  As a
+# workaround, we avoid defining 'TESTS', thus automake will not emit
+# the 'check' target.  For extra robustness, we merely define a
+# dependency on 'xcheck', so this hack should also work even if
+# automake would emit the 'check' target, as adding dependencies to
+# targets is okay.
+check: xcheck
+
+.PHONY: xcheck
+xcheck:
+	$(TESTS_ENVIRONMENT) $(abs_top_builddir)/tests/gpgscm/gpgscm \
+	  $(abs_srcdir)/run-tests.scm $(TESTFLAGS) $(XTESTS)
+
+EXTRA_DIST = gpgme-defs.scm run-tests.scm setup.scm wrap.scm
+
+# We need to depend on a couple of programs so that the tests don't
+# start before all programs are built.
+all-local: $(required_pgms)
diff --git a/tests/gpgme/gpgme-defs.scm b/tests/gpgme/gpgme-defs.scm
new file mode 100644
index 0000000..2490666
--- /dev/null
+++ b/tests/gpgme/gpgme-defs.scm
@@ -0,0 +1,167 @@
+#!/usr/bin/env gpgscm
+
+;; Copyright (C) 2016 g10 Code GmbH
+;;
+;; This file is part of GnuPG.
+;;
+;; GnuPG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GnuPG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+(load (with-path "defs.scm"))
+
+(define gpgme-srcdir (getenv "XTEST_GPGME_SRCDIR"))
+(when (string=? "" gpgme-srcdir)
+    (info
+     "SKIP: Environment variable 'XTEST_GPGME_SRCDIR' not set.  Please"
+     "point it to a recent GPGME source tree to run the GPGME test suite.")
+    (exit 0))
+
+(define (in-gpgme-srcdir . names)
+  (canonical-path (apply path-join (cons gpgme-srcdir names))))
+
+(define gpgme-builddir (getenv "XTEST_GPGME_BUILDDIR"))
+(when (string=? "" gpgme-builddir)
+    (info
+     "SKIP: Environment variable 'XTEST_GPGME_BUILDDIR' not set.  Please"
+     "point it to a recent GPGME build tree to run the GPGME test suite.")
+    (exit 0))
+
+;; Make sure that GPGME picks up our gpgconf.  This makes GPGME use
+;; and thus executes the tests with GnuPG components from the build
+;; tree.
+(setenv "PATH" (string-append (path-join (getenv "GNUPG_BUILDDIR") "tools")
+			      (string *pathsep*) (getenv "PATH")) #t)
+
+(define (create-file name content)
+  (letfd ((fd (open name (logior O_WRONLY O_CREAT O_BINARY) #o600)))
+    (display content (fdopen fd "wb"))))
+
+(define (create-gpgmehome . path)
+  (create-file "gpg.conf" "no-force-v3-sigs\n")
+  (create-file
+   "gpg-agent.conf"
+   (string-append "pinentry-program "
+		  (in-gpgme-srcdir "tests" "gpg" "pinentry") "\n"))
+  (mkdir "private-keys-v1.d" "-rwx")
+
+  (log "Storing private keys")
+  (for-each
+   (lambda (name)
+     (file-copy (apply in-gpgme-srcdir `(, at path ,name))
+		(path-join "private-keys-v1.d"
+			   (string-append name ".key"))))
+   '("13CD0F3BDF24BE53FE192D62F18737256FF6E4FD"
+     "76F7E2B35832976B50A27A282D9B87E44577EB66"
+     "A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD"
+     "13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F"
+     "7A030357C0F253A5BBCD282FFC4E521B37558F5C"))
+
+  (log "Importing public demo and test keys")
+  (for-each
+   (lambda (file)
+     (call-check `(, at GPG --yes --import ,(apply in-gpgme-srcdir
+						`(, at path ,file)))))
+   (list "pubdemo.asc" "secdemo.asc"))
+  (stop-agent))
+
+;; Initialize the test environment, install appropriate configuration
+;; and start the agent, with the keys from the legacy test suite.
+(define (setup-gpgme-environment . path)
+  (if (member "--unpack-tarball" *args*)
+      (begin
+	(call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*)))
+	(start-agent))
+      (apply create-gpgme-gpghome path)))
+
+;; Command line flag handling.  Returns the elements following KEY in
+;; ARGUMENTS up to the next argument, or #f if KEY is not in
+;; ARGUMENTS.
+(define (flag key arguments)
+  (cond
+   ((null? arguments)
+    #f)
+   ((string=? key (car arguments))
+    (let loop ((acc '())
+	       (args (cdr arguments)))
+      (if (or (null? args) (string-prefix? (car args) "--"))
+	  (reverse acc)
+	  (loop (cons (car args) acc) (cdr args)))))
+   ((string=? "--" (car arguments))
+    #f)
+   (else
+    (flag key (cdr arguments)))))
+(assert (equal? (flag "--xxx" '("--yyy")) #f))
+(assert (equal? (flag "--xxx" '("--xxx")) '()))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy")) '("yyy")))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz")) '("yyy" "zzz")))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz" "--")) '("yyy" "zzz")))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy" "--" "zzz")) '("yyy")))
+(assert (equal? (flag "--" '("--" "xxx" "yyy" "--" "zzz")) '("xxx" "yyy")))
+
+(define (parse-makefile port key)
+  (define (is-continuation? tokens)
+    (string=? (last tokens) "\\"))
+  (define (valid-token? s)
+    (< 0 (string-length s)))
+  (define (drop-continuations tokens)
+    (let loop ((acc '()) (tks tokens))
+      (if (null? tks)
+	  (reverse acc)
+	  (loop (if (string=? "\\" (car tks))
+		    acc
+		    (cons (car tks) acc)) (cdr tks)))))
+  (let next ((acc '()) (found #f))
+    (let ((line (read-line port)))
+      (if (eof-object? line)
+	  acc
+	  (let ((tokens (filter valid-token?
+				(string-splitp (string-trim char-whitespace?
+							    line)
+					       char-whitespace? -1))))
+	    (cond
+	     ((or (null? tokens)
+		  (string-prefix? (car tokens) "#")
+		  (and (not found) (not (and (string=? key (car tokens))
+					     (string=? "=" (cadr tokens))))))
+	      (next acc found))
+	     ((not found)
+	      (assert (and (string=? key (car tokens))
+			   (string=? "=" (cadr tokens))))
+	      (if (is-continuation? tokens)
+		  (next (drop-continuations (cddr tokens)) #t)
+		  (drop-continuations (cddr tokens))))
+	     (else
+	      (assert found)
+	      (if (is-continuation? tokens)
+		  (next (append acc (drop-continuations tokens)) found)
+		  (append acc (drop-continuations tokens))))))))))
+
+(define (parse-makefile-expand filename expand key)
+  (define (variable? v)
+    (and (string-prefix? v "$(") (string-suffix? v ")")))
+
+  (let expand-all ((values (parse-makefile (open-input-file filename) key)))
+    (if (any variable? values)
+	(expand-all
+	 (let expand-one ((acc '()) (v values))
+	   (cond
+	    ((null? v)
+	     acc)
+	    ((variable? (car v))
+	     (let ((makefile (open-input-file filename))
+		   (key (substring (car v) 2 (- (string-length (car v)) 1))))
+	       (expand-one (append acc (expand filename makefile key))
+			   (cdr v))))
+	    (else
+	     (expand-one (append acc (list (car v))) (cdr v))))))
+	values)))
diff --git a/tests/gpgme/run-tests.scm b/tests/gpgme/run-tests.scm
new file mode 100644
index 0000000..bce5584
--- /dev/null
+++ b/tests/gpgme/run-tests.scm
@@ -0,0 +1,69 @@
+#!/usr/bin/env gpgscm
+
+;; Copyright (C) 2016 g10 Code GmbH
+;;
+;; This file is part of GnuPG.
+;;
+;; GnuPG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GnuPG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+(load (with-path "gpgme-defs.scm"))
+
+(info "Running GPGME's test suite...")
+
+(define (gpgme-makefile-expand filename port key)
+  ;;(interactive-repl (current-environment))
+  (cond
+   ((string=? key "tests_unix")
+    (if *win32*
+	(parse-makefile port key)   ;; Use win32 definition.
+	(begin
+	  (parse-makefile port key) ;; Skip win32 definition.
+	  (parse-makefile port key))))
+   (else
+    (parse-makefile port key))))
+
+(define (all-tests filename key)
+  (parse-makefile-expand filename gpgme-makefile-expand key))
+
+(let* ((runner (if (member "--parallel" *args*)
+		   run-tests-parallel
+		   run-tests-sequential))
+       (tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*)))
+  (runner
+   (test::scm "setup.scm" (in-srcdir "setup.scm") "--" "tests" "gpg")
+   (apply
+    append
+    (map (lambda (cmpnts)
+	   (define (compiled? name)
+	     (not (or (string-suffix? name ".py")
+		      (string-suffix? name ".test"))))
+	   (define :path car)
+	   (define :key cadr)
+	   (define (find-test name)
+	     (apply path-join
+		    `(,(if (compiled? name)
+			   gpgme-builddir
+			   gpgme-srcdir) ,@(:path cmpnts),name)))
+	   (let ((makefile (apply path-join `(,gpgme-srcdir ,@(:path cmpnts)
+							    "Makefile.am"))))
+	     (map (lambda (name)
+		    (apply test::scm
+			   `(,name ,(in-srcdir "wrap.scm") --executable
+				   ,(find-test name)
+				   -- ,@(:path cmpnts))))
+		  (if (null? tests) (all-tests makefile (:key cmpnts)) tests))))
+	 '((("tests" "gpg") "c_tests")
+	   ;; XXX: Not yet.
+	   ;; (("lang" "python" "tests") "py_tests")
+	   (("lang" "qt" "tests") "TESTS"))))))
diff --git a/tests/gpgme/setup.scm b/tests/gpgme/setup.scm
new file mode 100644
index 0000000..0116a74
--- /dev/null
+++ b/tests/gpgme/setup.scm
@@ -0,0 +1,35 @@
+#!/usr/bin/env gpgscm
+
+;; Copyright (C) 2016 g10 Code GmbH
+;;
+;; This file is part of GnuPG.
+;;
+;; GnuPG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GnuPG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+(load (with-path "gpgme-defs.scm"))
+
+(define tarball (flag "--create-tarball" *args*))
+(unless (and tarball (not (null? tarball)))
+	(error "Usage: setup.scm --create-tarball <file> ..."))
+
+(define components (flag "--" *args*))
+(unless (and components (not (null? components)))
+	(error "Usage: setup.scm --create-tarball " (cadr tarball)
+	       " -- component [component ...]"))
+
+(with-temporary-working-directory
+ (setenv "GNUPGHOME" (getcwd) #t)
+ (apply create-gpgmehome components)
+ (stop-agent)
+ (call-check `(,(tool 'gpgtar) --create --output ,(car tarball) ".")))
diff --git a/tests/gpgme/wrap.scm b/tests/gpgme/wrap.scm
new file mode 100644
index 0000000..4f3ae7d
--- /dev/null
+++ b/tests/gpgme/wrap.scm
@@ -0,0 +1,60 @@
+#!/usr/bin/env gpgscm
+
+;; Copyright (C) 2016 g10 Code GmbH
+;;
+;; This file is part of GnuPG.
+;;
+;; GnuPG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GnuPG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+(load (with-path "gpgme-defs.scm"))
+
+(define executable (flag "--executable" *args*))
+(unless (and executable (not (null? executable)))
+	(error "Usage: wrap.scm --executable <file> [args...]"))
+
+(setup-gpgme-environment "tests" "gpg")
+
+(setenv "abs_builddir" (getcwd) #t)
+(setenv "top_srcdir" gpgme-srcdir #t)
+(setenv "srcdir" (path-join gpgme-srcdir "tests" "gpg") #t)
+
+(define (run what)
+  (if (string-suffix? (car what) ".py")
+      (begin
+	(setenv "LD_LIBRARY_PATH"
+		(if (< 0 (string-length (getenv "LD_LIBRARY_PATH")))
+		    (string-append (path-join gpgme-builddir "src/.libs")
+				   (string *pathsep*)
+				   (getenv "LD_LIBRARY_PATH"))
+		    (path-join gpgme-builddir "src/.libs"))
+		#t)
+	(call-with-fds
+	 `("/usr/bin/python"
+	   ,(in-gpgme-srcdir "lang" "python" "tests" "run-tests.py")
+	   --quiet
+	   --interpreters=/usr/bin/python
+	   --builddir ,(path-join gpgme-builddir "lang" "python" "tests")
+	   , at what)
+	 STDIN_FILENO STDOUT_FILENO STDERR_FILENO))
+      (if #f 77 (call-with-fds what STDIN_FILENO STDOUT_FILENO STDERR_FILENO))))
+
+(let ((name (basename (car executable))))
+  (cond
+   ((string=? "t-keylist" name)
+    ;; This test assumes that 't-import' imported a key.
+    (log "Importing extra key...")
+    (call-check `(, at GPG --yes --import ,(in-srcdir "pubkey-1.asc"))))))
+
+(log "Running" (car executable))
+(exit (run executable))

commit ca1e9749bfb069d90aa44efbf6f3d611b6104c1b
Author: Justus Winter <justus at g10code.com>
Date:   Wed Dec 14 14:18:22 2016 +0100

    common: Support locating components in the build tree.
    
    * common/homedir.c (gnupg_build_directory): New variable.
    (gnupg_module_name_called): Likewise.
    (gnupg_set_builddir): New function.
    (gnupg_set_builddir_from_env): Likewise.
    (gnupg_module_name): Support locating components in the build tree.
    * common/util.h (gnupg_set_builddir): New prototype.
    * tests/openpgp/defs.scm (tools): Drop 'gpg and 'gpg-agent.
    (tool): Rename to 'tool-hardcoded.
    (gpg-conf): New function, with accessors for the results.
    (gpg-components): New variable.
    (tool): New function.
    * tools/gpgconf.c (enum cmd_and_opt_values): New key.
    (opts): New option '--build-prefix'.
    (main): Handle new option.
    --
    
    This change makes sure that the components from the build tree are
    used, and not some older installed version in PATH.  It also lets us
    make GPGME use components from the build tree, making it possible to
    execute GPGME's test suite with them.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/common/homedir.c b/common/homedir.c
index 59b7135..6b40bb6 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -884,15 +884,60 @@ get_default_pinentry_name (int reset)
 }
 
 
+/* If set, 'gnupg_module_name' returns modules from that build
+ * directory.  */
+static char *gnupg_build_directory;
+
+/* For sanity checks.  */
+static int gnupg_module_name_called;
+
+
+/* Set NEWDIR as the new build directory.  This will make
+ * 'gnupg_module_name' return modules from that build directory.  Must
+ * be called before any invocation of 'gnupg_module_name', and must
+ * not be called twice.  It can be used by test suites to make sure
+ * the components from the build directory are used instead of
+ * potentially outdated installed ones.  */
+void
+gnupg_set_builddir (const char *newdir)
+{
+  log_assert (! gnupg_module_name_called);
+  log_assert (! gnupg_build_directory);
+  gnupg_build_directory = xtrystrdup (newdir);
+}
+
+
+/* If no build directory has been configured, try to set it from the
+ * environment.  We only do this in development builds to avoid
+ * increasing the set of influential environment variables and hence
+ * the attack surface of production builds.  */
+static void
+gnupg_set_builddir_from_env (void)
+{
+#ifdef IS_DEVELOPMENT_VERSION
+  if (gnupg_build_directory)
+    return;
+
+  gnupg_build_directory = getenv ("GNUPG_BUILDDIR");
+#endif
+}
+
+
 /* Return the file name of a helper tool.  WHICH is one of the
    GNUPG_MODULE_NAME_foo constants.  */
 const char *
 gnupg_module_name (int which)
 {
-#define X(a,b) do {                                                     \
+  gnupg_set_builddir_from_env ();
+  gnupg_module_name_called = 1;
+
+#define X(a,b,c) do {                                                   \
     static char *name;                                                  \
     if (!name)                                                          \
-      name = xstrconcat (gnupg_ ## a (), DIRSEP_S b EXEEXT_S, NULL);    \
+      name = gnupg_build_directory                                      \
+        ? xstrconcat (gnupg_build_directory,                            \
+                      DIRSEP_S b DIRSEP_S c EXEEXT_S, NULL)             \
+        : xstrconcat (gnupg_ ## a (), DIRSEP_S c EXEEXT_S, NULL);       \
     return name;                                                        \
   } while (0)
 
@@ -902,7 +947,7 @@ gnupg_module_name (int which)
 #ifdef GNUPG_DEFAULT_AGENT
       return GNUPG_DEFAULT_AGENT;
 #else
-      X(bindir, "gpg-agent");
+      X(bindir, "agent", "gpg-agent");
 #endif
 
     case GNUPG_MODULE_NAME_PINENTRY:
@@ -916,55 +961,57 @@ gnupg_module_name (int which)
 #ifdef GNUPG_DEFAULT_SCDAEMON
       return GNUPG_DEFAULT_SCDAEMON;
 #else
-      X(libexecdir, "scdaemon");
+      X(libexecdir, "scd", "scdaemon");
 #endif
 
     case GNUPG_MODULE_NAME_DIRMNGR:
 #ifdef GNUPG_DEFAULT_DIRMNGR
       return GNUPG_DEFAULT_DIRMNGR;
 #else
-      X(bindir, DIRMNGR_NAME);
+      X(bindir, "dirmngr", DIRMNGR_NAME);
 #endif
 
     case GNUPG_MODULE_NAME_PROTECT_TOOL:
 #ifdef GNUPG_DEFAULT_PROTECT_TOOL
       return GNUPG_DEFAULT_PROTECT_TOOL;
 #else
-      X(libexecdir, "gpg-protect-tool");
+      X(libexecdir, "agent", "gpg-protect-tool");
 #endif
 
     case GNUPG_MODULE_NAME_DIRMNGR_LDAP:
 #ifdef GNUPG_DEFAULT_DIRMNGR_LDAP
       return GNUPG_DEFAULT_DIRMNGR_LDAP;
 #else
-      X(libexecdir, "dirmngr_ldap");
+      X(libexecdir, "dirmngr", "dirmngr_ldap");
 #endif
 
     case GNUPG_MODULE_NAME_CHECK_PATTERN:
-      X(libexecdir, "gpg-check-pattern");
+      X(libexecdir, "tools", "gpg-check-pattern");
 
     case GNUPG_MODULE_NAME_GPGSM:
-      X(bindir, "gpgsm");
+      X(bindir, "sm", "gpgsm");
 
     case GNUPG_MODULE_NAME_GPG:
 #if USE_GPG2_HACK
-      X(bindir, GPG_NAME "2");
-#else
-      X(bindir, GPG_NAME);
+      if (! gnupg_build_directory)
+        X(bindir, "g10", GPG_NAME "2");
+      else
 #endif
+        X(bindir, "g10", GPG_NAME);
 
     case GNUPG_MODULE_NAME_GPGV:
 #if USE_GPG2_HACK
-      X(bindir, GPG_NAME "v2");
-#else
-      X(bindir, GPG_NAME "v");
+      if (! gnupg_build_directory)
+        X(bindir, "g10", GPG_NAME "v2");
+      else
 #endif
+        X(bindir, "g10", GPG_NAME "v");
 
     case GNUPG_MODULE_NAME_CONNECT_AGENT:
-      X(bindir, "gpg-connect-agent");
+      X(bindir, "tools", "gpg-connect-agent");
 
     case GNUPG_MODULE_NAME_GPGCONF:
-      X(bindir, "gpgconf");
+      X(bindir, "tools", "gpgconf");
 
     default:
       BUG ();
diff --git a/common/util.h b/common/util.h
index 2ff2bbc..f7a53e1 100644
--- a/common/util.h
+++ b/common/util.h
@@ -263,6 +263,7 @@ char *_gnupg_socketdir_internal (int skip_checks, unsigned *r_info);
 #define GNUPG_MODULE_NAME_GPGV          12
 const char *gnupg_module_name (int which);
 void gnupg_module_name_flush_some (void);
+void gnupg_set_builddir (const char *newdir);
 
 
 
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 5249ca9..ef81f99 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -56,9 +56,7 @@
 	value)))
 
 (define tools
-  '((gpg "GPG" "g10/gpg")
-    (gpgv "GPGV" "g10/gpgv")
-    (gpg-agent "GPG_AGENT" "agent/gpg-agent")
+  '((gpgv "GPGV" "g10/gpgv")
     (gpg-connect-agent "GPG_CONNECT_AGENT" "tools/gpg-connect-agent")
     (gpgconf "GPGCONF" "tools/gpgconf")
     (gpg-preset-passphrase "GPG_PRESET_PASSPHRASE"
@@ -67,7 +65,7 @@
     (gpg-zip "GPGZIP" "tools/gpg-zip")
     (pinentry "PINENTRY" "tests/openpgp/fake-pinentry")))
 
-(define (tool which)
+(define (tool-hardcoded which)
   (let ((t (assoc which tools))
 	(prefix (getenv "BIN_PREFIX")))
     (getenv' (cadr t)
@@ -75,6 +73,24 @@
 			  (string-append (getenv "objdir") "/" (caddr t))
 			  (string-append prefix "/" (basename (caddr t))))))))
 
+(define (gpg-conf . args)
+  (let ((s (call-popen `(,(tool-hardcoded 'gpgconf) , at args) "")))
+    (map (lambda (line) (string-split line #\:))
+	 (string-split-newlines s))))
+(define :gc:c:name car)
+(define :gc:c:description cadr)
+(define :gc:c:pgmname caddr)
+
+(setenv "GNUPG_BUILDDIR" (getenv "objdir") #t)
+(define gpg-components (gpg-conf '--build-prefix (getenv "objdir")
+				 '--list-components))
+
+(define (tool which)
+  (case which
+    ((gpg gpg-agent scdaemon gpgsm dirmngr)
+     (:gc:c:pgmname (assoc (symbol->string which) gpg-components)))
+    (else
+     (tool-hardcoded which))))
 
 (define (gpg-has-option? option)
   (string-contains? (call-popen `(,(tool 'gpg) --dump-options) "")
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index 5f7912a..d056f4f 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -44,6 +44,7 @@ enum cmd_and_opt_values
     oNull       = '0',
     oNoVerbose	= 500,
     oHomedir,
+    oBuilddir,
 
     aListComponents,
     aCheckPrograms,
@@ -98,6 +99,7 @@ static ARGPARSE_OPTS opts[] =
     { oRuntime, "runtime",  0, N_("activate changes at runtime, if possible") },
     /* hidden options */
     { oHomedir, "homedir", 2, "@" },
+    { oBuilddir, "build-prefix", 2, "@" },
     { oNull, "null", 0, "@" },
     { oNoVerbose, "no-verbose",  0, "@"},
     {0}
@@ -483,6 +485,7 @@ main (int argc, char **argv)
         case oVerbose:   opt.verbose++; break;
         case oNoVerbose: opt.verbose = 0; break;
         case oHomedir:   gnupg_set_homedir (pargs.r.ret_str); break;
+        case oBuilddir:  gnupg_set_builddir (pargs.r.ret_str); break;
         case oNull:      opt.null = 1; break;
 
 	case aListDirs:

commit 55dc81125abc43cd3cc8db951fc3b8a81767942d
Author: Justus Winter <justus at g10code.com>
Date:   Wed Dec 14 11:45:52 2016 +0100

    tests: Rework check for trust models.
    
    * tests/openpgp/defs.scm (gpg-has-option?): New function.
    (have-opt-always-trust): Use a simpler test for that option.  This way
    that is less distracting when we run the tests with verbose=3.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index b198cdd..5249ca9 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -76,9 +76,14 @@
 			  (string-append prefix "/" (basename (caddr t))))))))
 
 
-(define have-opt-always-trust
+(define (gpg-has-option? option)
   (string-contains? (call-popen `(,(tool 'gpg) --dump-options) "")
-			"--always-trust"))
+		    option))
+
+(define have-opt-always-trust
+  (catch #f
+	 (call-check `(,(tool 'gpg) --gpgconf-test --always-trust))
+	 #t))
 
 (define GPG `(,(tool 'gpg) --no-permission-warning
 	      ,@(if have-opt-always-trust '(--always-trust) '())))

commit d6e332422f7a8adc01a45685b067b977e28444e2
Author: Justus Winter <justus at g10code.com>
Date:   Wed Dec 14 11:35:44 2016 +0100

    common: Fix typo.
    
    --
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/common/util.h b/common/util.h
index a7d7e86..2ff2bbc 100644
--- a/common/util.h
+++ b/common/util.h
@@ -281,7 +281,7 @@ const char *gnupg_messages_locale_name (void);
    logging subsystem. */
 void setup_libgcrypt_logging (void);
 
-/* Print an out of core emssage and die.  */
+/* Print an out of core message and die.  */
 void xoutofcore (void);
 
 /* Same as estream_asprintf but die on memory failure.  */

-----------------------------------------------------------------------

Summary of changes:
 common/homedir.c                        |  81 ++++++++++++----
 common/util.h                           |   3 +-
 configure.ac                            |   1 +
 tests/Makefile.am                       |   2 +-
 tests/{migrations => gpgme}/Makefile.am |  47 +++++----
 tests/gpgme/gpgme-defs.scm              | 167 ++++++++++++++++++++++++++++++++
 tests/gpgme/run-tests.scm               |  69 +++++++++++++
 tests/{openpgp => gpgme}/setup.scm      |  17 ++--
 tests/gpgme/wrap.scm                    |  60 ++++++++++++
 tests/openpgp/defs.scm                  |  33 +++++--
 tools/gpgconf.c                         |   3 +
 11 files changed, 428 insertions(+), 55 deletions(-)
 copy tests/{migrations => gpgme}/Makefile.am (56%)
 create mode 100644 tests/gpgme/gpgme-defs.scm
 create mode 100644 tests/gpgme/run-tests.scm
 copy tests/{openpgp => gpgme}/setup.scm (63%)
 mode change 100755 => 100644
 create mode 100644 tests/gpgme/wrap.scm


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list