diff options
Diffstat (limited to 'g10/test.c')
-rw-r--r-- | g10/test.c | 30 |
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[]) { |