From: Sree Harsha Totakura Date: Sun, 20 May 2012 15:06:15 +0000 (+0000) Subject: testing system X-Git-Tag: initial-import-from-subversion-38251~13435 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6517ea25896f843fd4af805533155d70f0fd3d77;p=oweals%2Fgnunet.git testing system --- diff --git a/src/testing/testing_new.c b/src/testing/testing_new.c index 33065e954..087afb723 100644 --- a/src/testing/testing_new.c +++ b/src/testing/testing_new.c @@ -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); }