summaryrefslogtreecommitdiffstats
path: root/g10/test.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-09-10 18:11:58 +0200
committerWerner Koch <wk@gnupg.org>2015-09-10 18:12:20 +0200
commite92a8ab021672b19e5cd397fa555fcc8a3401e8b (patch)
treedbf55296b6539a5d0c54246d1706501949618c14 /g10/test.c
parentg10: Improve portability of the new test driver. (diff)
downloadgnupg2-e92a8ab021672b19e5cd397fa555fcc8a3401e8b.tar.xz
gnupg2-e92a8ab021672b19e5cd397fa555fcc8a3401e8b.zip
g10: Fix make distcheck problem.
* g10/test.c: Include string.h. (prepend_srcdir): New. Taken from Libgcrypt. (test_free): New. * g10/t-keydb.c (do_test): Malloc the filename. * g10/Makefile.am (AM_CPPFLAGS): Remove -DSOURCE_DIR (EXTRA_DIST): Add t-keydb-keyring.kbx. -- Using SOURCE_DIR should in general work but we have seen problems when doing this in Libgcrypt. Using the srcdir variable gives us anyway more flexibility and aligns with the way we do it in tests/openpgp. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/test.c')
-rw-r--r--g10/test.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/g10/test.c b/g10/test.c
index e9e6b2342..59a015ca6 100644
--- a/g10/test.c
+++ b/g10/test.c
@@ -20,6 +20,7 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gpg.h"
@@ -138,6 +139,35 @@ exit_tests (int force)
}
}
+
+/* Prepend FNAME with the srcdir environment variable's value and
+ return a malloced filename. Caller must release the returned
+ string using test_free. */
+char *
+prepend_srcdir (const char *fname)
+{
+ static const char *srcdir;
+ char *result;
+
+ if (!srcdir && !(srcdir = getenv ("srcdir")))
+ srcdir = ".";
+
+ result = malloc (strlen (srcdir) + 1 + strlen (fname) + 1);
+ strcpy (result, srcdir);
+ strcat (result, "/");
+ strcat (result, fname);
+ return result;
+}
+
+
+void
+test_free (void *a)
+{
+ if (a)
+ free (a);
+}
+
+
int
main (int argc, char *argv[])
{