aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_twopeer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/test_dht_twopeer.c')
-rw-r--r--src/dht/test_dht_twopeer.c331
1 files changed, 178 insertions, 153 deletions
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c
index 8c373d365..6ba3799dc 100644
--- a/src/dht/test_dht_twopeer.c
+++ b/src/dht/test_dht_twopeer.c
@@ -87,53 +87,53 @@ static struct GNUNET_DHT_Handle *peer2dht;
87/** 87/**
88 * Check whether peers successfully shut down. 88 * Check whether peers successfully shut down.
89 */ 89 */
90void shutdown_callback (void *cls, 90void
91 const char *emsg) 91shutdown_callback (void *cls, const char *emsg)
92{ 92{
93 if (emsg != NULL) 93 if (emsg != NULL)
94 { 94 {
95 if (ok == 0) 95 if (ok == 0)
96 ok = 2; 96 ok = 2;
97 } 97 }
98} 98}
99 99
100static void 100static void
101finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 101finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
102{ 102{
103 GNUNET_assert (pg != NULL); 103 GNUNET_assert (pg != NULL);
104 GNUNET_assert (peer1dht != NULL); 104 GNUNET_assert (peer1dht != NULL);
105 GNUNET_assert (peer2dht != NULL); 105 GNUNET_assert (peer2dht != NULL);
106 GNUNET_DHT_disconnect(peer1dht); 106 GNUNET_DHT_disconnect (peer1dht);
107 GNUNET_DHT_disconnect(peer2dht); 107 GNUNET_DHT_disconnect (peer2dht);
108 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 108 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
109 ok = 0; 109 ok = 0;
110} 110}
111 111
112static void 112static void
113end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 113end_badly_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
114{ 114{
115 if (peer1dht != NULL) 115 if (peer1dht != NULL)
116 GNUNET_DHT_disconnect(peer1dht); 116 GNUNET_DHT_disconnect (peer1dht);
117 117
118 if (peer2dht != NULL) 118 if (peer2dht != NULL)
119 GNUNET_DHT_disconnect(peer2dht); 119 GNUNET_DHT_disconnect (peer2dht);
120 120
121 if (pg != NULL) 121 if (pg != NULL)
122 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 122 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
123 123
124 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) 124 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
125 GNUNET_SCHEDULER_cancel(curr_get_ctx.retry_task); 125 GNUNET_SCHEDULER_cancel (curr_get_ctx.retry_task);
126} 126}
127 127
128static void 128static void
129end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 129end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
130{ 130{
131 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK) 131 if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
132 GNUNET_SCHEDULER_cancel(curr_get_ctx.retry_task); 132 GNUNET_SCHEDULER_cancel (curr_get_ctx.retry_task);
133 133
134 if (curr_get_ctx.get_handle != NULL) 134 if (curr_get_ctx.get_handle != NULL)
135 { 135 {
136 GNUNET_DHT_get_stop(curr_get_ctx.get_handle); 136 GNUNET_DHT_get_stop (curr_get_ctx.get_handle);
137 } 137 }
138 138
139 GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL); 139 GNUNET_SCHEDULER_add_now (&end_badly_cont, NULL);
@@ -141,8 +141,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
141} 141}
142 142
143/* Forward declaration */ 143/* Forward declaration */
144static void 144static void do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
145do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc);
146 145
147/** 146/**
148 * Iterator called on each result obtained for a DHT 147 * Iterator called on each result obtained for a DHT
@@ -155,108 +154,122 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc);
155 * @param size number of bytes in data 154 * @param size number of bytes in data
156 * @param data pointer to the result data 155 * @param data pointer to the result data
157 */ 156 */
158void get_result_iterator (void *cls, 157void
159 struct GNUNET_TIME_Absolute exp, 158get_result_iterator (void *cls,
160 const GNUNET_HashCode * key, 159 struct GNUNET_TIME_Absolute exp,
161 const struct GNUNET_PeerIdentity * const *get_path, 160 const GNUNET_HashCode * key,
162 const struct GNUNET_PeerIdentity * const *put_path, 161 const struct GNUNET_PeerIdentity *const *get_path,
163 enum GNUNET_BLOCK_Type type, 162 const struct GNUNET_PeerIdentity *const *put_path,
164 size_t size, 163 enum GNUNET_BLOCK_Type type, size_t size, const void *data)
165 const void *data)
166{ 164{
167 struct PeerGetContext *get_context = cls; 165 struct PeerGetContext *get_context = cls;
168 166
169 if (0 != memcmp(&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode))) 167 if (0 !=
168 memcmp (&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode)))
170 { 169 {
171 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Key returned is not the same key as was searched for!\n"); 170 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
172 GNUNET_SCHEDULER_cancel(die_task); 171 "Key returned is not the same key as was searched for!\n");
173 GNUNET_SCHEDULER_add_now(&end_badly, "key mismatch in get response!\n"); 172 GNUNET_SCHEDULER_cancel (die_task);
173 GNUNET_SCHEDULER_add_now (&end_badly, "key mismatch in get response!\n");
174 return; 174 return;
175 } 175 }
176 176
177 if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK) 177 if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK)
178 { 178 {
179 GNUNET_SCHEDULER_cancel(get_context->retry_task); 179 GNUNET_SCHEDULER_cancel (get_context->retry_task);
180 get_context->retry_task = GNUNET_SCHEDULER_NO_TASK; 180 get_context->retry_task = GNUNET_SCHEDULER_NO_TASK;
181 } 181 }
182 182
183 if (get_context->peer == &peer2id) 183 if (get_context->peer == &peer2id)
184 { 184 {
185 get_context->peer = &peer1id; 185 get_context->peer = &peer1id;
186 get_context->dht_handle = peer2dht; 186 get_context->dht_handle = peer2dht;
187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received first correct GET request response!\n"); 187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
188 GNUNET_DHT_get_stop(get_context->get_handle); 188 "Received first correct GET request response!\n");
189 GNUNET_DHT_get_stop (get_context->get_handle);
189 GNUNET_SCHEDULER_add_now (&do_get, get_context); 190 GNUNET_SCHEDULER_add_now (&do_get, get_context);
190 } 191 }
191 else 192 else
192 { 193 {
193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received second correct GET request response!\n"); 194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
194 GNUNET_SCHEDULER_cancel(die_task); 195 "Received second correct GET request response!\n");
195 GNUNET_DHT_get_stop(get_context->get_handle); 196 GNUNET_SCHEDULER_cancel (die_task);
197 GNUNET_DHT_get_stop (get_context->get_handle);
196 GNUNET_SCHEDULER_add_now (&finish_testing, NULL); 198 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
197 } 199 }
198 200
199} 201}
200 202
201static void 203static void
202stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc); 204stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
203 205
204static void 206static void
205get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 207get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
206{ 208{
207 struct PeerGetContext *get_context = cls; 209 struct PeerGetContext *get_context = cls;
208 210
209 if (get_context->get_attempts < MAX_GET_ATTEMPTS) 211 if (get_context->get_attempts < MAX_GET_ATTEMPTS)
210 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, retrying request!\n", get_context->get_attempts); 212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
213 "Get attempt %u failed, retrying request!\n",
214 get_context->get_attempts);
211 else 215 else
212 { 216 {
213 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Too many attempts failed, ending test!\n", get_context->get_attempts); 217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
214 GNUNET_SCHEDULER_cancel(die_task); 218 "Too many attempts failed, ending test!\n",
215 GNUNET_SCHEDULER_add_now(&end_badly, "key mismatch in get response!\n"); 219 get_context->get_attempts);
216 return; 220 GNUNET_SCHEDULER_cancel (die_task);
217 } 221 GNUNET_SCHEDULER_add_now (&end_badly, "key mismatch in get response!\n");
222 return;
223 }
218 get_context->get_attempts++; 224 get_context->get_attempts++;
219 get_context->retry_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), 225 get_context->retry_task =
220 &stop_retry_get, get_context); 226 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
221 get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 227 (GNUNET_TIME_UNIT_SECONDS, 10),
222 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), 228 &stop_retry_get, get_context);
223 GNUNET_BLOCK_TYPE_DHT_HELLO, 229 get_context->get_handle =
224 &get_context->peer->hashPubKey, 230 GNUNET_DHT_get_start (get_context->dht_handle,
225 DEFAULT_GET_REPLICATION, 231 GNUNET_TIME_relative_multiply
226 GNUNET_DHT_RO_NONE, 232 (GNUNET_TIME_UNIT_SECONDS, 5),
227 NULL, 0, 233 GNUNET_BLOCK_TYPE_DHT_HELLO,
228 NULL, 0, 234 &get_context->peer->hashPubKey,
229 &get_result_iterator, get_context); 235 DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL,
236 0, NULL, 0, &get_result_iterator, get_context);
230} 237}
231 238
232static void 239static void
233stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 240stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
234{ 241{
235 struct PeerGetContext *get_context = cls; 242 struct PeerGetContext *get_context = cls;
243
236 get_context->retry_task = GNUNET_SCHEDULER_NO_TASK; 244 get_context->retry_task = GNUNET_SCHEDULER_NO_TASK;
237 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Get attempt %u failed, canceling request!\n", get_context->get_attempts); 245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
238 GNUNET_DHT_get_stop(get_context->get_handle); 246 "Get attempt %u failed, canceling request!\n",
247 get_context->get_attempts);
248 GNUNET_DHT_get_stop (get_context->get_handle);
239 get_context->get_handle = NULL; 249 get_context->get_handle = NULL;
240 GNUNET_SCHEDULER_add_now(&get_stop_finished, get_context); 250 GNUNET_SCHEDULER_add_now (&get_stop_finished, get_context);
241} 251}
242 252
243static void 253static void
244do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 254do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
245{ 255{
246 struct PeerGetContext *get_context = cls; 256 struct PeerGetContext *get_context = cls;
247 257
248 get_context->retry_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), 258 get_context->retry_task =
249 &stop_retry_get, get_context); 259 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
250 260 (GNUNET_TIME_UNIT_SECONDS, 10),
251 get_context->get_handle = GNUNET_DHT_get_start(get_context->dht_handle, 261 &stop_retry_get, get_context);
252 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), 262
253 GNUNET_BLOCK_TYPE_DHT_HELLO, 263 get_context->get_handle = GNUNET_DHT_get_start (get_context->dht_handle,
254 &get_context->peer->hashPubKey, 264 GNUNET_TIME_relative_multiply
255 DEFAULT_GET_REPLICATION, 265 (GNUNET_TIME_UNIT_SECONDS, 5),
256 GNUNET_DHT_RO_NONE, 266 GNUNET_BLOCK_TYPE_DHT_HELLO,
257 NULL, 0, 267 &get_context->
258 NULL, 0, 268 peer->hashPubKey,
259 &get_result_iterator, get_context); 269 DEFAULT_GET_REPLICATION,
270 GNUNET_DHT_RO_NONE, NULL, 0,
271 NULL, 0, &get_result_iterator,
272 get_context);
260} 273}
261 274
262 275
@@ -272,49 +285,52 @@ topology_callback (void *cls,
272 const char *emsg) 285 const char *emsg)
273{ 286{
274 if (emsg == NULL) 287 if (emsg == NULL)
275 { 288 {
276 total_connections++; 289 total_connections++;
277#if VERBOSE 290#if VERBOSE
278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
279 first_daemon->shortname, 292 "connected peer %s to peer %s, distance %u\n",
280 second_daemon->shortname, 293 first_daemon->shortname, second_daemon->shortname, distance);
281 distance);
282#endif 294#endif
283 } 295 }
284#if VERBOSE 296#if VERBOSE
285 else 297 else
286 { 298 {
287 failed_connections++; 299 failed_connections++;
288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", 300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
289 first_daemon->shortname, 301 "Failed to connect peer %s to peer %s with error :\n%s\n",
290 second_daemon->shortname, emsg); 302 first_daemon->shortname, second_daemon->shortname, emsg);
291 } 303 }
292#endif 304#endif
293 305
294 if (total_connections == expected_connections) 306 if (total_connections == expected_connections)
295 { 307 {
296#if VERBOSE 308#if VERBOSE
297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
298 "Created %d total connections, which is our target number! Starting next phase of testing.\n", 310 "Created %d total connections, which is our target number! Starting next phase of testing.\n",
299 total_connections); 311 total_connections);
300#endif 312#endif
301 GNUNET_SCHEDULER_cancel (die_task); 313 GNUNET_SCHEDULER_cancel (die_task);
302 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 314 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
303 &end_badly, "from test gets"); 315 &end_badly, "from test gets");
304 316
305 curr_get_ctx.dht_handle = peer1dht; 317 curr_get_ctx.dht_handle = peer1dht;
306 curr_get_ctx.peer = &peer2id; 318 curr_get_ctx.peer = &peer2id;
307 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &do_get, &curr_get_ctx); 319 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
308 } 320 (GNUNET_TIME_UNIT_SECONDS, 2), &do_get,
321 &curr_get_ctx);
322 }
309 else if (total_connections + failed_connections == expected_connections) 323 else if (total_connections + failed_connections == expected_connections)
310 { 324 {
311 GNUNET_SCHEDULER_cancel (die_task); 325 GNUNET_SCHEDULER_cancel (die_task);
312 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); 326 die_task =
313 } 327 GNUNET_SCHEDULER_add_now (&end_badly,
328 "from topology_callback (too many failed connections)");
329 }
314} 330}
315 331
316static void 332static void
317connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 333connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
318{ 334{
319 expected_connections = -1; 335 expected_connections = -1;
320 if ((pg != NULL) && (peers_left == 0)) 336 if ((pg != NULL) && (peers_left == 0))
@@ -322,48 +338,52 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
322 GNUNET_TESTING_TOPOLOGY_CLIQUE, 338 GNUNET_TESTING_TOPOLOGY_CLIQUE,
323 GNUNET_TESTING_TOPOLOGY_OPTION_ALL, 339 GNUNET_TESTING_TOPOLOGY_OPTION_ALL,
324 0.0, 340 0.0,
325 TIMEOUT, 12, NULL, NULL); 341 TIMEOUT, 12, NULL,
342 NULL);
326 343
327 GNUNET_SCHEDULER_cancel (die_task); 344 GNUNET_SCHEDULER_cancel (die_task);
328 if (expected_connections == GNUNET_SYSERR) 345 if (expected_connections == GNUNET_SYSERR)
329 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); 346 die_task =
347 GNUNET_SCHEDULER_add_now (&end_badly,
348 "from connect topology (bad return)");
330 349
331 350
332 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 351 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
333 &end_badly, "from connect topology (timeout)"); 352 &end_badly,
353 "from connect topology (timeout)");
334} 354}
335 355
336static void 356static void
337peers_started_callback (void *cls, 357peers_started_callback (void *cls,
338 const struct GNUNET_PeerIdentity *id, 358 const struct GNUNET_PeerIdentity *id,
339 const struct GNUNET_CONFIGURATION_Handle *cfg, 359 const struct GNUNET_CONFIGURATION_Handle *cfg,
340 struct GNUNET_TESTING_Daemon *d, const char *emsg) 360 struct GNUNET_TESTING_Daemon *d, const char *emsg)
341{ 361{
342 if (emsg != NULL) 362 if (emsg != NULL)
343 { 363 {
344 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to start daemon with error: `%s'\n", 364 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
345 emsg); 365 "Failed to start daemon with error: `%s'\n", emsg);
346 return; 366 return;
347 } 367 }
348 GNUNET_assert (id != NULL); 368 GNUNET_assert (id != NULL);
349 if (peers_left == num_peers) 369 if (peers_left == num_peers)
350 { 370 {
351 memcpy(&peer1id, id, sizeof(struct GNUNET_PeerIdentity)); 371 memcpy (&peer1id, id, sizeof (struct GNUNET_PeerIdentity));
352 peer1dht = GNUNET_DHT_connect(cfg, 100); 372 peer1dht = GNUNET_DHT_connect (cfg, 100);
353 if (peer1dht == NULL) 373 if (peer1dht == NULL)
354 { 374 {
355 GNUNET_SCHEDULER_cancel (die_task); 375 GNUNET_SCHEDULER_cancel (die_task);
356 GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n"); 376 GNUNET_SCHEDULER_add_now (&end_badly, "Failed to get dht handle!\n");
357 } 377 }
358 } 378 }
359 else 379 else
360 { 380 {
361 memcpy(&peer2id, id, sizeof(struct GNUNET_PeerIdentity)); 381 memcpy (&peer2id, id, sizeof (struct GNUNET_PeerIdentity));
362 peer2dht = GNUNET_DHT_connect(cfg, 100); 382 peer2dht = GNUNET_DHT_connect (cfg, 100);
363 if (peer2dht == NULL) 383 if (peer2dht == NULL)
364 { 384 {
365 GNUNET_SCHEDULER_cancel (die_task); 385 GNUNET_SCHEDULER_cancel (die_task);
366 GNUNET_SCHEDULER_add_now(&end_badly, "Failed to get dht handle!\n"); 386 GNUNET_SCHEDULER_add_now (&end_badly, "Failed to get dht handle!\n");
367 } 387 }
368 } 388 }
369 389
@@ -371,21 +391,21 @@ peers_started_callback (void *cls,
371 peers_left--; 391 peers_left--;
372 392
373 if (peers_left == 0) 393 if (peers_left == 0)
374 { 394 {
375#if VERBOSE 395#if VERBOSE
376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
377 "All %d daemons started, now connecting peers!\n", 397 "All %d daemons started, now connecting peers!\n", num_peers);
378 num_peers);
379#endif 398#endif
380 GNUNET_SCHEDULER_cancel (die_task); 399 GNUNET_SCHEDULER_cancel (die_task);
381 /* Set up task in case topology creation doesn't finish 400 /* Set up task in case topology creation doesn't finish
382 * within a reasonable amount of time */ 401 * within a reasonable amount of time */
383 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 402 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
384 &end_badly, "from peers_started_callback"); 403 &end_badly,
385 404 "from peers_started_callback");
386 GNUNET_SCHEDULER_add_now(&connect_topology, NULL); 405
387 ok = 0; 406 GNUNET_SCHEDULER_add_now (&connect_topology, NULL);
388 } 407 ok = 0;
408 }
389} 409}
390 410
391static void 411static void
@@ -394,11 +414,13 @@ run (void *cls,
394 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 414 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
395{ 415{
396 416
397 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) 417 if (GNUNET_YES !=
398 { 418 GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
399 ok = 404; 419 &test_directory))
400 return; 420 {
401 } 421 ok = 404;
422 return;
423 }
402 424
403 if (GNUNET_SYSERR == 425 if (GNUNET_SYSERR ==
404 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", 426 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
@@ -410,7 +432,8 @@ run (void *cls,
410 gets_succeeded = 0; 432 gets_succeeded = 0;
411 /* Set up a task to end testing if peer start fails */ 433 /* Set up a task to end testing if peer start fails */
412 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 434 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
413 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 435 &end_badly,
436 "didn't start all daemons in reasonable amount of time!!!");
414 437
415 pg = GNUNET_TESTING_daemons_start (cfg, 438 pg = GNUNET_TESTING_daemons_start (cfg,
416 num_peers, 439 num_peers,
@@ -419,8 +442,7 @@ run (void *cls,
419 TIMEOUT, 442 TIMEOUT,
420 NULL, NULL, 443 NULL, NULL,
421 &peers_started_callback, 444 &peers_started_callback,
422 NULL, 445 NULL, &topology_callback, NULL, NULL);
423 &topology_callback, NULL, NULL);
424 446
425} 447}
426 448
@@ -428,7 +450,8 @@ static int
428check () 450check ()
429{ 451{
430 int ret; 452 int ret;
431 char *const argv[] = {"test-dht-twopeer", 453
454 char *const argv[] = { "test-dht-twopeer",
432 "-c", 455 "-c",
433 "test_dht_twopeer_data.conf", 456 "test_dht_twopeer_data.conf",
434#if VERBOSE 457#if VERBOSE
@@ -440,12 +463,13 @@ check ()
440 GNUNET_GETOPT_OPTION_END 463 GNUNET_GETOPT_OPTION_END
441 }; 464 };
442 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 465 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
443 argv, "test-dht-twopeer", "nohelp", 466 argv, "test-dht-twopeer", "nohelp",
444 options, &run, &ok); 467 options, &run, &ok);
445 if (ret != GNUNET_OK) 468 if (ret != GNUNET_OK)
446 { 469 {
447 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`test-dht-twopeer': Failed with error code %d\n", ret); 470 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
448 } 471 "`test-dht-twopeer': Failed with error code %d\n", ret);
472 }
449 return ok; 473 return ok;
450} 474}
451 475
@@ -467,9 +491,10 @@ main (int argc, char *argv[])
467 * of by the testing framework. 491 * of by the testing framework.
468 */ 492 */
469 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) 493 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
470 { 494 {
471 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to remove testing directory %s\n", test_directory); 495 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
472 } 496 "Failed to remove testing directory %s\n", test_directory);
497 }
473 return ret; 498 return ret;
474} 499}
475 500