diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-05-30 21:21:49 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-05-30 21:21:49 +0000 |
commit | 279d169d25efb2a9e77f0efd9b2da4e57e2989e5 (patch) | |
tree | 85a8d3f0aa594a78eddb6b37985a0aa2ee403a7f /src/testing/testing_new.c | |
parent | 8f654f30c3c4987c9ca1b564d6e6f2d75ae24862 (diff) | |
download | gnunet-279d169d25efb2a9e77f0efd9b2da4e57e2989e5.tar.gz gnunet-279d169d25efb2a9e77f0efd9b2da4e57e2989e5.zip |
test case for peer startup in new testing library
Diffstat (limited to 'src/testing/testing_new.c')
-rw-r--r-- | src/testing/testing_new.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/testing/testing_new.c b/src/testing/testing_new.c index 6cb75ab95..1bdf7a45f 100644 --- a/src/testing/testing_new.c +++ b/src/testing/testing_new.c | |||
@@ -36,9 +36,6 @@ | |||
36 | #define LOG(kind,...) \ | 36 | #define LOG(kind,...) \ |
37 | GNUNET_log_from (kind, "gnunettestingnew", __VA_ARGS__) | 37 | GNUNET_log_from (kind, "gnunettestingnew", __VA_ARGS__) |
38 | 38 | ||
39 | #define TIME_REL_SEC(sec) \ | ||
40 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) | ||
41 | |||
42 | 39 | ||
43 | /** | 40 | /** |
44 | * Size of a hostkey when written to a file | 41 | * Size of a hostkey when written to a file |
@@ -194,9 +191,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system, | |||
194 | if (NULL != system->hostkeys_data) | 191 | if (NULL != system->hostkeys_data) |
195 | { | 192 | { |
196 | GNUNET_break (0); /* Use GNUNET_TESTING_hostkeys_unload() */ | 193 | GNUNET_break (0); /* Use GNUNET_TESTING_hostkeys_unload() */ |
197 | GNUNET_free (system->hostkeys_data); | 194 | GNUNET_TESTING_hostkeys_unload (system); |
198 | system->hostkeys_data = NULL; | ||
199 | system->total_hostkeys = 0; | ||
200 | } | 195 | } |
201 | if (GNUNET_YES == remove_paths) | 196 | if (GNUNET_YES == remove_paths) |
202 | GNUNET_DISK_directory_remove (system->tmppath); | 197 | GNUNET_DISK_directory_remove (system->tmppath); |
@@ -261,7 +256,7 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system, | |||
261 | continue; | 256 | continue; |
262 | } | 257 | } |
263 | open_port = (index * 32) + pos; | 258 | open_port = (index * 32) + pos; |
264 | GNUNET_asprintf (&open_port_str, "%u", open_port); | 259 | GNUNET_asprintf (&open_port_str, "%u", (unsigned int) open_port); |
265 | ret = NULL; | 260 | ret = NULL; |
266 | GNUNET_assert (0 == getaddrinfo (NULL, open_port_str, &hint, &ret)); | 261 | GNUNET_assert (0 == getaddrinfo (NULL, open_port_str, &hint, &ret)); |
267 | GNUNET_free (open_port_str); | 262 | GNUNET_free (open_port_str); |
@@ -278,7 +273,11 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system, | |||
278 | socket = NULL; | 273 | socket = NULL; |
279 | port_buckets[index] |= (1U << pos); /* Set the port bit */ | 274 | port_buckets[index] |= (1U << pos); /* Set the port bit */ |
280 | if (GNUNET_OK == bind_status) | 275 | if (GNUNET_OK == bind_status) |
276 | { | ||
277 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
278 | "Found a free port %u\n", (unsigned int) open_port); | ||
281 | return open_port; | 279 | return open_port; |
280 | } | ||
282 | pos++; | 281 | pos++; |
283 | } | 282 | } |
284 | } | 283 | } |
@@ -509,6 +508,10 @@ update_config (void *cls, const char *section, const char *option, | |||
509 | 508 | ||
510 | if (GNUNET_OK != uc->status) | 509 | if (GNUNET_OK != uc->status) |
511 | return; | 510 | return; |
511 | if (! ((0 == strcmp (option, "PORT")) | ||
512 | || (0 == strcmp (option, "UNIXPATH")) | ||
513 | || (0 == strcmp (option, "HOSTNAME")))) | ||
514 | return; | ||
512 | GNUNET_asprintf (&single_variable, "single_%s_per_host", section); | 515 | GNUNET_asprintf (&single_variable, "single_%s_per_host", section); |
513 | GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section); | 516 | GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section); |
514 | if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival))) | 517 | if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival))) |
@@ -548,7 +551,7 @@ update_config (void *cls, const char *section, const char *option, | |||
548 | GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", | 551 | GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", |
549 | single_variable)) | 552 | single_variable)) |
550 | { | 553 | { |
551 | GNUNET_snprintf (uval, sizeof (uval), "%s\\%s.sock", | 554 | GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock", |
552 | uc->service_home, section); | 555 | uc->service_home, section); |
553 | value = uval; | 556 | value = uval; |
554 | } | 557 | } |
@@ -625,7 +628,7 @@ GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system, | |||
625 | uc.system = system; | 628 | uc.system = system; |
626 | uc.cfg = cfg; | 629 | uc.cfg = cfg; |
627 | uc.status = GNUNET_OK; | 630 | uc.status = GNUNET_OK; |
628 | GNUNET_asprintf (&uc.service_home, "%s\\%u", system->tmppath, | 631 | GNUNET_asprintf (&uc.service_home, "%s/%u", system->tmppath, |
629 | system->path_counter++); | 632 | system->path_counter++); |
630 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "SERVICEHOME", | 633 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "SERVICEHOME", |
631 | uc.service_home); | 634 | uc.service_home); |
@@ -708,9 +711,9 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
708 | } | 711 | } |
709 | GNUNET_assert (GNUNET_OK == | 712 | GNUNET_assert (GNUNET_OK == |
710 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", | 713 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", |
711 | "SERVICE_HOME", | 714 | "SERVICEHOME", |
712 | &service_home)); | 715 | &service_home)); |
713 | GNUNET_snprintf (hostkey_filename, sizeof (hostkey_filename), "%s\\.hostkey", | 716 | GNUNET_snprintf (hostkey_filename, sizeof (hostkey_filename), "%s/.hostkey", |
714 | service_home); | 717 | service_home); |
715 | fd = GNUNET_DISK_file_open (hostkey_filename, | 718 | fd = GNUNET_DISK_file_open (hostkey_filename, |
716 | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE, | 719 | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE, |
@@ -739,7 +742,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
739 | return NULL; | 742 | return NULL; |
740 | } | 743 | } |
741 | GNUNET_DISK_file_close (fd); | 744 | GNUNET_DISK_file_close (fd); |
742 | GNUNET_asprintf (&config_filename, "%s\\config", service_home); | 745 | GNUNET_asprintf (&config_filename, "%s/config", service_home); |
743 | GNUNET_free (service_home); | 746 | GNUNET_free (service_home); |
744 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename)) | 747 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename)) |
745 | { | 748 | { |
@@ -933,7 +936,7 @@ GNUNET_TESTING_service_run (const char *tmppath, | |||
933 | char *hostkeys_file; | 936 | char *hostkeys_file; |
934 | 937 | ||
935 | data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); | 938 | data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); |
936 | GNUNET_asprintf (&hostkeys_file, "%s\\testing_hostkeys.dat", data_dir); | 939 | GNUNET_asprintf (&hostkeys_file, "%s/testing_hostkeys.dat", data_dir); |
937 | GNUNET_free (data_dir); | 940 | GNUNET_free (data_dir); |
938 | system = GNUNET_TESTING_system_create (tmppath, "localhost"); | 941 | system = GNUNET_TESTING_system_create (tmppath, "localhost"); |
939 | if (NULL == system) | 942 | if (NULL == system) |