gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r21650 - gnunet/src/testing


From: gnunet
Subject: [GNUnet-SVN] r21650 - gnunet/src/testing
Date: Thu, 31 May 2012 12:40:36 +0200

Author: harsha
Date: 2012-05-31 12:40:36 +0200 (Thu, 31 May 2012)
New Revision: 21650

Modified:
   gnunet/src/testing/test_testing_new_peerstartup.c
   gnunet/src/testing/testing_new.c
Log:
-fixed memory leaks and added windows support for temp dirs

Modified: gnunet/src/testing/test_testing_new_peerstartup.c
===================================================================
--- gnunet/src/testing/test_testing_new_peerstartup.c   2012-05-31 09:47:11 UTC 
(rev 21649)
+++ gnunet/src/testing/test_testing_new_peerstartup.c   2012-05-31 10:40:36 UTC 
(rev 21650)
@@ -50,6 +50,11 @@
    * The peer which has been started by the testing system
    */
   struct GNUNET_TESTING_Peer *peer;
+
+  /**
+   * The running configuration of the peer
+   */
+  struct GNUNET_CONFIGURATION_Handle *cfg;
 };
 
 
@@ -66,6 +71,7 @@
   
   GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_stop (test_ctx->peer));
   GNUNET_TESTING_peer_destroy (test_ctx->peer);
+  GNUNET_CONFIGURATION_destroy (test_ctx->cfg);
   GNUNET_TESTING_hostkeys_unload (test_ctx->system);
   GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES);
   GNUNET_free (test_ctx);
@@ -86,14 +92,28 @@
   char *data_dir;
   char *hostkeys_file;
   char *emsg;
+  char *tmpdir_;
   char *tmpdir;
+#ifdef MINGW
+  char *tmpdir_w;
+#endif
+
   struct GNUNET_PeerIdentity id;
   
-  GNUNET_asprintf (&tmpdir, "%s/%s", P_tmpdir,
-                   "test-gnunet-testing_new-XXXXXX");
+  tmpdir_ = getenv ("TMPDIR");
+  tmpdir_ = tmpdir_ ? tmpdir_ : "/tmp";
+  GNUNET_asprintf (&tmpdir, "%s/%s", tmpdir_, 
"test-gnunet-testing_new-XXXXXX");  
+#ifdef MINGW
+  tmpdir_w = GNUNET_malloc (MAX_PATH + 1);
+  GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w));
+  GNUNET_free (tmpdir);
+  tmpdir = tmpdir_w;
+  GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1));
+#else
   GNUNET_assert (mkdtemp (tmpdir) == tmpdir);
-  /* LOG (GNUNET_ERROR_TYPE_ERROR, */
-  /*      "Temporary directory: %s\n", tmpdir); */
+#endif
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "Temporary directory: %s\n", tmpdir);
   system = GNUNET_TESTING_system_create (tmpdir,
                                          "localhost");
   GNUNET_assert (NULL != system);
@@ -113,6 +133,7 @@
   test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
   test_ctx->system = system;
   test_ctx->peer = peer;
+  test_ctx->cfg = new_cfg;
   GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (5),
                                 &do_shutdown, test_ctx);
   

Modified: gnunet/src/testing/testing_new.c
===================================================================
--- gnunet/src/testing/testing_new.c    2012-05-31 09:47:11 UTC (rev 21649)
+++ gnunet/src/testing/testing_new.c    2012-05-31 10:40:36 UTC (rev 21650)
@@ -592,13 +592,14 @@
       GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "ACCEPT_FROM",
                                              &orig_allowed_hosts))
   {
-    orig_allowed_hosts = "127.0.0.1;";
+    orig_allowed_hosts = GNUNET_strdup ("127.0.0.1;");
   }
   if (NULL == uc->system->controller)
     allowed_hosts = GNUNET_strdup (orig_allowed_hosts);
   else
     GNUNET_asprintf (&allowed_hosts, "%s %s;", orig_allowed_hosts,
                      uc->system->controller);
+  GNUNET_free (orig_allowed_hosts);
   GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, "ACCEPT_FROM",
                                          allowed_hosts);
   GNUNET_free (allowed_hosts);  




reply via email to

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