[git] GnuPG - branch, master, updated. gnupg-2.1.15-67-g65a7563

by Justus Winter cvs at cvs.gnupg.org
Mon Sep 5 14:05:59 CEST 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  65a7563edbbab8f93fe901f932065687508788de (commit)
       via  059c79d8b447a3baa9ad0b4d3367bdb64dd2ef3b (commit)
       via  e33111fcdac08ed2ddfbdf59b1f790569b42f695 (commit)
       via  c39be0add8835c9bcc25bdd40e99e828aca56204 (commit)
      from  de623474db3ba402c9bbd872ab6f932f46cbdde9 (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 65a7563edbbab8f93fe901f932065687508788de
Author: Justus Winter <justus at g10code.com>
Date:   Mon Sep 5 13:59:29 2016 +0200

    tests: Update README.
    
    * tests/openpgp/README: Update.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/README b/tests/openpgp/README
index 9b384be..84faf1c 100644
--- a/tests/openpgp/README
+++ b/tests/openpgp/README
@@ -1,22 +1,36 @@
 #                                   Emacs, this is an -*- org -*- file.
 
 * How to run the test suite
-** using the legacy driver
-On POSIX you can just use
+From your build directory, run
 
-  $ make -C tests/openpgp check
+  obj $ make -C tests/openpgp check
 
-or
+to run all tests or
 
-  $ make -C tests/openpgp check XTESTS="setup.scm your-test.scm finish.scm"
+  obj $ make -C tests/openpgp check XTESTS=your-test.scm
 
-as before.
-** using the Scheme driver
+to run a specific test (or any number of tests separated by spaces).
+
+If you want to debug a test, add verbose=1 to see messages printed by
+spawned programs to their standard error stream, verbose=2 to see what
+programs are executed, or verbose=3 to see even more program output
+and exit codes.
+
+** Passing options to the test driver
+
+You can set TESTFLAGS to pass flags to 'run-tests.scm'.  For example,
+to speed up the test suite when bisecting, do
+
+  obj $ make -C tests/openpgp check TESTFLAGS=--parallel
+
+See below for the arguments supported by the driver.
+
+** Calling the test driver directly
 This is a bit tricky because one needs to manually set some
 environment variables.  We should make that easier.  See discussion
 below.  From your build directory, do:
 
-  obj $ srcdir=<path to>/tests/openpgp \
+  obj $ TMP=/tmp srcdir=<path to>/tests/openpgp \
         GPGSCM_PATH=<path to>/tests/gpgscm:<path to>/tests/openpgp \
         $(pwd)/tests/gpgscm/gpgscm [gpgscm args] \
         run-tests.scm [test suite runner args]

commit 059c79d8b447a3baa9ad0b4d3367bdb64dd2ef3b
Author: Justus Winter <justus at g10code.com>
Date:   Mon Sep 5 13:58:37 2016 +0200

    tests: Pass flags to test driver.
    
    * tests/openpgp/Makefile.am (xcheck): Pass flags to 'run-tests.scm'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index 5d8acbf..43de31e 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -98,7 +98,7 @@ check: xcheck
 .PHONY: xcheck
 xcheck:
 	$(TESTS_ENVIRONMENT) $(abs_top_builddir)/tests/gpgscm/gpgscm \
-	  run-tests.scm $(XTESTS)
+	  run-tests.scm $(TESTFLAGS) $(XTESTS)
 
 TEST_FILES = pubring.asc secring.asc plain-1o.asc plain-2o.asc plain-3o.asc \
 	     plain-1.asc plain-2.asc plain-3.asc plain-1-pgp.asc \

commit e33111fcdac08ed2ddfbdf59b1f790569b42f695
Author: Justus Winter <justus at g10code.com>
Date:   Mon Sep 5 13:50:17 2016 +0200

    common: Improve waiting for processes on POSIX.
    
    * common/exechelp-posix.c (struct terminated_child): New definition.
    (terminated_children): New variable.
    (store_result): New function.
    (get_result): Likewise.
    (gnupg_wait_process): Store results that were not requested and
    consider previously stored results.
    
    waitpid(2) may return information about terminated children that we
    did not yet request, and there is no portable way to wait for a
    specific set of children.  As a workaround, we store the results of
    children for later use.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c
index 943f20a..32c4203 100644
--- a/common/exechelp-posix.c
+++ b/common/exechelp-posix.c
@@ -583,6 +583,66 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
 }
 
 
+

+
+/* Waiting for child processes.
+
+   waitpid(2) may return information about terminated children that we
+   did not yet request, and there is no portable way to wait for a
+   specific set of children.
+
+   As a workaround, we store the results of children for later use.
+
+   XXX: This assumes that PIDs are not reused too quickly.  */
+
+struct terminated_child
+{
+  pid_t pid;
+  int exitcode;
+  struct terminated_child *next;
+};
+
+struct terminated_child *terminated_children;
+
+
+static gpg_error_t
+store_result (pid_t pid, int exitcode)
+{
+  struct terminated_child *c;
+
+  c = xmalloc (sizeof *c);
+  if (c == NULL)
+    return gpg_err_code_from_syserror ();
+
+  c->pid = pid;
+  c->exitcode = exitcode;
+  c->next = terminated_children;
+  terminated_children = c;
+
+  return 0;
+}
+
+
+static int
+get_result (pid_t pid, int *r_exitcode)
+{
+  struct terminated_child *c, **prevp;
+
+  for (prevp = &terminated_children, c = terminated_children;
+       c;
+       prevp = &c->next, c = c->next)
+    if (c->pid == pid)
+      {
+        *prevp = c->next;
+        *r_exitcode = c->exitcode;
+        xfree (c);
+        return 1;
+      }
+
+  return 0;
+}
+
+
 /* See exechelp.h for a description.  */
 gpg_error_t
 gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
@@ -597,17 +657,25 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
 {
   gpg_err_code_t ec = 0;
   size_t i, left;
+  int *dummy = NULL;
 
-  for (i = 0; i < count; i++)
+  if (r_exitcodes == NULL)
+    dummy = r_exitcodes = xmalloc (sizeof *r_exitcodes * count);
+
+  for (i = 0, left = count; i < count; i++)
     {
-      if (r_exitcodes)
-        r_exitcodes[i] = -1;
+      int status = -1;
 
       if (pids[i] == (pid_t)(-1))
         return my_error (GPG_ERR_INV_VALUE);
+
+      /* See if there was a previously stored result for this pid.  */
+      if (get_result (pids[i], &status))
+        left -= 1;
+
+      r_exitcodes[i] = status;
     }
 
-  left = count;
   while (left > 0)
     {
       pid_t pid;
@@ -639,43 +707,57 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
               break;
 
           if (i == count)
-            /* No match, ignore this pid.  */
-            continue;
-
-          /* Process PIDS[i] died.  */
-          left -= 1;
-
-          if (WIFEXITED (status) && WEXITSTATUS (status) == 127)
             {
-              log_error (_("error running '%s': probably not installed\n"),
-                         pgmnames[i]);
-              ec = GPG_ERR_CONFIGURATION;
-            }
-          else if (WIFEXITED (status) && WEXITSTATUS (status))
-            {
-              if (!r_exitcodes)
-                log_error (_("error running '%s': exit status %d\n"),
-                           pgmnames[i], WEXITSTATUS (status));
-              else
-                r_exitcodes[i] = WEXITSTATUS (status);
-              ec = GPG_ERR_GENERAL;
+              /* No match, store this result.  */
+              ec = store_result (pid, status);
+              if (ec)
+                break;
+              continue;
             }
-          else if (!WIFEXITED (status))
+
+          /* Process PIDS[i] died.  */
+          if (r_exitcodes[i] != (pid_t) -1)
             {
-              log_error (_("error running '%s': terminated\n"), pgmnames[i]);
+              log_error ("PID %d was reused", pid);
               ec = GPG_ERR_GENERAL;
+              break;
             }
-          else
-            {
-              if (r_exitcodes)
-                r_exitcodes[i] = 0;
-            }
+
+          left -= 1;
+          r_exitcodes[i] = status;
         }
     }
 
+  if (ec == 0)
+    for (i = 0; i < count; i++)
+      {
+        if (WIFEXITED (r_exitcodes[i]) && WEXITSTATUS (r_exitcodes[i]) == 127)
+          {
+            log_error (_("error running '%s': probably not installed\n"),
+                       pgmnames[i]);
+            ec = GPG_ERR_CONFIGURATION;
+          }
+        else if (WIFEXITED (r_exitcodes[i]) && WEXITSTATUS (r_exitcodes[i]))
+          {
+            if (dummy)
+              log_error (_("error running '%s': exit status %d\n"),
+                         pgmnames[i], WEXITSTATUS (r_exitcodes[i]));
+            else
+              r_exitcodes[i] = WEXITSTATUS (r_exitcodes[i]);
+            ec = GPG_ERR_GENERAL;
+          }
+        else if (!WIFEXITED (r_exitcodes[i]))
+          {
+            log_error (_("error running '%s': terminated\n"), pgmnames[i]);
+            ec = GPG_ERR_GENERAL;
+          }
+      }
+
+  xfree (dummy);
   return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec);
 }
 
+

 
 void
 gnupg_release_process (pid_t pid)

commit c39be0add8835c9bcc25bdd40e99e828aca56204
Author: Justus Winter <justus at g10code.com>
Date:   Mon Sep 5 11:22:10 2016 +0200

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

diff --git a/common/get-passphrase.c b/common/get-passphrase.c
index 8f3137b..68361ec 100644
--- a/common/get-passphrase.c
+++ b/common/get-passphrase.c
@@ -203,7 +203,7 @@ gnupg_get_passphrase (const char *cache_id,
                          default_inq_cb, NULL, NULL, NULL);
 
   /* Older Pinentries return the old assuan error code for canceled
-     which gets translated bt libassuan to GPG_ERR_ASS_CANCELED and
+     which gets translated by libassuan to GPG_ERR_ASS_CANCELED and
      not to the code for a user cancel.  Fix this here. */
   if (err && gpg_err_source (err)
       && gpg_err_code (err) == GPG_ERR_ASS_CANCELED)

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

Summary of changes:
 common/exechelp-posix.c   | 142 ++++++++++++++++++++++++++++++++++++----------
 common/get-passphrase.c   |   2 +-
 tests/openpgp/Makefile.am |   2 +-
 tests/openpgp/README      |  30 +++++++---
 4 files changed, 136 insertions(+), 40 deletions(-)


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




More information about the Gnupg-commits mailing list