aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testing/Makefile.am11
-rw-r--r--src/testing/testing_new.c29
2 files changed, 25 insertions, 15 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index dc357fbf7..50b6d77b3 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -90,7 +90,8 @@ check_PROGRAMS = \
90 test_testing_topology_internat \ 90 test_testing_topology_internat \
91 test_testing_topology_none \ 91 test_testing_topology_none \
92 test_testing_topology_scale_free \ 92 test_testing_topology_scale_free \
93 test_testing_new_portreservation 93 test_testing_new_portreservation \
94 test_testing_new_peerstartup
94 95
95if ENABLE_TEST_RUN 96if ENABLE_TEST_RUN
96TESTS = \ 97TESTS = \
@@ -99,7 +100,8 @@ TESTS = \
99 test_testing_reconnect \ 100 test_testing_reconnect \
100 test_testing_group \ 101 test_testing_group \
101 test_testing_peergroup \ 102 test_testing_peergroup \
102 test_testing_new_portreservation 103 test_testing_new_portreservation \
104 test_testing_new_peerstartup
103endif 105endif
104 106
105gnunet_testing_SOURCES = \ 107gnunet_testing_SOURCES = \
@@ -271,6 +273,11 @@ test_testing_new_portreservation_LDADD = \
271 $(top_builddir)/src/testing/libgnunettesting_new.la \ 273 $(top_builddir)/src/testing/libgnunettesting_new.la \
272 $(top_builddir)/src/util/libgnunetutil.la 274 $(top_builddir)/src/util/libgnunetutil.la
273 275
276test_testing_new_peerstartup_SOURCES = \
277 test_testing_new_peerstartup.c
278test_testing_new_peerstartup_LDADD = \
279 $(top_builddir)/src/testing/libgnunettesting_new.la \
280 $(top_builddir)/src/util/libgnunetutil.la
274 281
275EXTRA_DIST = \ 282EXTRA_DIST = \
276 test_testing_defaults.conf \ 283 test_testing_defaults.conf \
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)