-minor fixes
authorChristian Grothoff <christian@grothoff.org>
Sun, 10 Jun 2012 01:01:03 +0000 (01:01 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 10 Jun 2012 01:01:03 +0000 (01:01 +0000)
src/testing/test_testing_peerstartup.c
src/testing/test_testing_portreservation.c
src/testing/test_testing_servicestartup.c
src/testing/testing.c

index 13853fe683a32fee3b055e24b51f6304ae969074..990486467d3b074faa191bafee9b80ec46bd738a 100644 (file)
@@ -33,8 +33,6 @@
 #define LOG(kind,...)                           \
   GNUNET_log (kind, __VA_ARGS__)
 
-#define TIME_REL_SEC(sec)                                      \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
 
 /**
  * The testing context
@@ -89,37 +87,11 @@ run (void *cls, char *const *args, const char *cfgfile,
   struct GNUNET_CONFIGURATION_Handle *new_cfg;
   struct TestingContext *test_ctx;
   char *emsg;
-  char *_tmpdir;
-  char *tmpdir;
-#ifdef MINGW
-  char *tmpdir_w;
-#endif
-
   struct GNUNET_PeerIdentity id;
     
-  _tmpdir = getenv ("TMP");
-  if (NULL == _tmpdir)
-    _tmpdir = getenv ("TEMP");  
-  if (NULL == _tmpdir)
-    _tmpdir = getenv ("TMPDIR");
-  if (NULL == _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);
-#endif
-  /* LOG (GNUNET_ERROR_TYPE_ERROR, */
-  /*      "Temporary directory: %s\n", tmpdir); */
-  system = GNUNET_TESTING_system_create (tmpdir,
+  system = GNUNET_TESTING_system_create ("test-gnunet-testing",
                                          "127.0.0.1");
   GNUNET_assert (NULL != system);
-  GNUNET_free (tmpdir);
   new_cfg = GNUNET_CONFIGURATION_dup (cfg);
   emsg = NULL;
   peer = GNUNET_TESTING_peer_configure (system, new_cfg, 0, &id, &emsg);
@@ -130,9 +102,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   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);
-  
+  GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx);
 }
 
 
@@ -150,3 +120,5 @@ int main (int argc, char *argv[])
     return 1;
   return 0;
 }
+
+/* end of test_testing_peerstartup.c */
index 02d6e168674cd94d99779ff13c60b98c23ae0a06..f689f455ab7e1b32ce3e28948b03f7e53896cdd6 100644 (file)
@@ -89,3 +89,5 @@ int main (int argc, char *argv[])
   }
   return 0;
 }
+
+/* end of test_testing_portreservation.c */
index 0d3c6ca13b85ab25e671f56928f75a37b491d7a3..236e8478978c67fd58185196ac0508ae9c41dd27 100644 (file)
@@ -23,7 +23,6 @@
  * @brief test case for testing service startup using new testing API
  * @author Sree Harsha Totakura
  */
-
 #include "platform.h"
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_testing_lib-new.h"
 #define LOG(kind,...)                           \
   GNUNET_log (kind, __VA_ARGS__)
 
-#define TIME_REL_SEC(sec)                                      \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
 
 /**
  * Global test status
  */
 static int test_success;
 
-/**
- * The shutdown task. Used to signal that testing is done and service has to be
- * stopped 
- *
- * @param cls NULL
- */
-static void
-shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  test_success = GNUNET_YES;
-  GNUNET_SCHEDULER_shutdown ();  
-}
-
 
 /**
  * The testing callback function
@@ -66,7 +50,8 @@ test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
   GNUNET_assert (NULL == cls);
   GNUNET_assert (NULL != cfg);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Service arm started successfully\n");
-  GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (3), &shutdown_task, NULL);
+  test_success = GNUNET_YES;
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -75,37 +60,14 @@ test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
  */
 int main (int argc, char *argv[])
 {
-  char *_tmpdir;
-  char *tmpdir;
-#ifdef MINGW
-  char *tmpdir_w;
-#endif
-  
-  GNUNET_log_setup ("test_testing_new_servicestartup", "DEBUG", NULL);  
-  _tmpdir = getenv ("TMP");
-  if (NULL == _tmpdir)
-    _tmpdir = getenv ("TEMP");  
-  if (NULL == _tmpdir)
-    _tmpdir = getenv ("TMPDIR");
-  if (NULL == _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);
-#endif
-
   test_success = GNUNET_NO;
-  GNUNET_assert (0 == GNUNET_TESTING_service_run (tmpdir,
+  GNUNET_assert (0 == GNUNET_TESTING_service_run ("test-testing-servicestartup",
                                                   "arm",
                                                   "test_testing_defaults.conf",
                                                   &test_run,
                                                   NULL));
-  GNUNET_free (tmpdir);
   return (GNUNET_YES == test_success) ? 0 : 1;
 }
+
+/* end of test_testing_servicestartup.c */
+
index ac5edab34dfc23648f4d077b9b8d07d88e5ee8fa..949dd5357e99a1a406b2fa75f55b74a6047ee145 100644 (file)
@@ -245,7 +245,12 @@ GNUNET_TESTING_system_create (const char *tmppath,
 
   GNUNET_assert (NULL != tmppath);
   system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System));
-  system->tmppath = GNUNET_strdup (tmppath);
+  system->tmppath = GNUNET_DISK_mkdtemp (tmppath);
+  if (NULL == system->tmppath)
+  {
+    GNUNET_free (system);
+    return NULL;
+  }
   if (NULL != controller)
     system->controller = GNUNET_strdup (controller);
   if (GNUNET_OK != hostkeys_load (system))