diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run-identify.c | 2 | ||||
-rw-r--r-- | tests/run-support.h | 18 | ||||
-rw-r--r-- | tests/t-data.c | 27 |
3 files changed, 20 insertions, 27 deletions
diff --git a/tests/run-identify.c b/tests/run-identify.c index 01e9671f..9361fa2d 100644 --- a/tests/run-identify.c +++ b/tests/run-identify.c @@ -102,7 +102,7 @@ main (int argc, char **argv) } - init_gpgme (GPGME_PROTOCOL_OpenPGP); + init_gpgme_basic (); for (; argc; argc--, argv++) { diff --git a/tests/run-support.h b/tests/run-support.h index 841b2232..6a2170b0 100644 --- a/tests/run-support.h +++ b/tests/run-support.h @@ -107,7 +107,11 @@ make_filename (const char *fname) srcdir = "."; buf = malloc (strlen(srcdir) + strlen(fname) + 2); if (!buf) - exit (8); + { + fprintf (stderr, "%s:%d: could not allocate string: %s\n", + __FILE__, __LINE__, strerror (errno)); + exit (8); + } strcpy (buf, srcdir); strcat (buf, "/"); strcat (buf, fname); @@ -116,17 +120,23 @@ make_filename (const char *fname) void -init_gpgme (gpgme_protocol_t proto) +init_gpgme_basic (void) { - gpgme_error_t err; - gpgme_check_version (NULL); setlocale (LC_ALL, ""); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); #ifndef HAVE_W32_SYSTEM gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); #endif +} + + +void +init_gpgme (gpgme_protocol_t proto) +{ + gpg_error_t err; + init_gpgme_basic (); err = gpgme_engine_check_version (proto); fail_if_err (err); } diff --git a/tests/t-data.c b/tests/t-data.c index fe2d59ed..c214de7b 100644 --- a/tests/t-data.c +++ b/tests/t-data.c @@ -30,8 +30,10 @@ #include <string.h> #include <errno.h> -#include <gpgme.h> +#define PGM "t-data" +#include "run-support.h" +#undef fail_if_err #define fail_if_err(a) do { if(a) { \ fprintf (stderr, "%s:%d: (%i) gpgme_error_t " \ "%s\n", __FILE__, __LINE__, round, \ @@ -39,27 +41,6 @@ exit (1); } \ } while(0) -static char * -make_filename (const char *fname) -{ - const char *srcdir = getenv ("srcdir"); - char *buf; - - if (!srcdir) - srcdir = "."; - buf = malloc (strlen(srcdir) + strlen(fname) + 2 ); - if (!buf) - { - fprintf (stderr, "%s:%d: could not allocate string: %s\n", - __FILE__, __LINE__, strerror (errno)); - exit (1); - } - strcpy (buf, srcdir); - strcat (buf, "/"); - strcat (buf, fname); - return buf; -} - typedef enum { TEST_INITIALIZER, @@ -203,6 +184,8 @@ main (void) gpgme_error_t err = 0; gpgme_data_t data; + init_gpgme_basic (); + while (++round) { switch (round) |