diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-05 14:12:49 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-05 14:12:49 +0000 |
commit | 87566df009e48391b08d3f1cdf3dedf7debcac7b (patch) | |
tree | e56d091c02b989535754dbd723c39d30620aa905 /src/testing | |
parent | 69d9d1763c430be814457f744b468140d278e3e9 (diff) | |
download | gnunet-87566df009e48391b08d3f1cdf3dedf7debcac7b.tar.gz gnunet-87566df009e48391b08d3f1cdf3dedf7debcac7b.zip |
testing now includes valid hostname rewriting
Diffstat (limited to 'src/testing')
-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 |
4 files changed, 31 insertions, 17 deletions
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 (); |