aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-05-20 15:06:15 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-05-20 15:06:15 +0000
commit6517ea25896f843fd4af805533155d70f0fd3d77 (patch)
tree87517beafb86c7801c3fc462655de38e01415253
parent13d3775c4dbe1e17751f6dfe4ec1d8e419be3b8d (diff)
downloadgnunet-6517ea25896f843fd4af805533155d70f0fd3d77.tar.gz
gnunet-6517ea25896f843fd4af805533155d70f0fd3d77.zip
testing system
-rw-r--r--src/testing/testing_new.c46
1 files changed, 43 insertions, 3 deletions
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 @@
30 * 30 *
31 */ 31 */
32#include "platform.h" 32#include "platform.h"
33#include "gnunet_disk_lib.h"
33#include "gnunet_testing_lib-new.h" 34#include "gnunet_testing_lib-new.h"
34 35
35 36
@@ -46,6 +47,11 @@ struct GNUNET_TESTING_System
46 char *tmppath; 47 char *tmppath;
47 48
48 /** 49 /**
50 * The hostname of the controller
51 */
52 char *controller;
53
54 /**
49 * Bitmap where each TCP port that has already been reserved for 55 * Bitmap where each TCP port that has already been reserved for
50 * some GNUnet peer is recorded. Note that we additionally need to 56 * some GNUnet peer is recorded. Note that we additionally need to
51 * test if a port is already in use by non-GNUnet components before 57 * test if a port is already in use by non-GNUnet components before
@@ -76,6 +82,11 @@ struct GNUNET_TESTING_System
76 * we never re-use path counters. 82 * we never re-use path counters.
77 */ 83 */
78 uint32_t path_counter; 84 uint32_t path_counter;
85
86 /**
87 * Last used port number
88 */
89
79}; 90};
80 91
81 92
@@ -108,6 +119,23 @@ struct GNUNET_TESTING_Peer
108 119
109 120
110/** 121/**
122 * Lowest port used for GNUnet testing. Should be high enough to not
123 * conflict with other applications running on the hosts but be low
124 * enough to not conflict with client-ports (typically starting around
125 * 32k).
126 */
127#define LOW_PORT 12000
128
129
130/**
131 * Highest port used for GNUnet testing. Should be low enough to not
132 * conflict with the port range for "local" ports (client apps; see
133 * /proc/sys/net/ipv4/ip_local_port_range on Linux for example).
134 */
135#define HIGH_PORT 56000
136
137
138/**
111 * Create a system handle. There must only be one system 139 * Create a system handle. There must only be one system
112 * handle per operating system. 140 * handle per operating system.
113 * 141 *
@@ -121,8 +149,15 @@ struct GNUNET_TESTING_System *
121GNUNET_TESTING_system_create (const char *tmppath, 149GNUNET_TESTING_system_create (const char *tmppath,
122 const char *controller) 150 const char *controller)
123{ 151{
124 GNUNET_break (0); 152 struct GNUNET_TESTING_System *system;
125 return NULL; 153
154 if (NULL == tmppath)
155 return NULL;
156 system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System));
157 system->tmppath = GNUNET_strdup (tmppath);
158 if (NULL != controller)
159 system->controller = GNUNET_strdup (controller);
160 return system;
126} 161}
127 162
128 163
@@ -137,7 +172,12 @@ void
137GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system, 172GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
138 int remove_paths) 173 int remove_paths)
139{ 174{
140 GNUNET_break (0); 175 GNUNET_assert (NULL != system);
176 if (GNUNET_YES == remove_paths)
177 GNUNET_DISK_directory_remove (system->tmppath);
178 GNUNET_free (system->tmppath);
179 GNUNET_free_non_null (system->controller);
180 GNUNET_free (system);
141} 181}
142 182
143 183