diff options
-rw-r--r-- | src/include/gnunet_testing_lib-new.h | 25 | ||||
-rw-r--r-- | src/testbed/gnunet-helper-testbed.c | 30 | ||||
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 10 | ||||
-rw-r--r-- | src/testbed/test_gnunet_helper_testbed.c | 2 | ||||
-rw-r--r-- | src/testbed/testbed_api.c | 17 | ||||
-rw-r--r-- | src/testbed/testbed_api.h | 2 | ||||
-rw-r--r-- | src/testbed/testbed_helper.h | 13 | ||||
-rw-r--r-- | src/testing/gnunet-testing.c | 4 | ||||
-rw-r--r-- | src/testing/test_testing_peerstartup.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_portreservation.c | 2 | ||||
-rw-r--r-- | src/testing/testing.c | 40 | ||||
-rw-r--r-- | src/transport/transport-testing.c | 2 |
12 files changed, 112 insertions, 37 deletions
diff --git a/src/include/gnunet_testing_lib-new.h b/src/include/gnunet_testing_lib-new.h index 802839d17..aef8c763d 100644 --- a/src/include/gnunet_testing_lib-new.h +++ b/src/include/gnunet_testing_lib-new.h | |||
@@ -59,21 +59,23 @@ struct GNUNET_TESTING_Peer; | |||
59 | 59 | ||
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Create a system handle. There must only be one system | 62 | * Create a system handle. There must only be one system handle per operating |
63 | * handle per operating system. Uses a default range for allowed ports. | 63 | * system. Uses a default range for allowed ports. Ports are still tested for |
64 | * Ports are still tested for availability. | 64 | * availability. |
65 | * | 65 | * |
66 | * @param testdir only the directory name without any path. This is used for | 66 | * @param testdir only the directory name without any path. This is used for all |
67 | * all service homes; the directory will be created in a temporary | 67 | * service homes; the directory will be created in a temporary location |
68 | * location depending on the underlying OS | 68 | * depending on the underlying OS |
69 | * @param controller hostname of the controlling host, | 69 | * @param controller hostname of the controlling host, service configurations |
70 | * service configurations are modified to allow | 70 | * are modified to allow control connections from this host; can be NULL |
71 | * control connections from this host; can be NULL | 71 | * @param hostname the hostname of the system we are using for testing; NULL for |
72 | * localhost | ||
72 | * @return handle to this system, NULL on error | 73 | * @return handle to this system, NULL on error |
73 | */ | 74 | */ |
74 | struct GNUNET_TESTING_System * | 75 | struct GNUNET_TESTING_System * |
75 | GNUNET_TESTING_system_create (const char *testdir, | 76 | GNUNET_TESTING_system_create (const char *testdir, |
76 | const char *controller); | 77 | const char *controller, |
78 | const char *hostname); | ||
77 | 79 | ||
78 | 80 | ||
79 | /** | 81 | /** |
@@ -89,6 +91,8 @@ GNUNET_TESTING_system_create (const char *testdir, | |||
89 | * @param controller hostname of the controlling host, | 91 | * @param controller hostname of the controlling host, |
90 | * service configurations are modified to allow | 92 | * service configurations are modified to allow |
91 | * control connections from this host; can be NULL | 93 | * control connections from this host; can be NULL |
94 | * @param hostname the hostname of the system we are using for testing; NULL for | ||
95 | * localhost | ||
92 | * @param lowport lowest port number this system is allowed to allocate (inclusive) | 96 | * @param lowport lowest port number this system is allowed to allocate (inclusive) |
93 | * @param highport highest port number this system is allowed to allocate (exclusive) | 97 | * @param highport highest port number this system is allowed to allocate (exclusive) |
94 | * @return handle to this system, NULL on error | 98 | * @return handle to this system, NULL on error |
@@ -96,6 +100,7 @@ GNUNET_TESTING_system_create (const char *testdir, | |||
96 | struct GNUNET_TESTING_System * | 100 | struct GNUNET_TESTING_System * |
97 | GNUNET_TESTING_system_create_with_portrange (const char *testdir, | 101 | GNUNET_TESTING_system_create_with_portrange (const char *testdir, |
98 | const char *controller, | 102 | const char *controller, |
103 | const char *hostname, | ||
99 | uint16_t lowport, | 104 | uint16_t lowport, |
100 | uint16_t highport); | 105 | uint16_t highport); |
101 | 106 | ||
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index bc7f223af..0e70645c7 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c | |||
@@ -226,14 +226,18 @@ tokenizer_cb (void *cls, void *client, | |||
226 | struct GNUNET_CONFIGURATION_Handle *cfg; | 226 | struct GNUNET_CONFIGURATION_Handle *cfg; |
227 | struct WriteContext *wc; | 227 | struct WriteContext *wc; |
228 | char *controller; | 228 | char *controller; |
229 | char *hostname; | ||
229 | char *config; | 230 | char *config; |
230 | char *xconfig; | 231 | char *xconfig; |
231 | size_t config_size; | 232 | size_t config_size; |
232 | uLongf ul_config_size; | 233 | uLongf ul_config_size; |
233 | size_t xconfig_size; | 234 | size_t xconfig_size; |
234 | uint16_t cname_size; | 235 | uint16_t cname_size; |
235 | 236 | uint16_t hostname_size; | |
236 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) || | 237 | uint16_t msize; |
238 | |||
239 | msize = ntohs (message->size); | ||
240 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) || | ||
237 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) | 241 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) |
238 | { | 242 | { |
239 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | 243 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
@@ -248,6 +252,14 @@ tokenizer_cb (void *cls, void *client, | |||
248 | "Controller name cannot be empty -- exiting\n"); | 252 | "Controller name cannot be empty -- exiting\n"); |
249 | goto error; | 253 | goto error; |
250 | } | 254 | } |
255 | hostname_size = ntohs (msg->hostname_size); | ||
256 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) + cname_size + 1 + | ||
257 | hostname_size) >= msize) | ||
258 | { | ||
259 | GNUNET_break (0); | ||
260 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | ||
261 | goto error; | ||
262 | } | ||
251 | ul_config_size = (uLongf) ntohs (msg->config_size); | 263 | ul_config_size = (uLongf) ntohs (msg->config_size); |
252 | config = GNUNET_malloc (ul_config_size); | 264 | config = GNUNET_malloc (ul_config_size); |
253 | xconfig_size = | 265 | xconfig_size = |
@@ -255,7 +267,7 @@ tokenizer_cb (void *cls, void *client, | |||
255 | sizeof (struct GNUNET_TESTBED_HelperInit)); | 267 | sizeof (struct GNUNET_TESTBED_HelperInit)); |
256 | if (Z_OK != | 268 | if (Z_OK != |
257 | uncompress ((Bytef *) config, &ul_config_size, | 269 | uncompress ((Bytef *) config, &ul_config_size, |
258 | (const Bytef *) (controller + cname_size + 1), | 270 | (const Bytef *) (controller + cname_size + 1 + hostname_size), |
259 | (uLongf) xconfig_size)) | 271 | (uLongf) xconfig_size)) |
260 | { | 272 | { |
261 | LOG (GNUNET_ERROR_TYPE_WARNING, | 273 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -273,7 +285,17 @@ tokenizer_cb (void *cls, void *client, | |||
273 | goto error; | 285 | goto error; |
274 | } | 286 | } |
275 | GNUNET_free (config); | 287 | GNUNET_free (config); |
276 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller); | 288 | hostname = NULL; |
289 | if (0 != hostname_size) | ||
290 | { | ||
291 | hostname = GNUNET_malloc (hostname_size + 1); | ||
292 | (void) strncpy (hostname, ((char *) &msg[1]) + cname_size + 1, hostname_size); | ||
293 | hostname[hostname_size] = '\0'; | ||
294 | } | ||
295 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller, | ||
296 | hostname); | ||
297 | GNUNET_free_non_null (hostname); | ||
298 | hostname = NULL; | ||
277 | GNUNET_assert (NULL != test_system); | 299 | GNUNET_assert (NULL != test_system); |
278 | GNUNET_assert (GNUNET_OK == | 300 | GNUNET_assert (GNUNET_OK == |
279 | GNUNET_TESTING_configuration_create (test_system, cfg)); | 301 | GNUNET_TESTING_configuration_create (test_system, cfg)); |
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index c4a30f12c..0736f5997 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -538,6 +538,11 @@ struct LinkControllersContext | |||
538 | */ | 538 | */ |
539 | static struct Context *master_context; | 539 | static struct Context *master_context; |
540 | 540 | ||
541 | /** | ||
542 | * Our hostname; we give this to all the peers we start | ||
543 | */ | ||
544 | static char *hostname; | ||
545 | |||
541 | /***********/ | 546 | /***********/ |
542 | /* Handles */ | 547 | /* Handles */ |
543 | /***********/ | 548 | /***********/ |
@@ -1237,7 +1242,7 @@ handle_init (void *cls, struct GNUNET_SERVER_Client *client, | |||
1237 | master_context->master_ip = GNUNET_strdup (controller_hostname); | 1242 | master_context->master_ip = GNUNET_strdup (controller_hostname); |
1238 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); | 1243 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); |
1239 | master_context->system = | 1244 | master_context->system = |
1240 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip); | 1245 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip, hostname); |
1241 | host = | 1246 | host = |
1242 | GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL, | 1247 | GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL, |
1243 | 0); | 1248 | 0); |
@@ -2832,6 +2837,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2832 | GNUNET_free (master_context); | 2837 | GNUNET_free (master_context); |
2833 | master_context = NULL; | 2838 | master_context = NULL; |
2834 | } | 2839 | } |
2840 | GNUNET_free_non_null (hostname); | ||
2835 | } | 2841 | } |
2836 | 2842 | ||
2837 | 2843 | ||
@@ -2896,6 +2902,8 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2896 | {NULL} | 2902 | {NULL} |
2897 | }; | 2903 | }; |
2898 | 2904 | ||
2905 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string | ||
2906 | (cfg, "testbed", "HOSTNAME", &hostname)); | ||
2899 | GNUNET_SERVER_add_handlers (server, message_handlers); | 2907 | GNUNET_SERVER_add_handlers (server, message_handlers); |
2900 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); | 2908 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); |
2901 | ss_map = GNUNET_CONTAINER_multihashmap_create (5); | 2909 | ss_map = GNUNET_CONTAINER_multihashmap_create (5); |
diff --git a/src/testbed/test_gnunet_helper_testbed.c b/src/testbed/test_gnunet_helper_testbed.c index 7fce9a5d8..db889c1ec 100644 --- a/src/testbed/test_gnunet_helper_testbed.c +++ b/src/testbed/test_gnunet_helper_testbed.c | |||
@@ -212,7 +212,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
212 | &mst_cb, &exp_cb, NULL); | 212 | &mst_cb, &exp_cb, NULL); |
213 | GNUNET_assert (NULL != helper); | 213 | GNUNET_assert (NULL != helper); |
214 | cfg = GNUNET_CONFIGURATION_dup (cfg2); | 214 | cfg = GNUNET_CONFIGURATION_dup (cfg2); |
215 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, cfg); | 215 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, NULL, cfg); |
216 | shandle = | 216 | shandle = |
217 | GNUNET_HELPER_send (helper, &msg->header, GNUNET_NO, &cont_cb, NULL); | 217 | GNUNET_HELPER_send (helper, &msg->header, GNUNET_NO, &cont_cb, NULL); |
218 | GNUNET_assert (NULL != shandle); | 218 | GNUNET_assert (NULL != shandle); |
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 953488af1..1d99c7e3f 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -1338,10 +1338,12 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1338 | { | 1338 | { |
1339 | struct GNUNET_TESTBED_ControllerProc *cp; | 1339 | struct GNUNET_TESTBED_ControllerProc *cp; |
1340 | struct GNUNET_TESTBED_HelperInit *msg; | 1340 | struct GNUNET_TESTBED_HelperInit *msg; |
1341 | const char *hostname; | ||
1341 | static char *const binary_argv[] = { | 1342 | static char *const binary_argv[] = { |
1342 | HELPER_TESTBED_BINARY, NULL | 1343 | HELPER_TESTBED_BINARY, NULL |
1343 | }; | 1344 | }; |
1344 | 1345 | ||
1346 | hostname = NULL; | ||
1345 | cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); | 1347 | cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); |
1346 | if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host))) | 1348 | if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host))) |
1347 | cp->helper = | 1349 | cp->helper = |
@@ -1352,7 +1354,6 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1352 | char *remote_args[8]; | 1354 | char *remote_args[8]; |
1353 | unsigned int argp; | 1355 | unsigned int argp; |
1354 | const char *username; | 1356 | const char *username; |
1355 | const char *hostname; | ||
1356 | 1357 | ||
1357 | username = GNUNET_TESTBED_host_get_username_ (host); | 1358 | username = GNUNET_TESTBED_host_get_username_ (host); |
1358 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); | 1359 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); |
@@ -1386,7 +1387,7 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1386 | cp->host = host; | 1387 | cp->host = host; |
1387 | cp->cb = cb; | 1388 | cp->cb = cb; |
1388 | cp->cls = cls; | 1389 | cp->cls = cls; |
1389 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); | 1390 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, hostname, cfg); |
1390 | cp->msg = &msg->header; | 1391 | cp->msg = &msg->header; |
1391 | cp->shandle = | 1392 | cp->shandle = |
1392 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); | 1393 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); |
@@ -1915,12 +1916,14 @@ GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller | |||
1915 | * want to use this in testing | 1916 | * want to use this in testing |
1916 | * | 1917 | * |
1917 | * @param cname the ip address of the controlling host | 1918 | * @param cname the ip address of the controlling host |
1919 | * @param hostname the hostname of the destination this message is intended for | ||
1918 | * @param cfg the configuration that has to used to start the testbed service | 1920 | * @param cfg the configuration that has to used to start the testbed service |
1919 | * thru helper | 1921 | * thru helper |
1920 | * @return the initialization message | 1922 | * @return the initialization message |
1921 | */ | 1923 | */ |
1922 | struct GNUNET_TESTBED_HelperInit * | 1924 | struct GNUNET_TESTBED_HelperInit * |
1923 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | 1925 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, |
1926 | const char *hostname, | ||
1924 | const struct GNUNET_CONFIGURATION_Handle | 1927 | const struct GNUNET_CONFIGURATION_Handle |
1925 | *cfg) | 1928 | *cfg) |
1926 | { | 1929 | { |
@@ -1930,6 +1933,7 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1930 | size_t config_size; | 1933 | size_t config_size; |
1931 | size_t xconfig_size; | 1934 | size_t xconfig_size; |
1932 | uint16_t cname_len; | 1935 | uint16_t cname_len; |
1936 | uint16_t hostname_len; | ||
1933 | uint16_t msg_size; | 1937 | uint16_t msg_size; |
1934 | 1938 | ||
1935 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); | 1939 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); |
@@ -1938,15 +1942,22 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1938 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); | 1942 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); |
1939 | GNUNET_free (config); | 1943 | GNUNET_free (config); |
1940 | cname_len = strlen (cname); | 1944 | cname_len = strlen (cname); |
1945 | hostname_len = (NULL == hostname) ? 0 : strlen (hostname); | ||
1941 | msg_size = | 1946 | msg_size = |
1942 | xconfig_size + cname_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit); | 1947 | xconfig_size + cname_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit); |
1948 | msg_size += hostname_len; | ||
1943 | msg = GNUNET_realloc (xconfig, msg_size); | 1949 | msg = GNUNET_realloc (xconfig, msg_size); |
1944 | (void) memmove (((void *) &msg[1]) + cname_len + 1, msg, xconfig_size); | 1950 | (void) memmove (((void *) &msg[1]) + cname_len + 1 + hostname_len, |
1951 | msg, | ||
1952 | xconfig_size); | ||
1945 | msg->header.size = htons (msg_size); | 1953 | msg->header.size = htons (msg_size); |
1946 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); | 1954 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); |
1947 | msg->cname_size = htons (cname_len); | 1955 | msg->cname_size = htons (cname_len); |
1956 | msg->hostname_size = htons (hostname_len); | ||
1948 | msg->config_size = htons (config_size); | 1957 | msg->config_size = htons (config_size); |
1949 | (void) strcpy ((char *) &msg[1], cname); | 1958 | (void) strcpy ((char *) &msg[1], cname); |
1959 | if (0 != hostname_len) | ||
1960 | (void) strncpy (((char *) &msg[1]) + cname_len + 1, hostname, hostname_len); | ||
1950 | return msg; | 1961 | return msg; |
1951 | } | 1962 | } |
1952 | 1963 | ||
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index c464b0ad5..020d951a2 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -356,12 +356,14 @@ GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op); | |||
356 | * Creates a helper initialization message. Only for testing. | 356 | * Creates a helper initialization message. Only for testing. |
357 | * | 357 | * |
358 | * @param cname the ip address of the controlling host | 358 | * @param cname the ip address of the controlling host |
359 | * @param hostname the hostname of the destination this message is intended for | ||
359 | * @param cfg the configuration that has to used to start the testbed service | 360 | * @param cfg the configuration that has to used to start the testbed service |
360 | * thru helper | 361 | * thru helper |
361 | * @return the initialization message | 362 | * @return the initialization message |
362 | */ | 363 | */ |
363 | struct GNUNET_TESTBED_HelperInit * | 364 | struct GNUNET_TESTBED_HelperInit * |
364 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | 365 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, |
366 | const char *hostname, | ||
365 | const struct GNUNET_CONFIGURATION_Handle | 367 | const struct GNUNET_CONFIGURATION_Handle |
366 | *cfg); | 368 | *cfg); |
367 | 369 | ||
diff --git a/src/testbed/testbed_helper.h b/src/testbed/testbed_helper.h index aee2c5b47..8a3ea55e0 100644 --- a/src/testbed/testbed_helper.h +++ b/src/testbed/testbed_helper.h | |||
@@ -28,6 +28,8 @@ | |||
28 | #ifndef TESTBED_HELPER_H | 28 | #ifndef TESTBED_HELPER_H |
29 | #define TESTBED_HELPER_H | 29 | #define TESTBED_HELPER_H |
30 | 30 | ||
31 | GNUNET_NETWORK_STRUCT_BEGIN | ||
32 | |||
31 | /** | 33 | /** |
32 | * Initialization message for gnunet-helper-testbed to start testbed service | 34 | * Initialization message for gnunet-helper-testbed to start testbed service |
33 | */ | 35 | */ |
@@ -45,12 +47,21 @@ struct GNUNET_TESTBED_HelperInit | |||
45 | uint16_t cname_size GNUNET_PACKED; | 47 | uint16_t cname_size GNUNET_PACKED; |
46 | 48 | ||
47 | /** | 49 | /** |
50 | * The hostname size excluding the NULL termination character - strlen | ||
51 | * (hostname); cannot be zero | ||
52 | */ | ||
53 | uint16_t hostname_size GNUNET_PACKED; | ||
54 | |||
55 | /** | ||
48 | * The size of the uncompressed configuration | 56 | * The size of the uncompressed configuration |
49 | */ | 57 | */ |
50 | uint16_t config_size GNUNET_PACKED; | 58 | uint16_t config_size GNUNET_PACKED; |
51 | 59 | ||
52 | /* Followed by NULL terminated controller hostname */ | 60 | /* Followed by NULL terminated controller hostname */ |
53 | 61 | ||
62 | /* Followed by hostname of the machine on which helper runs. This is not NULL | ||
63 | terminated */ | ||
64 | |||
54 | /* Followed by serialized and compressed configuration which should be | 65 | /* Followed by serialized and compressed configuration which should be |
55 | * config_size long when un-compressed */ | 66 | * config_size long when un-compressed */ |
56 | }; | 67 | }; |
@@ -74,6 +85,8 @@ struct GNUNET_TESTBED_HelperReply | |||
74 | * un-compressed */ | 85 | * un-compressed */ |
75 | }; | 86 | }; |
76 | 87 | ||
88 | GNUNET_NETWORK_STRUCT_END | ||
89 | |||
77 | #endif | 90 | #endif |
78 | 91 | ||
79 | /* end of testbed_helper.h */ | 92 | /* end of testbed_helper.h */ |
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index 77d2cf415..cc5c6f50c 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c | |||
@@ -77,7 +77,7 @@ create_unique_cfgs (const char * template, const unsigned int no) | |||
77 | } | 77 | } |
78 | 78 | ||
79 | fail = GNUNET_NO; | 79 | fail = GNUNET_NO; |
80 | system = GNUNET_TESTING_system_create ("testing", NULL /* controller */); | 80 | system = GNUNET_TESTING_system_create ("testing", NULL /* controller */, NULL); |
81 | for (cur = 0; cur < no; cur++) | 81 | for (cur = 0; cur < no; cur++) |
82 | { | 82 | { |
83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); | 83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); |
@@ -124,7 +124,7 @@ create_hostkeys (const unsigned int no) | |||
124 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | 124 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; |
125 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb; | 125 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb; |
126 | 126 | ||
127 | system = GNUNET_TESTING_system_create ("testing", NULL); | 127 | system = GNUNET_TESTING_system_create ("testing", NULL, NULL); |
128 | pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); | 128 | pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); |
129 | if (NULL == pk) | 129 | if (NULL == pk) |
130 | { | 130 | { |
diff --git a/src/testing/test_testing_peerstartup.c b/src/testing/test_testing_peerstartup.c index 990486467..7f78827f6 100644 --- a/src/testing/test_testing_peerstartup.c +++ b/src/testing/test_testing_peerstartup.c | |||
@@ -90,7 +90,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
90 | struct GNUNET_PeerIdentity id; | 90 | struct GNUNET_PeerIdentity id; |
91 | 91 | ||
92 | system = GNUNET_TESTING_system_create ("test-gnunet-testing", | 92 | system = GNUNET_TESTING_system_create ("test-gnunet-testing", |
93 | "127.0.0.1"); | 93 | "127.0.0.1", NULL); |
94 | GNUNET_assert (NULL != system); | 94 | GNUNET_assert (NULL != system); |
95 | new_cfg = GNUNET_CONFIGURATION_dup (cfg); | 95 | new_cfg = GNUNET_CONFIGURATION_dup (cfg); |
96 | emsg = NULL; | 96 | emsg = NULL; |
diff --git a/src/testing/test_testing_portreservation.c b/src/testing/test_testing_portreservation.c index 4815d47fd..664031633 100644 --- a/src/testing/test_testing_portreservation.c +++ b/src/testing/test_testing_portreservation.c | |||
@@ -45,7 +45,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
45 | uint16_t old_port1; | 45 | uint16_t old_port1; |
46 | 46 | ||
47 | system = GNUNET_TESTING_system_create ("/tmp/gnunet-testing-new", | 47 | system = GNUNET_TESTING_system_create ("/tmp/gnunet-testing-new", |
48 | "localhost"); | 48 | "localhost", NULL); |
49 | GNUNET_assert (NULL != system); | 49 | GNUNET_assert (NULL != system); |
50 | new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES); | 50 | new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES); |
51 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 51 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/testing/testing.c b/src/testing/testing.c index ecef4f266..8a5ff6679 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -74,6 +74,11 @@ struct GNUNET_TESTING_System | |||
74 | char *controller; | 74 | char *controller; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * our hostname | ||
78 | */ | ||
79 | char *hostname; | ||
80 | |||
81 | /** | ||
77 | * Hostkeys data, contains "HOSTKEYFILESIZE * total_hostkeys" bytes. | 82 | * Hostkeys data, contains "HOSTKEYFILESIZE * total_hostkeys" bytes. |
78 | */ | 83 | */ |
79 | char *hostkeys_data; | 84 | char *hostkeys_data; |
@@ -262,6 +267,8 @@ hostkeys_unload (struct GNUNET_TESTING_System *system) | |||
262 | * @param controller hostname of the controlling host, | 267 | * @param controller hostname of the controlling host, |
263 | * service configurations are modified to allow | 268 | * service configurations are modified to allow |
264 | * control connections from this host; can be NULL | 269 | * control connections from this host; can be NULL |
270 | * @param hostname the hostname of the system we are using for testing; NULL for | ||
271 | * localhost | ||
265 | * @param lowport lowest port number this system is allowed to allocate (inclusive) | 272 | * @param lowport lowest port number this system is allowed to allocate (inclusive) |
266 | * @param highport highest port number this system is allowed to allocate (exclusive) | 273 | * @param highport highest port number this system is allowed to allocate (exclusive) |
267 | * @return handle to this system, NULL on error | 274 | * @return handle to this system, NULL on error |
@@ -269,6 +276,7 @@ hostkeys_unload (struct GNUNET_TESTING_System *system) | |||
269 | struct GNUNET_TESTING_System * | 276 | struct GNUNET_TESTING_System * |
270 | GNUNET_TESTING_system_create_with_portrange (const char *testdir, | 277 | GNUNET_TESTING_system_create_with_portrange (const char *testdir, |
271 | const char *controller, | 278 | const char *controller, |
279 | const char *hostname, | ||
272 | uint16_t lowport, | 280 | uint16_t lowport, |
273 | uint16_t highport) | 281 | uint16_t highport) |
274 | { | 282 | { |
@@ -286,6 +294,8 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, | |||
286 | } | 294 | } |
287 | if (NULL != controller) | 295 | if (NULL != controller) |
288 | system->controller = GNUNET_strdup (controller); | 296 | system->controller = GNUNET_strdup (controller); |
297 | if (NULL != hostname) | ||
298 | system->hostname = GNUNET_strdup (hostname); | ||
289 | if (GNUNET_OK != hostkeys_load (system)) | 299 | if (GNUNET_OK != hostkeys_load (system)) |
290 | { | 300 | { |
291 | GNUNET_TESTING_system_destroy (system, GNUNET_YES); | 301 | GNUNET_TESTING_system_destroy (system, GNUNET_YES); |
@@ -296,24 +306,27 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, | |||
296 | 306 | ||
297 | 307 | ||
298 | /** | 308 | /** |
299 | * Create a system handle. There must only be one system | 309 | * Create a system handle. There must only be one system handle per operating |
300 | * handle per operating system. | 310 | * system. Uses a default range for allowed ports. Ports are still tested for |
301 | * | 311 | * availability. |
302 | * @param testdir only the directory name without any path. This is used for | ||
303 | * all service homes; the directory will be created in a temporary | ||
304 | * location depending on the underlying OS | ||
305 | * | 312 | * |
306 | * @param controller hostname of the controlling host, | 313 | * @param testdir only the directory name without any path. This is used for all |
307 | * service configurations are modified to allow | 314 | * service homes; the directory will be created in a temporary location |
308 | * control connections from this host; can be NULL | 315 | * depending on the underlying OS |
316 | * @param controller hostname of the controlling host, service configurations | ||
317 | * are modified to allow control connections from this host; can be NULL | ||
318 | * @param hostname the hostname of the system we are using for testing; NULL for | ||
319 | * localhost | ||
309 | * @return handle to this system, NULL on error | 320 | * @return handle to this system, NULL on error |
310 | */ | 321 | */ |
311 | struct GNUNET_TESTING_System * | 322 | struct GNUNET_TESTING_System * |
312 | GNUNET_TESTING_system_create (const char *testdir, | 323 | GNUNET_TESTING_system_create (const char *testdir, |
313 | const char *controller) | 324 | const char *controller, |
325 | const char *hostname) | ||
314 | { | 326 | { |
315 | return GNUNET_TESTING_system_create_with_portrange (testdir, | 327 | return GNUNET_TESTING_system_create_with_portrange (testdir, |
316 | controller, | 328 | controller, |
329 | hostname, | ||
317 | LOW_PORT, | 330 | LOW_PORT, |
318 | HIGH_PORT); | 331 | HIGH_PORT); |
319 | } | 332 | } |
@@ -336,6 +349,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system, | |||
336 | GNUNET_DISK_directory_remove (system->tmppath); | 349 | GNUNET_DISK_directory_remove (system->tmppath); |
337 | GNUNET_free (system->tmppath); | 350 | GNUNET_free (system->tmppath); |
338 | GNUNET_free_non_null (system->controller); | 351 | GNUNET_free_non_null (system->controller); |
352 | GNUNET_free_non_null (system->hostname); | ||
339 | GNUNET_free (system); | 353 | GNUNET_free (system); |
340 | } | 354 | } |
341 | 355 | ||
@@ -635,9 +649,9 @@ update_config (void *cls, const char *section, const char *option, | |||
635 | GNUNET_break(0); /* FIXME */ | 649 | GNUNET_break(0); /* FIXME */ |
636 | } | 650 | } |
637 | } | 651 | } |
638 | if ((0 == strcmp (option, "HOSTNAME")) && (NULL != uc->system->controller)) | 652 | if (0 == strcmp (option, "HOSTNAME")) |
639 | { | 653 | { |
640 | value = uc->system->controller; | 654 | value = (NULL == uc->system->hostname) ? "localhost" : uc->system->hostname; |
641 | } | 655 | } |
642 | GNUNET_free (single_variable); | 656 | GNUNET_free (single_variable); |
643 | GNUNET_free (per_host_variable); | 657 | GNUNET_free (per_host_variable); |
@@ -1119,7 +1133,7 @@ GNUNET_TESTING_service_run (const char *testdir, | |||
1119 | struct GNUNET_CONFIGURATION_Handle *cfg; | 1133 | struct GNUNET_CONFIGURATION_Handle *cfg; |
1120 | 1134 | ||
1121 | GNUNET_log_setup (testdir, "WARNING", NULL); | 1135 | GNUNET_log_setup (testdir, "WARNING", NULL); |
1122 | system = GNUNET_TESTING_system_create (testdir, "127.0.0.1"); | 1136 | system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL); |
1123 | if (NULL == system) | 1137 | if (NULL == system) |
1124 | return 1; | 1138 | return 1; |
1125 | cfg = GNUNET_CONFIGURATION_create (); | 1139 | cfg = GNUNET_CONFIGURATION_create (); |
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 660b9c6b4..f1c06ebc0 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -584,7 +584,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
584 | tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); | 584 | tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); |
585 | 585 | ||
586 | /* Init testing the testing lib */ | 586 | /* Init testing the testing lib */ |
587 | tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL); | 587 | tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL, NULL); |
588 | if (NULL == tth->tl_system) | 588 | if (NULL == tth->tl_system) |
589 | { | 589 | { |
590 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing library!\n")); | 590 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to initialize testing library!\n")); |