diff options
author | harsha <harsha@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-10-05 14:12:49 +0000 |
---|---|---|
committer | harsha <harsha@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-10-05 14:12:49 +0000 |
commit | 8710fd4c322ec873cabe78e2ed71bfb28d71da3b (patch) | |
tree | e56d091c02b989535754dbd723c39d30620aa905 /src/testing | |
parent | da200edbc17888e3f2f27ff770744feabf2e82b2 (diff) |
testing now includes valid hostname rewriting
git-svn-id: https://gnunet.org/svn/gnunet@24196 140774ce-b5e7-0310-ab8b-a85725594a96
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 77d2cf4151..cc5c6f50ce 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) } fail = GNUNET_NO; - system = GNUNET_TESTING_system_create ("testing", NULL /* controller */); + system = GNUNET_TESTING_system_create ("testing", NULL /* controller */, NULL); for (cur = 0; cur < no; cur++) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); @@ -124,7 +124,7 @@ create_hostkeys (const unsigned int no) struct GNUNET_CRYPTO_RsaPrivateKey *pk; struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkb; - system = GNUNET_TESTING_system_create ("testing", NULL); + system = GNUNET_TESTING_system_create ("testing", NULL, NULL); pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); if (NULL == pk) { diff --git a/src/testing/test_testing_peerstartup.c b/src/testing/test_testing_peerstartup.c index 990486467d..7f78827f65 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, struct GNUNET_PeerIdentity id; system = GNUNET_TESTING_system_create ("test-gnunet-testing", - "127.0.0.1"); + "127.0.0.1", NULL); GNUNET_assert (NULL != system); new_cfg = GNUNET_CONFIGURATION_dup (cfg); emsg = NULL; diff --git a/src/testing/test_testing_portreservation.c b/src/testing/test_testing_portreservation.c index 4815d47fda..6640316331 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, uint16_t old_port1; system = GNUNET_TESTING_system_create ("/tmp/gnunet-testing-new", - "localhost"); + "localhost", NULL); GNUNET_assert (NULL != system); new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES); LOG (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/testing/testing.c b/src/testing/testing.c index ecef4f2668..8a5ff66797 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -74,6 +74,11 @@ struct GNUNET_TESTING_System char *controller; /** + * our hostname + */ + char *hostname; + + /** * Hostkeys data, contains "HOSTKEYFILESIZE * total_hostkeys" bytes. */ char *hostkeys_data; @@ -262,6 +267,8 @@ hostkeys_unload (struct GNUNET_TESTING_System *system) * @param controller hostname of the controlling host, * service configurations are modified to allow * control connections from this host; can be NULL + * @param hostname the hostname of the system we are using for testing; NULL for + * localhost * @param lowport lowest port number this system is allowed to allocate (inclusive) * @param highport highest port number this system is allowed to allocate (exclusive) * @return handle to this system, NULL on error @@ -269,6 +276,7 @@ hostkeys_unload (struct GNUNET_TESTING_System *system) struct GNUNET_TESTING_System * GNUNET_TESTING_system_create_with_portrange (const char *testdir, const char *controller, + const char *hostname, uint16_t lowport, uint16_t highport) { @@ -286,6 +294,8 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, } if (NULL != controller) system->controller = GNUNET_strdup (controller); + if (NULL != hostname) + system->hostname = GNUNET_strdup (hostname); if (GNUNET_OK != hostkeys_load (system)) { GNUNET_TESTING_system_destroy (system, GNUNET_YES); @@ -296,24 +306,27 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, /** - * Create a system handle. There must only be one system - * handle per operating system. - * - * @param testdir only the directory name without any path. This is used for - * all service homes; the directory will be created in a temporary - * location depending on the underlying OS + * Create a system handle. There must only be one system handle per operating + * system. Uses a default range for allowed ports. Ports are still tested for + * availability. * - * @param controller hostname of the controlling host, - * service configurations are modified to allow - * control connections from this host; can be NULL + * @param testdir only the directory name without any path. This is used for all + * service homes; the directory will be created in a temporary location + * depending on the underlying OS + * @param controller hostname of the controlling host, service configurations + * are modified to allow control connections from this host; can be NULL + * @param hostname the hostname of the system we are using for testing; NULL for + * localhost * @return handle to this system, NULL on error */ struct GNUNET_TESTING_System * GNUNET_TESTING_system_create (const char *testdir, - const char *controller) + const char *controller, + const char *hostname) { return GNUNET_TESTING_system_create_with_portrange (testdir, controller, + hostname, LOW_PORT, HIGH_PORT); } @@ -336,6 +349,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system, GNUNET_DISK_directory_remove (system->tmppath); GNUNET_free (system->tmppath); GNUNET_free_non_null (system->controller); + GNUNET_free_non_null (system->hostname); GNUNET_free (system); } @@ -635,9 +649,9 @@ update_config (void *cls, const char *section, const char *option, GNUNET_break(0); /* FIXME */ } } - if ((0 == strcmp (option, "HOSTNAME")) && (NULL != uc->system->controller)) + if (0 == strcmp (option, "HOSTNAME")) { - value = uc->system->controller; + value = (NULL == uc->system->hostname) ? "localhost" : uc->system->hostname; } GNUNET_free (single_variable); GNUNET_free (per_host_variable); @@ -1119,7 +1133,7 @@ GNUNET_TESTING_service_run (const char *testdir, struct GNUNET_CONFIGURATION_Handle *cfg; GNUNET_log_setup (testdir, "WARNING", NULL); - system = GNUNET_TESTING_system_create (testdir, "127.0.0.1"); + system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL); if (NULL == system) return 1; cfg = GNUNET_CONFIGURATION_create (); |