diff options
author | Werner Koch <[email protected]> | 2017-12-04 11:08:31 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-12-04 11:08:31 +0000 |
commit | 0c1244a2b7e30ab0610ae70166e1b5d0219782c3 (patch) | |
tree | 138353cb937071ed0cd7e37cbb58fb38ce3eafbe /tests/t-data.c | |
parent | python: Default whence argument for Data() to SEEK_SET. (diff) | |
download | gpgme-0c1244a2b7e30ab0610ae70166e1b5d0219782c3.tar.gz gpgme-0c1244a2b7e30ab0610ae70166e1b5d0219782c3.zip |
core: Also check for a failed selftest in gpgm_data_new.
* src/data.c (_gpgme_data_new): Check for failed selftest.
* tests/run-support.h (make_filename): Print a message on mallooc
failure.
(init_gpgme_basic): New.
* tests/run-identify.c (main): Call init_gpgme_basic becuase we do not
need to setup a protocol.
* tests/t-data.c: Define PGM and include run-support.h.
(make_filename): Remove.
(main): Call init_gpgme_basic.
--
Note: This patch may break applications which used gpgme_data but no
gpgme_new without having called the required gpgme_check_version.
GPGME can be used without a protocol for example to work with the data
object abstraction. Thus a call to gpgme_data_new also needs to check
the result of the core selftests - including on whether
gpgme_check_version has been called.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tests/t-data.c')
-rw-r--r-- | tests/t-data.c | 27 |
1 files changed, 5 insertions, 22 deletions
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) |