mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
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>
This commit is contained in:
parent
fbf24cd09a
commit
e92a8ab021
@ -19,9 +19,9 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = options.skel distsigkey.gpg ChangeLog-2011 gpg-w32info.rc \
|
||||
gpg.w32-manifest.in test.c
|
||||
gpg.w32-manifest.in test.c t-keydb-keyring.kbx
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/common -DSOURCE_DIR="\"$(srcdir)\""
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/common
|
||||
|
||||
include $(top_srcdir)/am/cmacros.am
|
||||
|
||||
|
@ -30,11 +30,14 @@ do_test (int argc, char *argv[])
|
||||
KBNODE kb1, kb2;
|
||||
char *uid1;
|
||||
char *uid2;
|
||||
char *fname;
|
||||
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
rc = keydb_add_resource (SOURCE_DIR "/t-keydb-keyring.kbx", 0);
|
||||
fname = prepend_srcdir ("t-keydb-keyring.kbx");
|
||||
rc = keydb_add_resource (fname, 0);
|
||||
test_free (fname);
|
||||
if (rc)
|
||||
ABORT ("Failed to open keyring.");
|
||||
|
||||
|
30
g10/test.c
30
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[])
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user