aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
commit61c39c60565b386e0e12ea669556b030e8cd7180 (patch)
tree59109aeab8297bdc996faca8c4e38ec7426c36cf /src/testing
parent780eb09dd8040ecf8649d40ddf8314464e0fc48e (diff)
downloadgnunet-61c39c60565b386e0e12ea669556b030e8cd7180.tar.gz
gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.zip
-remove trailing whitespace
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/gnunet-testing.c12
-rw-r--r--src/testing/test_testing_peerstartup.c10
-rw-r--r--src/testing/test_testing_peerstartup2.c18
-rw-r--r--src/testing/test_testing_sharedservices.c8
-rw-r--r--src/testing/testing.c122
5 files changed, 85 insertions, 85 deletions
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index 37d6f9888..1cec948a2 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -197,7 +197,7 @@ create_hostkeys (const unsigned int no)
197 * Removes the temporary file. 197 * Removes the temporary file.
198 * 198 *
199 * @param cls unused 199 * @param cls unused
200 * @param tc scheduler context 200 * @param tc scheduler context
201 */ 201 */
202static void 202static void
203cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 203cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -221,10 +221,10 @@ cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
221 221
222 222
223/** 223/**
224 * Called whenever we can read stdin non-blocking 224 * Called whenever we can read stdin non-blocking
225 * 225 *
226 * @param cls unused 226 * @param cls unused
227 * @param tc scheduler context 227 * @param tc scheduler context
228 */ 228 */
229static void 229static void
230stdin_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 230stdin_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -259,7 +259,7 @@ stdin_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
259 break; 259 break;
260 } 260 }
261 tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh, 261 tid = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fh,
262 &stdin_cb, NULL); 262 &stdin_cb, NULL);
263} 263}
264 264
265 265
@@ -282,7 +282,7 @@ testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
282 GNUNET_SCHEDULER_shutdown (); 282 GNUNET_SCHEDULER_shutdown ();
283 return; 283 return;
284 } 284 }
285 if (GNUNET_SYSERR == 285 if (GNUNET_SYSERR ==
286 GNUNET_CONFIGURATION_write ((struct GNUNET_CONFIGURATION_Handle *) cfg, 286 GNUNET_CONFIGURATION_write ((struct GNUNET_CONFIGURATION_Handle *) cfg,
287 tmpfilename)) 287 tmpfilename))
288 { 288 {
@@ -322,7 +322,7 @@ run_no_scheduler (void *cls, char *const *args, const char *cfgfile,
322 { 322 {
323 if (create_no > 0) 323 if (create_no > 0)
324 { 324 {
325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
326 "Creating %u configuration files based on template `%s'\n", create_no, create_cfg_template); 326 "Creating %u configuration files based on template `%s'\n", create_no, create_cfg_template);
327 ret = create_unique_cfgs (create_cfg_template, create_no); 327 ret = create_unique_cfgs (create_cfg_template, create_no);
328 } 328 }
diff --git a/src/testing/test_testing_peerstartup.c b/src/testing/test_testing_peerstartup.c
index 3bae6a9ca..b871ed1e3 100644
--- a/src/testing/test_testing_peerstartup.c
+++ b/src/testing/test_testing_peerstartup.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file testing/test_testing_new_peerstartup.c 22 * @file testing/test_testing_new_peerstartup.c
23 * @brief test case for testing peer startup and shutdown using new testing 23 * @brief test case for testing peer startup and shutdown using new testing
24 * library 24 * library
25 * @author Sree Harsha Totakura 25 * @author Sree Harsha Totakura
26 */ 26 */
27 27
@@ -46,7 +46,7 @@ struct TestingContext
46 * The testing system 46 * The testing system
47 */ 47 */
48 struct GNUNET_TESTING_System *system; 48 struct GNUNET_TESTING_System *system;
49 49
50 /** 50 /**
51 * The peer which has been started by the testing system 51 * The peer which has been started by the testing system
52 */ 52 */
@@ -69,7 +69,7 @@ static void
69do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 69do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
70{ 70{
71 struct TestingContext *test_ctx = cls; 71 struct TestingContext *test_ctx = cls;
72 72
73 GNUNET_assert (NULL != test_ctx); 73 GNUNET_assert (NULL != test_ctx);
74 if (NULL != test_ctx->peer) 74 if (NULL != test_ctx->peer)
75 { 75 {
@@ -96,14 +96,14 @@ run (void *cls, char *const *args, const char *cfgfile,
96 struct GNUNET_PeerIdentity id; 96 struct GNUNET_PeerIdentity id;
97 97
98 test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); 98 test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
99 test_ctx->system = 99 test_ctx->system =
100 GNUNET_TESTING_system_create ("test-gnunet-testing", 100 GNUNET_TESTING_system_create ("test-gnunet-testing",
101 "127.0.0.1", NULL, NULL); 101 "127.0.0.1", NULL, NULL);
102 emsg = NULL; 102 emsg = NULL;
103 if (NULL == test_ctx->system) 103 if (NULL == test_ctx->system)
104 goto end; 104 goto end;
105 test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg); 105 test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg);
106 test_ctx->peer = 106 test_ctx->peer =
107 GNUNET_TESTING_peer_configure (test_ctx->system, 107 GNUNET_TESTING_peer_configure (test_ctx->system,
108 test_ctx->cfg, 108 test_ctx->cfg,
109 0, &id, &emsg); 109 0, &id, &emsg);
diff --git a/src/testing/test_testing_peerstartup2.c b/src/testing/test_testing_peerstartup2.c
index 8bc6396d3..a4bdd4d65 100644
--- a/src/testing/test_testing_peerstartup2.c
+++ b/src/testing/test_testing_peerstartup2.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file testing/test_testing_new_peerstartup.c 22 * @file testing/test_testing_new_peerstartup.c
23 * @brief test case for testing peer startup and shutdown using new testing 23 * @brief test case for testing peer startup and shutdown using new testing
24 * library 24 * library
25 * @author Sree Harsha Totakura 25 * @author Sree Harsha Totakura
26 */ 26 */
27 27
@@ -42,7 +42,7 @@
42 } \ 42 } \
43 } \ 43 } \
44 } while (0) \ 44 } while (0) \
45 45
46 46
47/** 47/**
48 * The status of the test 48 * The status of the test
@@ -58,7 +58,7 @@ struct TestingContext
58 * The testing system 58 * The testing system
59 */ 59 */
60 struct GNUNET_TESTING_System *system; 60 struct GNUNET_TESTING_System *system;
61 61
62 /** 62 /**
63 * The peer which has been started by the testing system 63 * The peer which has been started by the testing system
64 */ 64 */
@@ -94,7 +94,7 @@ do_shutdown2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
94 if (NULL != test_ctx->system) 94 if (NULL != test_ctx->system)
95 GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES); 95 GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES);
96 GNUNET_free (test_ctx); 96 GNUNET_free (test_ctx);
97 97
98} 98}
99 99
100 100
@@ -143,7 +143,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
143 GNUNET_assert (NULL != test_ctx); 143 GNUNET_assert (NULL != test_ctx);
144 if (NULL != test_ctx->peer) 144 if (NULL != test_ctx->peer)
145 { 145 {
146 FAIL_TEST (GNUNET_OK == 146 FAIL_TEST (GNUNET_OK ==
147 GNUNET_TESTING_peer_stop_async (test_ctx->peer, 147 GNUNET_TESTING_peer_stop_async (test_ctx->peer,
148 &peer_status_cb, 148 &peer_status_cb,
149 test_ctx)); 149 test_ctx));
@@ -165,14 +165,14 @@ run (void *cls, char *const *args, const char *cfgfile,
165 struct GNUNET_PeerIdentity id; 165 struct GNUNET_PeerIdentity id;
166 166
167 test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); 167 test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
168 test_ctx->system = 168 test_ctx->system =
169 GNUNET_TESTING_system_create ("test-gnunet-testing", 169 GNUNET_TESTING_system_create ("test-gnunet-testing",
170 "127.0.0.1", NULL, NULL); 170 "127.0.0.1", NULL, NULL);
171 emsg = NULL; 171 emsg = NULL;
172 if (NULL == test_ctx->system) 172 if (NULL == test_ctx->system)
173 goto end; 173 goto end;
174 test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg); 174 test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg);
175 test_ctx->peer = 175 test_ctx->peer =
176 GNUNET_TESTING_peer_configure (test_ctx->system, 176 GNUNET_TESTING_peer_configure (test_ctx->system,
177 test_ctx->cfg, 177 test_ctx->cfg,
178 0, &id, &emsg); 178 0, &id, &emsg);
@@ -185,7 +185,7 @@ run (void *cls, char *const *args, const char *cfgfile,
185 if (GNUNET_OK != GNUNET_TESTING_peer_start (test_ctx->peer)) 185 if (GNUNET_OK != GNUNET_TESTING_peer_start (test_ctx->peer))
186 goto end; 186 goto end;
187 test_ctx->state = PEER_STARTED; 187 test_ctx->state = PEER_STARTED;
188 FAIL_TEST (GNUNET_OK == 188 FAIL_TEST (GNUNET_OK ==
189 GNUNET_TESTING_peer_stop_async (test_ctx->peer, 189 GNUNET_TESTING_peer_stop_async (test_ctx->peer,
190 &peer_status_cb, 190 &peer_status_cb,
191 test_ctx)); 191 test_ctx));
@@ -193,7 +193,7 @@ run (void *cls, char *const *args, const char *cfgfile,
193 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 193 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
194 &do_shutdown, test_ctx); 194 &do_shutdown, test_ctx);
195 return; 195 return;
196 196
197 end: 197 end:
198 FAIL_TEST (0); 198 FAIL_TEST (0);
199 GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx); 199 GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx);
diff --git a/src/testing/test_testing_sharedservices.c b/src/testing/test_testing_sharedservices.c
index 305b2b21b..5b5bc0a24 100644
--- a/src/testing/test_testing_sharedservices.c
+++ b/src/testing/test_testing_sharedservices.c
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file testing/test_testing_sharedservices.c 22 * @file testing/test_testing_sharedservices.c
23 * @brief test case for testing service sharing among peers started by testing 23 * @brief test case for testing service sharing among peers started by testing
24 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 24 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
@@ -47,7 +47,7 @@ struct TestingContext
47 * The testing system 47 * The testing system
48 */ 48 */
49 struct GNUNET_TESTING_System *system; 49 struct GNUNET_TESTING_System *system;
50 50
51 /** 51 /**
52 * The peer which has been started by the testing system 52 * The peer which has been started by the testing system
53 */ 53 */
@@ -81,7 +81,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
81 continue; 81 continue;
82 (void) GNUNET_TESTING_peer_stop (peer); 82 (void) GNUNET_TESTING_peer_stop (peer);
83 GNUNET_TESTING_peer_destroy (peer); 83 GNUNET_TESTING_peer_destroy (peer);
84 } 84 }
85 if (NULL != test_ctx->cfg) 85 if (NULL != test_ctx->cfg)
86 GNUNET_CONFIGURATION_destroy (test_ctx->cfg); 86 GNUNET_CONFIGURATION_destroy (test_ctx->cfg);
87 if (NULL != test_ctx->system) 87 if (NULL != test_ctx->system)
@@ -108,7 +108,7 @@ run (void *cls, char *const *args, const char *cfgfile,
108 unsigned int cnt; 108 unsigned int cnt;
109 109
110 test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); 110 test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
111 test_ctx->system = 111 test_ctx->system =
112 GNUNET_TESTING_system_create ("test-gnunet-testing", 112 GNUNET_TESTING_system_create ("test-gnunet-testing",
113 "127.0.0.1", NULL, ss); 113 "127.0.0.1", NULL, ss);
114 emsg = NULL; 114 emsg = NULL;
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 10d25637e..600c53c1a 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -149,7 +149,7 @@ struct GNUNET_TESTING_System
149 * by one for each configured peer. Even if peers are destroyed, 149 * by one for each configured peer. Even if peers are destroyed,
150 * we never re-use path counters. 150 * we never re-use path counters.
151 */ 151 */
152 uint32_t path_counter; 152 uint32_t path_counter;
153 153
154 /** 154 /**
155 * The number of hostkeys 155 * The number of hostkeys
@@ -185,13 +185,13 @@ struct GNUNET_TESTING_Peer
185 185
186 /** 186 /**
187 * Binary to be executed during 'GNUNET_TESTING_peer_start'. 187 * Binary to be executed during 'GNUNET_TESTING_peer_start'.
188 * Typically 'gnunet-service-arm' (but can be set to a 188 * Typically 'gnunet-service-arm' (but can be set to a
189 * specific service by 'GNUNET_TESTING_service_run' if 189 * specific service by 'GNUNET_TESTING_service_run' if
190 * necessary). 190 * necessary).
191 */ 191 */
192 char *main_binary; 192 char *main_binary;
193 char *args; 193 char *args;
194 194
195 /** 195 /**
196 * Handle to the running binary of the service, NULL if the 196 * Handle to the running binary of the service, NULL if the
197 * peer/service is currently not running. 197 * peer/service is currently not running.
@@ -215,14 +215,14 @@ struct GNUNET_TESTING_Peer
215 215
216 /** 216 /**
217 * The callback to call asynchronously when a peer is stopped 217 * The callback to call asynchronously when a peer is stopped
218 */ 218 */
219 GNUNET_TESTING_PeerStopCallback cb; 219 GNUNET_TESTING_PeerStopCallback cb;
220 220
221 /** 221 /**
222 * The closure for the above callback 222 * The closure for the above callback
223 */ 223 */
224 void *cb_cls; 224 void *cb_cls;
225 225
226 /** 226 /**
227 * The cached identity of this peer. Will be populated on call to 227 * The cached identity of this peer. Will be populated on call to
228 * GNUNET_TESTING_peer_get_identity() 228 * GNUNET_TESTING_peer_get_identity()
@@ -260,7 +260,7 @@ struct GNUNET_TESTING_Peer
260static int 260static int
261hostkeys_load (struct GNUNET_TESTING_System *system) 261hostkeys_load (struct GNUNET_TESTING_System *system)
262{ 262{
263 uint64_t fs; 263 uint64_t fs;
264 char *data_dir; 264 char *data_dir;
265 char *filename; 265 char *filename;
266 struct GNUNET_DISK_FileHandle *fd; 266 struct GNUNET_DISK_FileHandle *fd;
@@ -268,7 +268,7 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
268 GNUNET_assert (NULL == system->hostkeys_data); 268 GNUNET_assert (NULL == system->hostkeys_data);
269 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); 269 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
270 GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir); 270 GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
271 GNUNET_free (data_dir); 271 GNUNET_free (data_dir);
272 272
273 if (GNUNET_YES != GNUNET_DISK_file_test (filename)) 273 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
274 { 274 {
@@ -278,7 +278,7 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
278 return GNUNET_SYSERR; 278 return GNUNET_SYSERR;
279 } 279 }
280 /* Check hostkey file size, read entire thing into memory */ 280 /* Check hostkey file size, read entire thing into memory */
281 if (GNUNET_OK != 281 if (GNUNET_OK !=
282 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) 282 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
283 fs = 0; 283 fs = 0;
284 if (0 == fs) 284 if (0 == fs)
@@ -558,7 +558,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
558 * @param system system to use for reservation tracking 558 * @param system system to use for reservation tracking
559 * @return 0 if no free port was available 559 * @return 0 if no free port was available
560 */ 560 */
561uint16_t 561uint16_t
562GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system) 562GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
563{ 563{
564 struct GNUNET_NETWORK_Handle *socket; 564 struct GNUNET_NETWORK_Handle *socket;
@@ -576,7 +576,7 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
576 /* 576 /*
577 FIXME: Instead of using getaddrinfo we should try to determine the port 577 FIXME: Instead of using getaddrinfo we should try to determine the port
578 status by the following heurestics. 578 status by the following heurestics.
579 579
580 On systems which support both IPv4 and IPv6, only ports open on both 580 On systems which support both IPv4 and IPv6, only ports open on both
581 address families are considered open. 581 address families are considered open.
582 On system with either IPv4 or IPv6. A port is considered open if it's 582 On system with either IPv4 or IPv6. A port is considered open if it's
@@ -683,7 +683,7 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
683 * faster peer startup. This function can be used to 683 * faster peer startup. This function can be used to
684 * access the n-th key of those pre-created hostkeys; note 684 * access the n-th key of those pre-created hostkeys; note
685 * that these keys are ONLY useful for testing and not 685 * that these keys are ONLY useful for testing and not
686 * secure as the private keys are part of the public 686 * secure as the private keys are part of the public
687 * GNUnet source code. 687 * GNUnet source code.
688 * 688 *
689 * This is primarily a helper function used internally 689 * This is primarily a helper function used internally
@@ -699,9 +699,9 @@ struct GNUNET_CRYPTO_EccPrivateKey *
699GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, 699GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
700 uint32_t key_number, 700 uint32_t key_number,
701 struct GNUNET_PeerIdentity *id) 701 struct GNUNET_PeerIdentity *id)
702{ 702{
703 struct GNUNET_CRYPTO_EccPrivateKey *private_key; 703 struct GNUNET_CRYPTO_EccPrivateKey *private_key;
704 704
705 if ((NULL == id) || (NULL == system->hostkeys_data)) 705 if ((NULL == id) || (NULL == system->hostkeys_data))
706 return NULL; 706 return NULL;
707 if (key_number >= system->total_hostkeys) 707 if (key_number >= system->total_hostkeys)
@@ -709,13 +709,13 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
709 LOG (GNUNET_ERROR_TYPE_ERROR, 709 LOG (GNUNET_ERROR_TYPE_ERROR,
710 _("Key number %u does not exist\n"), key_number); 710 _("Key number %u does not exist\n"), key_number);
711 return NULL; 711 return NULL;
712 } 712 }
713 private_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey); 713 private_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
714 memcpy (private_key, 714 memcpy (private_key,
715 system->hostkeys_data + 715 system->hostkeys_data +
716 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE), 716 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
717 GNUNET_TESTING_HOSTKEYFILESIZE); 717 GNUNET_TESTING_HOSTKEYFILESIZE);
718 GNUNET_CRYPTO_ecc_key_get_public_for_signature (private_key, 718 GNUNET_CRYPTO_ecc_key_get_public_for_signature (private_key,
719 &id->public_key); 719 &id->public_key);
720 return private_key; 720 return private_key;
721} 721}
@@ -731,7 +731,7 @@ struct UpdateContext
731 * The system for which we are building configurations 731 * The system for which we are building configurations
732 */ 732 */
733 struct GNUNET_TESTING_System *system; 733 struct GNUNET_TESTING_System *system;
734 734
735 /** 735 /**
736 * The configuration we are building 736 * The configuration we are building
737 */ 737 */
@@ -865,7 +865,7 @@ static void
865update_config_sections (void *cls, 865update_config_sections (void *cls,
866 const char *section) 866 const char *section)
867{ 867{
868 struct UpdateContext *uc = cls; 868 struct UpdateContext *uc = cls;
869 char **ikeys; 869 char **ikeys;
870 char *val; 870 char *val;
871 char *ptr; 871 char *ptr;
@@ -874,7 +874,7 @@ update_config_sections (void *cls,
874 char *ACCEPT_FROM_key; 874 char *ACCEPT_FROM_key;
875 uint16_t ikeys_cnt; 875 uint16_t ikeys_cnt;
876 uint16_t key; 876 uint16_t key;
877 877
878 ikeys_cnt = 0; 878 ikeys_cnt = 0;
879 val = NULL; 879 val = NULL;
880 /* Ignore certain options from sections. See 880 /* Ignore certain options from sections. See
@@ -882,8 +882,8 @@ update_config_sections (void *cls,
882 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section, 882 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section,
883 "TESTING_IGNORE_KEYS")) 883 "TESTING_IGNORE_KEYS"))
884 { 884 {
885 GNUNET_assert 885 GNUNET_assert
886 (GNUNET_YES == 886 (GNUNET_YES ==
887 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, 887 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section,
888 "TESTING_IGNORE_KEYS", &val)); 888 "TESTING_IGNORE_KEYS", &val));
889 ptr = val; 889 ptr = val;
@@ -915,10 +915,10 @@ update_config_sections (void *cls,
915 (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section, 915 (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section,
916 "ADVERTISED_PORT"))) 916 "ADVERTISED_PORT")))
917 { 917 {
918 if (GNUNET_OK == 918 if (GNUNET_OK ==
919 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr)) 919 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr))
920 { 920 {
921 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, 921 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section,
922 "ADVERTISED_PORT", ptr); 922 "ADVERTISED_PORT", ptr);
923 GNUNET_free (ptr); 923 GNUNET_free (ptr);
924 } 924 }
@@ -935,11 +935,11 @@ update_config_sections (void *cls,
935 GNUNET_free (ikeys); 935 GNUNET_free (ikeys);
936 } 936 }
937 GNUNET_free_non_null (val); 937 GNUNET_free_non_null (val);
938 ACCEPT_FROM_key = "ACCEPT_FROM"; 938 ACCEPT_FROM_key = "ACCEPT_FROM";
939 if ((NULL != uc->system->trusted_ip) && 939 if ((NULL != uc->system->trusted_ip) &&
940 (NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */ 940 (NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */
941 ACCEPT_FROM_key = "ACCEPT_FROM6"; 941 ACCEPT_FROM_key = "ACCEPT_FROM6";
942 if (GNUNET_OK != 942 if (GNUNET_OK !=
943 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key, 943 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key,
944 &orig_allowed_hosts)) 944 &orig_allowed_hosts))
945 { 945 {
@@ -953,7 +953,7 @@ update_config_sections (void *cls,
953 GNUNET_free (orig_allowed_hosts); 953 GNUNET_free (orig_allowed_hosts);
954 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key, 954 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key,
955 allowed_hosts); 955 allowed_hosts);
956 GNUNET_free (allowed_hosts); 956 GNUNET_free (allowed_hosts);
957} 957}
958 958
959static struct SharedServiceInstance * 959static struct SharedServiceInstance *
@@ -969,9 +969,9 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
969 ss->n_peers++; 969 ss->n_peers++;
970 if ( ((0 == ss->share) && (NULL == ss->instances)) 970 if ( ((0 == ss->share) && (NULL == ss->instances))
971 || 971 ||
972 ( (0 != ss->share) 972 ( (0 != ss->share)
973 && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) ) 973 && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) )
974 { 974 {
975 i = GNUNET_malloc (sizeof (struct SharedServiceInstance)); 975 i = GNUNET_malloc (sizeof (struct SharedServiceInstance));
976 i->ss = ss; 976 i->ss = ss;
977 (void) GNUNET_asprintf (&service_home, "%s/shared/%s/%u", 977 (void) GNUNET_asprintf (&service_home, "%s/shared/%s/%u",
@@ -1009,7 +1009,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
1009 GNUNET_assert (0 < ss->n_instances); 1009 GNUNET_assert (0 < ss->n_instances);
1010 i = ss->instances[ss->n_instances - 1]; 1010 i = ss->instances[ss->n_instances - 1];
1011 } 1011 }
1012 GNUNET_CONFIGURATION_iterate_section_values(ss->cfg, ss->sname, 1012 GNUNET_CONFIGURATION_iterate_section_values(ss->cfg, ss->sname,
1013 &cfg_copy_iterator, cfg); 1013 &cfg_copy_iterator, cfg);
1014 GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH", 1014 GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH",
1015 i->unix_sock); 1015 i->unix_sock);
@@ -1044,7 +1044,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
1044 unsigned int *nports) 1044 unsigned int *nports)
1045{ 1045{
1046 struct UpdateContext uc; 1046 struct UpdateContext uc;
1047 char *default_config; 1047 char *default_config;
1048 1048
1049 uc.system = system; 1049 uc.system = system;
1050 uc.cfg = cfg; 1050 uc.cfg = cfg;
@@ -1066,7 +1066,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
1066 /* allow connections to services from system trusted_ip host */ 1066 /* allow connections to services from system trusted_ip host */
1067 GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc); 1067 GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc);
1068 /* enable loopback-based connections between peers */ 1068 /* enable loopback-based connections between peers */
1069 GNUNET_CONFIGURATION_set_value_string (cfg, 1069 GNUNET_CONFIGURATION_set_value_string (cfg,
1070 "nat", 1070 "nat",
1071 "USE_LOCALADDR", "YES"); 1071 "USE_LOCALADDR", "YES");
1072 GNUNET_free (uc.service_home); 1072 GNUNET_free (uc.service_home);
@@ -1107,14 +1107,14 @@ GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system,
1107 1107
1108/** 1108/**
1109 * Configure a GNUnet peer. GNUnet must be installed on the local 1109 * Configure a GNUnet peer. GNUnet must be installed on the local
1110 * system and available in the PATH. 1110 * system and available in the PATH.
1111 * 1111 *
1112 * @param system system to use to coordinate resource usage 1112 * @param system system to use to coordinate resource usage
1113 * @param cfg configuration to use; will be UPDATED (to reflect needed 1113 * @param cfg configuration to use; will be UPDATED (to reflect needed
1114 * changes in port numbers and paths) 1114 * changes in port numbers and paths)
1115 * @param key_number number of the hostkey to use for the peer 1115 * @param key_number number of the hostkey to use for the peer
1116 * @param id identifier for the daemon, will be set, can be NULL 1116 * @param id identifier for the daemon, will be set, can be NULL
1117 * @param emsg set to freshly allocated error message (set to NULL on success), 1117 * @param emsg set to freshly allocated error message (set to NULL on success),
1118 * can be NULL 1118 * can be NULL
1119 * @return handle to the peer, NULL on error 1119 * @return handle to the peer, NULL on error
1120 */ 1120 */
@@ -1136,7 +1136,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1136 struct SharedService *ss; 1136 struct SharedService *ss;
1137 struct SharedServiceInstance **ss_instances; 1137 struct SharedServiceInstance **ss_instances;
1138 unsigned int cnt; 1138 unsigned int cnt;
1139 unsigned int nports; 1139 unsigned int nports;
1140 1140
1141 ports = NULL; 1141 ports = NULL;
1142 nports = 0; 1142 nports = 0;
@@ -1147,7 +1147,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1147 { 1147 {
1148 GNUNET_asprintf (&emsg_, 1148 GNUNET_asprintf (&emsg_,
1149 _("You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"), 1149 _("You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"),
1150 (unsigned int) system->total_hostkeys); 1150 (unsigned int) system->total_hostkeys);
1151 goto err_ret; 1151 goto err_ret;
1152 } 1152 }
1153 pk = NULL; 1153 pk = NULL;
@@ -1158,13 +1158,13 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1158 _("Failed to initialize hostkey for peer %u\n"), 1158 _("Failed to initialize hostkey for peer %u\n"),
1159 (unsigned int) key_number); 1159 (unsigned int) key_number);
1160 goto err_ret; 1160 goto err_ret;
1161 } 1161 }
1162 if (NULL != pk) 1162 if (NULL != pk)
1163 GNUNET_free (pk); 1163 GNUNET_free (pk);
1164 if (GNUNET_NO == 1164 if (GNUNET_NO ==
1165 GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY")) 1165 GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY"))
1166 { 1166 {
1167 GNUNET_asprintf (&emsg_, 1167 GNUNET_asprintf (&emsg_,
1168 _("PRIVATE_KEY option in PEER section missing in configuration\n")); 1168 _("PRIVATE_KEY option in PEER section missing in configuration\n"));
1169 goto err_ret; 1169 goto err_ret;
1170 } 1170 }
@@ -1182,13 +1182,13 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1182 "(not enough free ports?)\n")); 1182 "(not enough free ports?)\n"));
1183 goto err_ret; 1183 goto err_ret;
1184 } 1184 }
1185 GNUNET_assert (GNUNET_OK == 1185 GNUNET_assert (GNUNET_OK ==
1186 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", 1186 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER",
1187 "PRIVATE_KEY", 1187 "PRIVATE_KEY",
1188 &hostkey_filename)); 1188 &hostkey_filename));
1189 fd = GNUNET_DISK_file_open (hostkey_filename, 1189 fd = GNUNET_DISK_file_open (hostkey_filename,
1190 GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE, 1190 GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE,
1191 GNUNET_DISK_PERM_USER_READ 1191 GNUNET_DISK_PERM_USER_READ
1192 | GNUNET_DISK_PERM_USER_WRITE); 1192 | GNUNET_DISK_PERM_USER_WRITE);
1193 if (NULL == fd) 1193 if (NULL == fd)
1194 { 1194 {
@@ -1199,7 +1199,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1199 } 1199 }
1200 GNUNET_free (hostkey_filename); 1200 GNUNET_free (hostkey_filename);
1201 if (GNUNET_TESTING_HOSTKEYFILESIZE != 1201 if (GNUNET_TESTING_HOSTKEYFILESIZE !=
1202 GNUNET_DISK_file_write (fd, system->hostkeys_data 1202 GNUNET_DISK_file_write (fd, system->hostkeys_data
1203 + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE), 1203 + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
1204 GNUNET_TESTING_HOSTKEYFILESIZE)) 1204 GNUNET_TESTING_HOSTKEYFILESIZE))
1205 { 1205 {
@@ -1219,17 +1219,17 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1219 ss_instances[cnt] = associate_shared_service (system, ss, cfg); 1219 ss_instances[cnt] = associate_shared_service (system, ss, cfg);
1220 if (NULL == ss_instances[cnt]) 1220 if (NULL == ss_instances[cnt])
1221 goto err_ret; 1221 goto err_ret;
1222 } 1222 }
1223 GNUNET_assert (GNUNET_OK == 1223 GNUNET_assert (GNUNET_OK ==
1224 GNUNET_CONFIGURATION_get_value_string 1224 GNUNET_CONFIGURATION_get_value_string
1225 (cfg, "PATHS", "DEFAULTCONFIG", &config_filename)); 1225 (cfg, "PATHS", "DEFAULTCONFIG", &config_filename));
1226 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename)) 1226 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename))
1227 { 1227 {
1228 GNUNET_asprintf (&emsg_, 1228 GNUNET_asprintf (&emsg_,
1229 _("Failed to write configuration file `%s' for peer %u: %s\n"), 1229 _("Failed to write configuration file `%s' for peer %u: %s\n"),
1230 config_filename, 1230 config_filename,
1231 (unsigned int) key_number, 1231 (unsigned int) key_number,
1232 STRERROR (errno)); 1232 STRERROR (errno));
1233 GNUNET_free (config_filename); 1233 GNUNET_free (config_filename);
1234 goto err_ret; 1234 goto err_ret;
1235 } 1235 }
@@ -1289,7 +1289,7 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
1289 1289
1290 1290
1291/** 1291/**
1292 * Start the peer. 1292 * Start the peer.
1293 * 1293 *
1294 * @param peer peer to start 1294 * @param peer peer to start
1295 * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running) 1295 * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running)
@@ -1304,7 +1304,7 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
1304 { 1304 {
1305 GNUNET_break (0); 1305 GNUNET_break (0);
1306 return GNUNET_SYSERR; 1306 return GNUNET_SYSERR;
1307 } 1307 }
1308 GNUNET_assert (NULL != peer->cfgfile); 1308 GNUNET_assert (NULL != peer->cfgfile);
1309 for (cnt = 0; cnt < peer->system->n_shared_services; cnt++) 1309 for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
1310 { 1310 {
@@ -1314,7 +1314,7 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
1314 return GNUNET_SYSERR; 1314 return GNUNET_SYSERR;
1315 i->n_refs++; 1315 i->n_refs++;
1316 } 1316 }
1317 peer->main_process = GNUNET_OS_start_process (PIPE_CONTROL, 1317 peer->main_process = GNUNET_OS_start_process (PIPE_CONTROL,
1318 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 1318 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1319 NULL, NULL, 1319 NULL, NULL,
1320 peer->main_binary, 1320 peer->main_binary,
@@ -1377,7 +1377,7 @@ GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer,
1377 * @return GNUNET_OK upon successfully queuing the service stop request; 1377 * @return GNUNET_OK upon successfully queuing the service stop request;
1378 * GNUNET_SYSERR upon error 1378 * GNUNET_SYSERR upon error
1379 */ 1379 */
1380int 1380int
1381GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer, 1381GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
1382 const char *service_name, 1382 const char *service_name,
1383 struct GNUNET_TIME_Relative timeout, 1383 struct GNUNET_TIME_Relative timeout,
@@ -1386,13 +1386,13 @@ GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
1386{ 1386{
1387 if (NULL == peer->ah) 1387 if (NULL == peer->ah)
1388 return GNUNET_SYSERR; 1388 return GNUNET_SYSERR;
1389 GNUNET_ARM_request_service_stop (peer->ah, 1389 GNUNET_ARM_request_service_stop (peer->ah,
1390 service_name, 1390 service_name,
1391 timeout, 1391 timeout,
1392 cont, cont_cls); 1392 cont, cont_cls);
1393 return GNUNET_OK; 1393 return GNUNET_OK;
1394} 1394}
1395 1395
1396 1396
1397/** 1397/**
1398 * Sends SIGTERM to the peer's main process 1398 * Sends SIGTERM to the peer's main process
@@ -1451,7 +1451,7 @@ GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer)
1451 1451
1452 1452
1453/** 1453/**
1454 * Stop the peer. 1454 * Stop the peer.
1455 * 1455 *
1456 * @param peer peer to stop 1456 * @param peer peer to stop
1457 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1457 * @return GNUNET_OK on success, GNUNET_SYSERR on error
@@ -1475,7 +1475,7 @@ GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer)
1475 * GNUNET_SYSERR on error. 1475 * GNUNET_SYSERR on error.
1476 */ 1476 */
1477static void 1477static void
1478disconn_status (void *cls, 1478disconn_status (void *cls,
1479 int connected) 1479 int connected)
1480{ 1480{
1481 struct GNUNET_TESTING_Peer *peer = cls; 1481 struct GNUNET_TESTING_Peer *peer = cls;
@@ -1514,7 +1514,7 @@ GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer,
1514 void *cb_cls) 1514 void *cb_cls)
1515{ 1515{
1516 if (NULL == peer->main_process) 1516 if (NULL == peer->main_process)
1517 return GNUNET_SYSERR; 1517 return GNUNET_SYSERR;
1518 peer->ah = GNUNET_ARM_connect (peer->cfg, &disconn_status, peer); 1518 peer->ah = GNUNET_ARM_connect (peer->cfg, &disconn_status, peer);
1519 if (NULL == peer->ah) 1519 if (NULL == peer->ah)
1520 return GNUNET_SYSERR; 1520 return GNUNET_SYSERR;
@@ -1535,7 +1535,7 @@ GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer,
1535 */ 1535 */
1536void 1536void
1537GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer) 1537GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer)
1538{ 1538{
1539 GNUNET_assert (NULL != peer->ah); 1539 GNUNET_assert (NULL != peer->ah);
1540 GNUNET_ARM_disconnect_and_free (peer->ah); 1540 GNUNET_ARM_disconnect_and_free (peer->ah);
1541 peer->ah = NULL; 1541 peer->ah = NULL;
@@ -1618,7 +1618,7 @@ struct ServiceContext
1618 * Callback to signal service startup 1618 * Callback to signal service startup
1619 */ 1619 */
1620 GNUNET_TESTING_TestMain tm; 1620 GNUNET_TESTING_TestMain tm;
1621 1621
1622 /** 1622 /**
1623 * The peer in which the service is run. 1623 * The peer in which the service is run.
1624 */ 1624 */
@@ -1719,7 +1719,7 @@ GNUNET_TESTING_service_run (const char *testdir,
1719 GNUNET_free (libexec_binary); 1719 GNUNET_free (libexec_binary);
1720 GNUNET_free (binary); 1720 GNUNET_free (binary);
1721 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer)) 1721 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer))
1722 { 1722 {
1723 GNUNET_TESTING_peer_destroy (peer); 1723 GNUNET_TESTING_peer_destroy (peer);
1724 GNUNET_CONFIGURATION_destroy (cfg); 1724 GNUNET_CONFIGURATION_destroy (cfg);
1725 GNUNET_TESTING_system_destroy (system, GNUNET_YES); 1725 GNUNET_TESTING_system_destroy (system, GNUNET_YES);
@@ -1749,14 +1749,14 @@ GNUNET_TESTING_service_run (const char *testdir,
1749 * Sometimes we use the binary name to determine which specific 1749 * Sometimes we use the binary name to determine which specific
1750 * test to run. In those cases, the string after the last "_" 1750 * test to run. In those cases, the string after the last "_"
1751 * in 'argv[0]' specifies a string that determines the configuration 1751 * in 'argv[0]' specifies a string that determines the configuration
1752 * file or plugin to use. 1752 * file or plugin to use.
1753 * 1753 *
1754 * This function returns the respective substring, taking care 1754 * This function returns the respective substring, taking care
1755 * of issues such as binaries ending in '.exe' on W32. 1755 * of issues such as binaries ending in '.exe' on W32.
1756 * 1756 *
1757 * @param argv0 the name of the binary 1757 * @param argv0 the name of the binary
1758 * @return string between the last '_' and the '.exe' (or the end of the string), 1758 * @return string between the last '_' and the '.exe' (or the end of the string),
1759 * NULL if argv0 has no '_' 1759 * NULL if argv0 has no '_'
1760 */ 1760 */
1761char * 1761char *
1762GNUNET_TESTING_get_testname_from_underscore (const char *argv0) 1762GNUNET_TESTING_get_testname_from_underscore (const char *argv0)