testing system
authorSree Harsha Totakura <totakura@in.tum.de>
Sun, 20 May 2012 15:06:15 +0000 (15:06 +0000)
committerSree Harsha Totakura <totakura@in.tum.de>
Sun, 20 May 2012 15:06:15 +0000 (15:06 +0000)
src/testing/testing_new.c

index 33065e954630b74b9863e830698455917a0a79ce..087afb723eb90334f4de36c5f8e33af3f28b2f8a 100644 (file)
@@ -30,6 +30,7 @@
  *
  */
 #include "platform.h"
+#include "gnunet_disk_lib.h"
 #include "gnunet_testing_lib-new.h"
 
 
@@ -45,6 +46,11 @@ struct GNUNET_TESTING_System
    */
   char *tmppath;
 
+  /**
+   * The hostname of the controller
+   */
+  char *controller;
+
   /**
    * Bitmap where each TCP port that has already been reserved for
    * some GNUnet peer is recorded.  Note that we additionally need to
@@ -76,6 +82,11 @@ struct GNUNET_TESTING_System
    * we never re-use path counters.
    */
   uint32_t path_counter;
+
+  /**
+   * Last used port number
+   */
+  
 };
 
 
@@ -107,6 +118,23 @@ struct GNUNET_TESTING_Peer
 };
 
 
+/**
+ * Lowest port used for GNUnet testing.  Should be high enough to not
+ * conflict with other applications running on the hosts but be low
+ * enough to not conflict with client-ports (typically starting around
+ * 32k).
+ */
+#define LOW_PORT 12000
+
+
+/**
+ * Highest port used for GNUnet testing.  Should be low enough to not
+ * conflict with the port range for "local" ports (client apps; see
+ * /proc/sys/net/ipv4/ip_local_port_range on Linux for example).
+ */
+#define HIGH_PORT 56000
+
+
 /**
  * Create a system handle.  There must only be one system
  * handle per operating system.
@@ -121,8 +149,15 @@ struct GNUNET_TESTING_System *
 GNUNET_TESTING_system_create (const char *tmppath,
                              const char *controller)
 {
-  GNUNET_break (0);
-  return NULL;
+  struct GNUNET_TESTING_System *system;
+
+  if (NULL == tmppath)
+    return NULL;
+  system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System));
+  system->tmppath = GNUNET_strdup (tmppath);
+  if (NULL != controller)
+    system->controller = GNUNET_strdup (controller);
+  return system;
 }
 
 
@@ -137,7 +172,12 @@ void
 GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
                               int remove_paths)
 {
-  GNUNET_break (0);
+  GNUNET_assert (NULL != system);
+  if (GNUNET_YES == remove_paths)
+    GNUNET_DISK_directory_remove (system->tmppath);
+  GNUNET_free (system->tmppath);
+  GNUNET_free_non_null (system->controller);
+  GNUNET_free (system);
 }