[git] GPGME - branch, aheinecke/json-test, updated. gpgme-1.12.0-68-g004e2ca

by Andre Heinecke cvs at cvs.gnupg.org
Thu Nov 15 10:36:08 CET 2018


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 "GnuPG Made Easy".

The branch, aheinecke/json-test has been updated
       via  004e2cad2f26250cd010684f11dc187f08e6f9e1 (commit)
       via  40d962b43a183070ba8602cac1e83f2292ebf2c3 (commit)
      from  d3dae4a445d950c94c952ddf54e534ef71675bd1 (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 004e2cad2f26250cd010684f11dc187f08e6f9e1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 15 10:33:35 2018 +0100

    tests,json: Clean openpgp-revocs.d
    
    * tests/json/clean-local: Remove revocs.d

diff --git a/tests/json/Makefile.am b/tests/json/Makefile.am
index 3439ff7..61c3e24 100644
--- a/tests/json/Makefile.am
+++ b/tests/json/Makefile.am
@@ -77,6 +77,7 @@ noinst_PROGRAMS = $(c_tests)
 clean-local:
 	-$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop
 	-rm -fR private-keys-v1.d
+	-rm -fR openpgp-revocs.d
 
 gpg-sample.stamp: $(private_keys)
 	-$(TESTS_ENVIRONMENT) gpgconf --kill all

commit 40d962b43a183070ba8602cac1e83f2292ebf2c3
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 15 10:31:22 2018 +0100

    tests,json: Move version check into t-json
    
    * tests/gpg/t-support.h (check_gpg_version, compare_versions),
    (parse_version_string, parse_version_number): Remove version
    check code.
    * tests/json/t-json.c (check_gpg_version, compare_versions),
    (parse_version_string, parse_version_number): Add.
    --
    
    t-support header was not a good place for this. It should
    go into a library e.g. gpgrt in the future. For now we
    can keep it close to where it is needed.

diff --git a/tests/gpg/t-support.h b/tests/gpg/t-support.h
index a1536c1..b6ad515 100644
--- a/tests/gpg/t-support.h
+++ b/tests/gpg/t-support.h
@@ -216,106 +216,3 @@ print_import_result (gpgme_import_result_t r)
           r->not_imported,
           r->skipped_v3_keys);
 }
-
-
-/* Read the next number in the version string STR and return it in
-   *NUMBER.  Return a pointer to the tail of STR after parsing, or
-   *NULL if the version string was invalid.  */
-static const char *
-parse_version_number (const char *str, int *number)
-{
-#define MAXVAL ((INT_MAX - 10) / 10)
-  int val = 0;
-
-  /* Leading zeros are not allowed.  */
-  if (*str == '0' && isdigit(str[1]))
-    return NULL;
-
-  while (isdigit (*str) && val <= MAXVAL)
-    {
-      val *= 10;
-      val += *(str++) - '0';
-    }
-  *number = val;
-  return val > MAXVAL ? NULL : str;
-}
-
-
-/* Parse the version string STR in the format MAJOR.MINOR.MICRO (for
-   example, 9.3.2) and return the components in MAJOR, MINOR and MICRO
-   as integers.  The function returns the tail of the string that
-   follows the version number.  This might be the empty string if there
-   is nothing following the version number, or a patchlevel.  The
-   function returns NULL if the version string is not valid.  */
-static const char *
-parse_version_string (const char *str, int *major, int *minor, int *micro)
-{
-  str = parse_version_number (str, major);
-  if (!str || *str != '.')
-    return NULL;
-  str++;
-
-  str = parse_version_number (str, minor);
-  if (!str || *str != '.')
-    return NULL;
-  str++;
-
-  str = parse_version_number (str, micro);
-  if (!str)
-    return NULL;
-
-  /* A patchlevel might follow.  */
-  return str;
-}
-
-
-/* Return true if MY_VERSION is at least REQ_VERSION, and false
-   otherwise.  */
-static int
-compare_versions (const char *my_version,
-                  const char *rq_version)
-{
-  int my_major, my_minor, my_micro;
-  int rq_major, rq_minor, rq_micro;
-  const char *my_plvl, *rq_plvl;
-
-  if (!rq_version)
-    return 1;
-  if (!my_version)
-    return 0;
-
-  my_plvl = parse_version_string (my_version, &my_major, &my_minor, &my_micro);
-  if (!my_plvl)
-    return 0;
-
-  rq_plvl = parse_version_string (rq_version, &rq_major, &rq_minor, &rq_micro);
-  if (!rq_plvl)
-    return 0;
-
-  if (my_major > rq_major
-      || (my_major == rq_major && my_minor > rq_minor)
-      || (my_major == rq_major && my_minor == rq_minor
-	  && my_micro > rq_micro)
-      || (my_major == rq_major && my_minor == rq_minor
-	  && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0))
-    return 1;
-
-  return 0;
-}
-
-/* Return true if we have the required gpg version. */
-static int
-check_gpg_version (const char *req_version)
-{
-  gpgme_engine_info_t engine_info;
-  init_gpgme (GPGME_PROTOCOL_OpenPGP);
-
-  fail_if_err (gpgme_get_engine_info (&engine_info));
-  for (; engine_info; engine_info = engine_info->next)
-    if (engine_info->protocol == GPGME_PROTOCOL_OpenPGP)
-      break;
-
-  test (engine_info);
-
-  return compare_versions (engine_info->version, req_version);
-}
diff --git a/tests/json/t-json.c b/tests/json/t-json.c
index 024b255..77750ad 100644
--- a/tests/json/t-json.c
+++ b/tests/json/t-json.c
@@ -48,6 +48,112 @@ static const char*tests[] = { "t-config", "t-version",
 
 static int verbose = 0;
 
+
+/* Read the next number in the version string STR and return it in
+   *NUMBER.  Return a pointer to the tail of STR after parsing, or
+   *NULL if the version string was invalid.  */
+static const char *
+parse_version_number (const char *str, int *number)
+{
+#define MAXVAL ((INT_MAX - 10) / 10)
+  int val = 0;
+
+  /* Leading zeros are not allowed.  */
+  if (*str == '0' && isdigit(str[1]))
+    return NULL;
+
+  while (isdigit (*str) && val <= MAXVAL)
+    {
+      val *= 10;
+      val += *(str++) - '0';
+    }
+  *number = val;
+  return val > MAXVAL ? NULL : str;
+}
+
+
+/* Parse the version string STR in the format MAJOR.MINOR.MICRO (for
+   example, 9.3.2) and return the components in MAJOR, MINOR and MICRO
+   as integers.  The function returns the tail of the string that
+   follows the version number.  This might be the empty string if there
+   is nothing following the version number, or a patchlevel.  The
+   function returns NULL if the version string is not valid.  */
+static const char *
+parse_version_string (const char *str, int *major, int *minor, int *micro)
+{
+  str = parse_version_number (str, major);
+  if (!str || *str != '.')
+    return NULL;
+  str++;
+
+  str = parse_version_number (str, minor);
+  if (!str || *str != '.')
+    return NULL;
+  str++;
+
+  str = parse_version_number (str, micro);
+  if (!str)
+    return NULL;
+
+  /* A patchlevel might follow.  */
+  return str;
+}
+
+
+/* Return true if MY_VERSION is at least REQ_VERSION, and false
+   otherwise.  */
+static int
+compare_versions (const char *my_version,
+                  const char *rq_version)
+{
+  int my_major, my_minor, my_micro;
+  int rq_major, rq_minor, rq_micro;
+  const char *my_plvl, *rq_plvl;
+
+  if (!rq_version)
+    return 1;
+  if (!my_version)
+    return 0;
+
+  my_plvl = parse_version_string (my_version, &my_major, &my_minor, &my_micro);
+  if (!my_plvl)
+    return 0;
+
+  rq_plvl = parse_version_string (rq_version, &rq_major, &rq_minor, &rq_micro);
+  if (!rq_plvl)
+    return 0;
+
+  if (my_major > rq_major
+      || (my_major == rq_major && my_minor > rq_minor)
+      || (my_major == rq_major && my_minor == rq_minor
+	  && my_micro > rq_micro)
+      || (my_major == rq_major && my_minor == rq_minor
+	  && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0))
+    return 1;
+
+  return 0;
+}
+
+/* Return true if we have the required gpg version.
+
+   This should probably go into gpgrt or gpgme proper.
+*/
+static int
+check_gpg_version (const char *req_version)
+{
+  gpgme_engine_info_t engine_info;
+  init_gpgme (GPGME_PROTOCOL_OpenPGP);
+
+  fail_if_err (gpgme_get_engine_info (&engine_info));
+  for (; engine_info; engine_info = engine_info->next)
+    if (engine_info->protocol == GPGME_PROTOCOL_OpenPGP)
+      break;
+
+  test (engine_info);
+
+  return compare_versions (engine_info->version, req_version);
+}
+
 static char *
 get_file (const char *fname)
 {

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

Summary of changes:
 tests/gpg/t-support.h  | 103 -----------------------------------------------
 tests/json/Makefile.am |   1 +
 tests/json/t-json.c    | 106 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 103 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list