gnunet-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-developers] Incorrect test environments


From: Ludovic Courtès
Subject: [GNUnet-developers] Incorrect test environments
Date: Mon, 25 Aug 2008 21:55:08 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Hi again,

While packaging GNUnet for NixOS, I tried running the test suite without
much success.  Builds are done in a chroot, which helps catch errors.

The most common problem that I've found is tests not being executed in
the right environment: for instance, $LTDL_LIBRARY_PATH doesn't contain
the directory where needed modules live, $PATH doesn't contain the
`gnunetd' directory, etc.

In addition, core GNUnet libraries do not honor $TMPDIR (the build
chroot doesn't have `/tmp' and expects applications to honor it; it's a
nice thing to have anyway, and it pleases SuSv2 [0]).

Patches are attached.  The test-related patches are against
`Makefile.in' can be easily adapted to `.am'.  It's not a complete list
of fixes as I eventually gave up trying to run the test-suite due to
lack of time.

Besides, any idea of which tests are likely to fail within a chroot?
Likewise, are there tests that rely on a network connection?

Thanks,
Ludovic.

[0] http://www.opengroup.org/onlinepubs/000095399/xrat/xbd_chap10.html

Make sure the core libraries used by the tests honor $TMPDIR.

diff --git a/src/applications/dstore_sqlite/dstore.c 
b/src/applications/dstore_sqlite/dstore.c
index cdcae81..4bb45a3 100644
--- a/src/applications/dstore_sqlite/dstore.c
+++ b/src/applications/dstore_sqlite/dstore.c
@@ -129,6 +129,7 @@ db_reset ()
   int fd;
   sqlite3 *dbh;
   char *tmpl;
+  const char *tmpdir;
 
   if (fn != NULL)
     {
@@ -136,7 +137,15 @@ db_reset ()
       GNUNET_free (fn);
     }
   payload = 0;
-  tmpl = "/tmp/dstoreXXXXXX";
+
+  tmpdir = getenv ("TMPDIR");
+  tmpdir = tmpdir ? tmpdir : "/tmp";
+
+#define TEMPLATE "/gnunet-dstoreXXXXXX"
+  tmpl = alloca (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
+  strcpy (tmpl, tmpdir);
+  strcat (tmpl, TEMPLATE);
+#undef TEMPLATE
 
 #ifdef MINGW
   fn = (char *) GNUNET_malloc (MAX_PATH + 1);
diff --git a/src/applications/fs/collection/collection.c 
b/src/applications/fs/collection/collection.c
index 5671cb3..da2b605 100644
--- a/src/applications/fs/collection/collection.c
+++ b/src/applications/fs/collection/collection.c
@@ -487,6 +487,7 @@ GNUNET_CO_collection_publish_now ()
   char *dirData;
   char this_revision_string[128];
   char next_revision_string[128];
+  const char *tmpdir;
 
   GNUNET_mutex_lock (lock);
   if ((collectionData == NULL) ||
@@ -495,7 +496,17 @@ GNUNET_CO_collection_publish_now ()
       GNUNET_mutex_unlock (lock);
       return;
     }
-  tmpName = GNUNET_strdup ("/tmp/gnunet-collectionXXXXXX");
+
+  tmpdir = getenv ("TMPDIR");
+  tmpdir = tmpdir ? tmpdir : "/tmp";
+
+#define TEMPLATE "/gnunet-collectionXXXXXX"
+  tmpName = alloca (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
+  strcpy (tmpName, tmpdir);
+  strcat (tmpName, TEMPLATE);
+#undef TEMPLATE
+
+  tmpName = GNUNET_strdup (tmpName);
   fd = mkstemp (tmpName);
   if (fd == -1)
     {
diff --git a/src/applications/fs/fsui/upload.c 
b/src/applications/fs/fsui/upload.c
index dc683a5..46a04af 100644
--- a/src/applications/fs/fsui/upload.c
+++ b/src/applications/fs/fsui/upload.c
@@ -159,6 +159,7 @@ createDirectoryHelper (struct GNUNET_GE_Context *ectx,
   int handle;
   struct GNUNET_GE_Memory *mem;
   struct GNUNET_GE_Context *ee;
+  const char *tmpdir;
 
   fis = NULL;
   size = 0;
@@ -208,7 +209,17 @@ createDirectoryHelper (struct GNUNET_GE_Context *ectx,
       pos = pos->next;
     }
   GNUNET_GE_memory_reset (mem);
-  tempName = GNUNET_strdup ("/tmp/gnunet-upload-dir.XXXXXX");
+
+  tmpdir = getenv ("TMPDIR");
+  tmpdir = tmpdir ? tmpdir : "/tmp";
+
+#define TEMPLATE "/gnunet-upload-dirXXXXXX"
+  tempName = alloca (strlen (tmpdir) + sizeof (TEMPLATE) + 1);
+  strcpy (tempName, tmpdir);
+  strcat (tempName, TEMPLATE);
+#undef TEMPLATE
+
+  tempName = GNUNET_strdup (tempName);
   handle = mkstemp (tempName);
   if (handle == -1)
     {
That test tries to load `libgnunetmodule_transport' but cannot locate it
out of the box.

diff --git a/src/applications/identity/Makefile.in 
b/src/applications/identity/Makefile.in
index 0bc5efc..5341f41 100644
--- a/src/applications/identity/Makefile.in
+++ b/src/applications/identity/Makefile.in
@@ -337,6 +337,11 @@ libgnunetidentity_api_la_LIBADD = \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 TESTS = $(check_PROGRAMS)
+
+# Allow `libgnunetmodule_transport' et al. to be located
+# by `GNUNET_CORE_p2p_init ()'.
+TESTS_ENVIRONMENT = 
LTDL_LIBRARY_PATH="$(top_builddir)/src/applications/transport:$(top_builddir)/src/transports:$(top_builddir)/src/transports/upnp:$(top_builddir)/src/applications/stats"
+
 identitytest_SOURCES = \
  identitytest.c 
 
Allow session tests to locate and run `gnunetd'.

diff --git a/src/applications/session/Makefile.in 
b/src/applications/session/Makefile.in
index b2717f9..3478aa8 100644
--- a/src/applications/session/Makefile.in
+++ b/src/applications/session/Makefile.in
@@ -352,6 +352,10 @@ libgnunetmodule_session_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 
 @address@hidden = sessiontest_http sessiontest_nat_http
+
+# Allow `gnunetd' to be located and executed.
+TESTS_ENVIRONMENT = PATH="$(top_builddir)/src/server:$$PATH" 
LTDL_LIBRARY_PATH="$(top_builddir)/src/applications/identity"
+
 TESTS = $(check_PROGRAMS)
 sessiontest_tcp_SOURCES = \
   sessiontest.c 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]