aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_small.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/test_mesh_small.c')
-rw-r--r--src/mesh/test_mesh_small.c497
1 files changed, 235 insertions, 262 deletions
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c
index c60e2c57e..d0d394177 100644
--- a/src/mesh/test_mesh_small.c
+++ b/src/mesh/test_mesh_small.c
@@ -138,38 +138,36 @@ static void
138shutdown_callback (void *cls, const char *emsg) 138shutdown_callback (void *cls, const char *emsg)
139{ 139{
140 if (emsg != NULL) 140 if (emsg != NULL)
141 { 141 {
142#if VERBOSE 142#if VERBOSE
143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); 143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n");
144#endif 144#endif
145 if (ok == 0) 145 if (ok == 0)
146 ok = 666; 146 ok = 666;
147 } 147 }
148 else 148 else
149 { 149 {
150#if VERBOSE 150#if VERBOSE
151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n");
152 "All peers successfully shut down!\n");
153#endif 152#endif
154 ok = 0; 153 ok = 0;
155 } 154 }
156} 155}
157 156
158 157
159static void 158static void
160shutdown_task (void *cls, 159shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
161 const struct GNUNET_SCHEDULER_TaskContext *tc)
162{ 160{
163// struct NSEPeer *pos; 161// struct NSEPeer *pos;
164#if VERBOSE 162#if VERBOSE
165 fprintf(stderr, "Ending test.\n"); 163 fprintf (stderr, "Ending test.\n");
166#endif 164#endif
167 165
168 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) 166 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
169 { 167 {
170 GNUNET_SCHEDULER_cancel(disconnect_task); 168 GNUNET_SCHEDULER_cancel (disconnect_task);
171 disconnect_task = GNUNET_SCHEDULER_NO_TASK; 169 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
172 } 170 }
173// while (NULL != (pos = peer_head)) 171// while (NULL != (pos = peer_head))
174// { 172// {
175// if (pos->nse_handle != NULL) 173// if (pos->nse_handle != NULL)
@@ -179,28 +177,27 @@ shutdown_task (void *cls,
179// } 177// }
180 178
181 if (data_file != NULL) 179 if (data_file != NULL)
182 GNUNET_DISK_file_close(data_file); 180 GNUNET_DISK_file_close (data_file);
183 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 181 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
184} 182}
185 183
186 184
187static void 185static void
188connect_mesh_service (void *cls, 186connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
189 const struct GNUNET_SCHEDULER_TaskContext *tc)
190{ 187{
191// struct NSEPeer *current_peer; 188// struct NSEPeer *current_peer;
192 unsigned int i; 189 unsigned int i;
193 190
194#if VERBOSE 191#if VERBOSE
195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to mesh service of peers\n");
196 "Connecting to mesh service of peers\n");
197#endif 193#endif
198 for (i = 0; i < num_peers; i++) 194 for (i = 0; i < num_peers; i++)
199 { 195 {
200// if ((connection_limit > 0) && (i % (num_peers / connection_limit) != 0)) 196// if ((connection_limit > 0) && (i % (num_peers / connection_limit) != 0))
201 continue; 197 continue;
202#if VERBOSE 198#if VERBOSE
203 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test_mesh_small: connecting to mesh service of peer %d\n", i); 199 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
200 "test_mesh_small: connecting to mesh service of peer %d\n", i);
204#endif 201#endif
205/* current_peer = GNUNET_malloc(sizeof(struct NSEPeer)); 202/* current_peer = GNUNET_malloc(sizeof(struct NSEPeer));
206 current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i); 203 current_peer->daemon = GNUNET_TESTING_daemon_get(pg, i);
@@ -212,13 +209,12 @@ connect_mesh_service (void *cls,
212 GNUNET_assert(current_peer->nse_handle != NULL); 209 GNUNET_assert(current_peer->nse_handle != NULL);
213 } 210 }
214 GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);*/ 211 GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer);*/
215 } 212 }
216} 213}
217 214
218 215
219static void 216static void
220churn_peers (void *cls, 217churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
221 const struct GNUNET_SCHEDULER_TaskContext *tc);
222 218
223 219
224/** 220/**
@@ -228,31 +224,30 @@ churn_peers (void *cls,
228 * @param success GNUNET_OK if statistics were 224 * @param success GNUNET_OK if statistics were
229 * successfully obtained, GNUNET_SYSERR if not. 225 * successfully obtained, GNUNET_SYSERR if not.
230 */ 226 */
231static void 227static void
232stats_finished_callback (void *cls, int success) 228stats_finished_callback (void *cls, int success)
233{ 229{
234 struct StatsContext *stats_context = cls; 230 struct StatsContext *stats_context = cls;
235 char *buf; 231 char *buf;
236 int buf_len; 232 int buf_len;
237 233
238 if ( (GNUNET_OK == success) && 234 if ((GNUNET_OK == success) && (data_file != NULL))
239 (data_file != NULL) ) 235 {
236 /* Stats lookup successful, write out data */
237 buf = NULL;
238 buf_len = GNUNET_asprintf (&buf,
239 "TOTAL_MESH_BYTES: %u\n",
240 stats_context->total_mesh_bytes);
241 if (buf_len > 0)
240 { 242 {
241 /* Stats lookup successful, write out data */ 243 GNUNET_DISK_file_write (data_file, buf, buf_len);
242 buf = NULL;
243 buf_len = GNUNET_asprintf(&buf,
244 "TOTAL_MESH_BYTES: %u\n",
245 stats_context->total_mesh_bytes);
246 if (buf_len > 0)
247 {
248 GNUNET_DISK_file_write(data_file, buf, buf_len);
249 }
250 GNUNET_free_non_null(buf);
251 } 244 }
245 GNUNET_free_non_null (buf);
246 }
252 247
253 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == shutdown_handle); 248 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == shutdown_handle);
254 shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); 249 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
255 GNUNET_free(stats_context); 250 GNUNET_free (stats_context);
256} 251}
257 252
258 253
@@ -267,33 +262,30 @@ stats_finished_callback (void *cls, int success)
267 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not 262 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
268 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 263 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
269 */ 264 */
270static int 265static int
271statistics_iterator (void *cls, 266statistics_iterator (void *cls,
272 const struct GNUNET_PeerIdentity *peer, 267 const struct GNUNET_PeerIdentity *peer,
273 const char *subsystem, 268 const char *subsystem,
274 const char *name, 269 const char *name, uint64_t value, int is_persistent)
275 uint64_t value,
276 int is_persistent)
277{ 270{
278 struct StatsContext *stats_context = cls; 271 struct StatsContext *stats_context = cls;
272
279// 273//
280// if ( (0 == strstr(subsystem, "nse")) && 274// if ( (0 == strstr(subsystem, "nse")) &&
281// (0 == strstr(name, "# flood messages received")) ) 275// (0 == strstr(name, "# flood messages received")) )
282 stats_context->total_mesh_bytes += 1; //value; 276 stats_context->total_mesh_bytes += 1; //value;
283 return GNUNET_OK; 277 return GNUNET_OK;
284} 278}
285 279
286 280
287static void 281static void
288disconnect_mesh_peers (void *cls, 282disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
289 const struct GNUNET_SCHEDULER_TaskContext *tc)
290{ 283{
291// struct NSEPeer *pos; 284// struct NSEPeer *pos;
292 char *buf; 285 char *buf;
293 struct StatsContext *stats_context; 286 struct StatsContext *stats_context;
294 287
295 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnecting mesh service of peers\n");
296 "disconnecting mesh service of peers\n");
297 disconnect_task = GNUNET_SCHEDULER_NO_TASK; 289 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
298// pos = peer_head; 290// pos = peer_head;
299// while (NULL != (pos = peer_head)) 291// while (NULL != (pos = peer_head))
@@ -307,29 +299,26 @@ disconnect_mesh_peers (void *cls,
307// GNUNET_free(pos); 299// GNUNET_free(pos);
308// } 300// }
309 301
310 GNUNET_asprintf(&buf, 302 GNUNET_asprintf (&buf, "round%llu", current_round);
311 "round%llu", 303 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg,
312 current_round); 304 "test_mesh_small",
313 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, 305 buf,
314 "test_mesh_small", 306 &peers_next_round))
315 buf, 307 {
316 &peers_next_round)) 308 current_round++;
317 { 309 GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK);
318 current_round++; 310 churn_task = GNUNET_SCHEDULER_add_now (&churn_peers, NULL);
319 GNUNET_assert(churn_task == GNUNET_SCHEDULER_NO_TASK); 311 }
320 churn_task = GNUNET_SCHEDULER_add_now(&churn_peers, NULL); 312 else /* No more rounds, let's shut it down! */
321 } 313 {
322 else /* No more rounds, let's shut it down! */ 314 stats_context = GNUNET_malloc (sizeof (struct StatsContext));
323 { 315 GNUNET_SCHEDULER_cancel (shutdown_handle);
324 stats_context = GNUNET_malloc(sizeof(struct StatsContext)); 316 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
325 GNUNET_SCHEDULER_cancel(shutdown_handle); 317 GNUNET_TESTING_get_statistics (pg,
326 shutdown_handle = GNUNET_SCHEDULER_NO_TASK; 318 &stats_finished_callback,
327 GNUNET_TESTING_get_statistics(pg, 319 &statistics_iterator, stats_context);
328 &stats_finished_callback, 320 }
329 &statistics_iterator, 321 GNUNET_free (buf);
330 stats_context);
331 }
332 GNUNET_free(buf);
333} 322}
334 323
335 324
@@ -339,12 +328,12 @@ disconnect_mesh_peers (void *cls,
339 * @param cls unused 328 * @param cls unused
340 * @param emsg NULL on success 329 * @param emsg NULL on success
341 */ 330 */
342static void 331static void
343topology_output_callback (void *cls, const char *emsg) 332topology_output_callback (void *cls, const char *emsg)
344{ 333{
345 disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, 334 disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time,
346 &disconnect_mesh_peers, NULL); 335 &disconnect_mesh_peers, NULL);
347 GNUNET_SCHEDULER_add_now(&connect_mesh_service, NULL); 336 GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL);
348} 337}
349 338
350 339
@@ -359,121 +348,108 @@ churn_callback (void *cls, const char *emsg)
359{ 348{
360 char *temp_output_file; 349 char *temp_output_file;
361 350
362 if (emsg == NULL) /* Everything is okay! */ 351 if (emsg == NULL) /* Everything is okay! */
363 { 352 {
364 peers_running = peers_next_round; 353 peers_running = peers_next_round;
365 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 354 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
366 "Round %llu, churn finished successfully.\n", 355 "Round %llu, churn finished successfully.\n", current_round);
367 current_round); 356 GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK);
368 GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); 357 GNUNET_asprintf (&temp_output_file,
369 GNUNET_asprintf(&temp_output_file, 358 "%s_%llu.dot", topology_file, current_round);
370 "%s_%llu.dot", 359 GNUNET_TESTING_peergroup_topology_to_file (pg,
371 topology_file, 360 temp_output_file,
372 current_round); 361 &topology_output_callback, NULL);
373 GNUNET_TESTING_peergroup_topology_to_file(pg, 362 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
374 temp_output_file, 363 "Writing topology to file %s\n", temp_output_file);
375 &topology_output_callback, 364 GNUNET_free (temp_output_file);
376 NULL); 365 }
377 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
378 "Writing topology to file %s\n",
379 temp_output_file);
380 GNUNET_free(temp_output_file);
381 }
382 else 366 else
383 { 367 {
384 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 368 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
385 "Round %llu, churn FAILED!!\n", 369 "Round %llu, churn FAILED!!\n", current_round);
386 current_round); 370 GNUNET_SCHEDULER_cancel (shutdown_handle);
387 GNUNET_SCHEDULER_cancel(shutdown_handle); 371 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
388 shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL); 372 }
389 }
390} 373}
391 374
392 375
393static void 376static void
394churn_peers (void *cls, 377churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
395 const struct GNUNET_SCHEDULER_TaskContext *tc)
396{ 378{
397 /* peers_running = GNUNET_TESTING_daemons_running(pg); */ 379 /* peers_running = GNUNET_TESTING_daemons_running(pg); */
398 churn_task = GNUNET_SCHEDULER_NO_TASK; 380 churn_task = GNUNET_SCHEDULER_NO_TASK;
399 if (peers_next_round == peers_running) 381 if (peers_next_round == peers_running)
400 { 382 {
401 /* Nothing to do... */ 383 /* Nothing to do... */
402 GNUNET_SCHEDULER_add_now(&connect_mesh_service, NULL); 384 GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL);
403 GNUNET_assert(disconnect_task == GNUNET_SCHEDULER_NO_TASK); 385 GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK);
404 disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, 386 disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time,
405 &disconnect_mesh_peers, NULL); 387 &disconnect_mesh_peers,
406 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 388 NULL);
407 "Round %lu, doing nothing!\n", 389 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n",
408 current_round); 390 current_round);
409 } 391 }
410 else 392 else
393 {
394 if (peers_next_round > num_peers)
411 { 395 {
412 if (peers_next_round > num_peers) 396 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
413 { 397 "Asked to turn on more peers than we have!!\n");
414 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 398 GNUNET_SCHEDULER_cancel (shutdown_handle);
415 "Asked to turn on more peers than we have!!\n"); 399 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
416 GNUNET_SCHEDULER_cancel(shutdown_handle);
417 GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
418 }
419 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
420 "Round %llu, turning off %llu peers, turning on %llu peers!\n",
421 current_round,
422 (peers_running > peers_next_round)
423 ? peers_running - peers_next_round
424 : 0,
425 (peers_next_round > peers_running)
426 ? peers_next_round - peers_running
427 : 0);
428 GNUNET_TESTING_daemons_churn (pg, "nse",
429 (peers_running > peers_next_round)
430 ? peers_running - peers_next_round
431 : 0,
432 (peers_next_round > peers_running)
433 ? peers_next_round - peers_running
434 : 0,
435 wait_time,
436 &churn_callback, NULL);
437 } 400 }
401 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
402 "Round %llu, turning off %llu peers, turning on %llu peers!\n",
403 current_round,
404 (peers_running > peers_next_round)
405 ? peers_running - peers_next_round
406 : 0,
407 (peers_next_round > peers_running)
408 ? peers_next_round - peers_running : 0);
409 GNUNET_TESTING_daemons_churn (pg, "nse",
410 (peers_running > peers_next_round)
411 ? peers_running - peers_next_round
412 : 0,
413 (peers_next_round > peers_running)
414 ? peers_next_round - peers_running
415 : 0, wait_time, &churn_callback, NULL);
416 }
438} 417}
439 418
440 419
441static void 420static void
442my_cb (void *cls, 421my_cb (void *cls, const char *emsg)
443 const char *emsg)
444{ 422{
445 char *buf; 423 char *buf;
446 int buf_len; 424 int buf_len;
425
447 if (emsg != NULL) 426 if (emsg != NULL)
448 { 427 {
449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
450 "Peergroup callback called with error, aborting test!\n"); 429 "Peergroup callback called with error, aborting test!\n");
451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error from testing: `%s'\n"); 430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error from testing: `%s'\n");
452 ok = 1; 431 ok = 1;
453 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 432 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
454 return; 433 return;
455 } 434 }
456#if VERBOSE 435#if VERBOSE
457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully!\n");
458 "Peer Group started successfully!\n");
459#endif 437#endif
460 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 438 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
461 "Have %u connections\n", 439 "Have %u connections\n", total_connections);
462 total_connections);
463 if (data_file != NULL) 440 if (data_file != NULL)
464 { 441 {
465 buf = NULL; 442 buf = NULL;
466 buf_len = GNUNET_asprintf(&buf, 443 buf_len = GNUNET_asprintf (&buf, "CONNECTIONS_0: %u\n", total_connections);
467 "CONNECTIONS_0: %u\n", 444 if (buf_len > 0)
468 total_connections); 445 GNUNET_DISK_file_write (data_file, buf, buf_len);
469 if (buf_len > 0) 446 GNUNET_free (buf);
470 GNUNET_DISK_file_write(data_file, buf, buf_len); 447 }
471 GNUNET_free (buf); 448 peers_running = GNUNET_TESTING_daemons_running (pg);
472 } 449
473 peers_running = GNUNET_TESTING_daemons_running(pg); 450 GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL);
474 451 disconnect_task =
475 GNUNET_SCHEDULER_add_now(&connect_mesh_service, NULL); 452 GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL);
476 disconnect_task = GNUNET_SCHEDULER_add_delayed(wait_time, &disconnect_mesh_peers, NULL);
477 453
478} 454}
479 455
@@ -492,16 +468,15 @@ my_cb (void *cls,
492 * @param second_daemon handle for the second daemon 468 * @param second_daemon handle for the second daemon
493 * @param emsg error message (NULL on success) 469 * @param emsg error message (NULL on success)
494 */ 470 */
495static void 471static void
496connect_cb (void *cls, 472connect_cb (void *cls,
497 const struct GNUNET_PeerIdentity *first, 473 const struct GNUNET_PeerIdentity *first,
498 const struct GNUNET_PeerIdentity *second, 474 const struct GNUNET_PeerIdentity *second,
499 uint32_t distance, 475 uint32_t distance,
500 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 476 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
501 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 477 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
502 struct GNUNET_TESTING_Daemon *first_daemon, 478 struct GNUNET_TESTING_Daemon *first_daemon,
503 struct GNUNET_TESTING_Daemon *second_daemon, 479 struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
504 const char *emsg)
505{ 480{
506 if (emsg == NULL) 481 if (emsg == NULL)
507 total_connections++; 482 total_connections++;
@@ -513,96 +488,95 @@ run (void *cls,
513 char *const *args, 488 char *const *args,
514 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 489 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
515{ 490{
516 char *temp_str; 491 char *temp_str;
517 unsigned long long temp_wait; 492 unsigned long long temp_wait;
518 struct GNUNET_TESTING_Host *hosts; 493 struct GNUNET_TESTING_Host *hosts;
519 494
520 ok = 1; 495 ok = 1;
521 testing_cfg = (struct GNUNET_CONFIGURATION_Handle *)cfg; // GNUNET_CONFIGURATION_create(); 496 testing_cfg = (struct GNUNET_CONFIGURATION_Handle *) cfg; // GNUNET_CONFIGURATION_create();
522#if VERBOSE 497#if VERBOSE
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); 498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n");
524 GNUNET_CONFIGURATION_set_value_string (testing_cfg, 499 GNUNET_CONFIGURATION_set_value_string (testing_cfg,
525 "testing", 500 "testing", "use_progressbars", "YES");
526 "use_progressbars",
527 "YES");
528#endif 501#endif
529 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, 502 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg,
530 "testing", 503 "testing",
531 "num_peers", &num_peers)) 504 "num_peers",
532 { 505 &num_peers))
533 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Option TESTING:NUM_PEERS is required!\n"); 506 {
534 return; 507 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
535 } 508 "Option TESTING:NUM_PEERS is required!\n");
536 509 return;
537 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, 510 }
538 "test_mesh_small", 511
539 "wait_time", 512 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg,
540 &temp_wait)) 513 "test_mesh_small",
541 { 514 "wait_time",
542 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 515 &temp_wait))
543 "Option nsetest_mesh_small:wait_time is required!\n"); 516 {
544 return; 517 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
545 } 518 "Option nsetest_mesh_small:wait_time is required!\n");
546 519 return;
547 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, 520 }
548 "testing", "topology_output_file", 521
549 &topology_file)) 522 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg,
550 { 523 "testing",
551 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 524 "topology_output_file",
552 "Option test_mesh_small:topology_output_file is required!\n"); 525 &topology_file))
553 return; 526 {
554 } 527 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
555 528 "Option test_mesh_small:topology_output_file is required!\n");
556 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, 529 return;
557 "test_mesh_small", "data_output_file", 530 }
558 &data_filename)) 531
559 { 532 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg,
560 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 533 "test_mesh_small",
561 "Option test_mesh_small:data_output_file is required!\n"); 534 "data_output_file",
562 return; 535 &data_filename))
563 } 536 {
537 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
538 "Option test_mesh_small:data_output_file is required!\n");
539 return;
540 }
564 541
565 data_file = GNUNET_DISK_file_open (data_filename, 542 data_file = GNUNET_DISK_file_open (data_filename,
566 GNUNET_DISK_OPEN_READWRITE 543 GNUNET_DISK_OPEN_READWRITE
567 | GNUNET_DISK_OPEN_CREATE, 544 | GNUNET_DISK_OPEN_CREATE,
568 GNUNET_DISK_PERM_USER_READ | 545 GNUNET_DISK_PERM_USER_READ |
569 GNUNET_DISK_PERM_USER_WRITE); 546 GNUNET_DISK_PERM_USER_WRITE);
570 if (data_file == NULL) 547 if (data_file == NULL)
571 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 548 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
572 "Failed to open %s for output!\n", 549 "Failed to open %s for output!\n", data_filename);
573 data_filename); 550 GNUNET_free (data_filename);
574 GNUNET_free(data_filename); 551
575 552 wait_time =
576 wait_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_wait); 553 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait);
577 554
578 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, 555 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg,
579 "test_mesh_small", 556 "test_mesh_small",
580 "output_file", 557 "output_file",
581 &temp_str)) 558 &temp_str))
582 { 559 {
583 output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE 560 output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE
584 | GNUNET_DISK_OPEN_CREATE, 561 | GNUNET_DISK_OPEN_CREATE,
585 GNUNET_DISK_PERM_USER_READ | 562 GNUNET_DISK_PERM_USER_READ |
586 GNUNET_DISK_PERM_USER_WRITE); 563 GNUNET_DISK_PERM_USER_WRITE);
587 if (output_file == NULL) 564 if (output_file == NULL)
588 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 565 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
589 "Failed to open %s for output!\n", 566 "Failed to open %s for output!\n", temp_str);
590 temp_str); 567 }
591 } 568 GNUNET_free_non_null (temp_str);
592 GNUNET_free_non_null(temp_str);
593 569
594 hosts = GNUNET_TESTING_hosts_load (testing_cfg); 570 hosts = GNUNET_TESTING_hosts_load (testing_cfg);
595 571
596 pg = GNUNET_TESTING_peergroup_start(testing_cfg, 572 pg = GNUNET_TESTING_peergroup_start (testing_cfg,
597 num_peers, 573 num_peers,
598 TIMEOUT, 574 TIMEOUT,
599 &connect_cb, 575 &connect_cb, &my_cb, NULL, hosts);
600 &my_cb, NULL,
601 hosts);
602 GNUNET_assert (pg != NULL); 576 GNUNET_assert (pg != NULL);
603 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever(), 577 shutdown_handle =
604 &shutdown_task, 578 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (),
605 NULL); 579 &shutdown_task, NULL);
606} 580}
607 581
608 582
@@ -629,10 +603,9 @@ main (int argc, char *argv[])
629#endif 603#endif
630 NULL); 604 NULL);
631 GNUNET_PROGRAM_run (argc, 605 GNUNET_PROGRAM_run (argc,
632 argv, "test_mesh_small", 606 argv, "test_mesh_small",
633 gettext_noop ("Test mesh in a small network."), 607 gettext_noop ("Test mesh in a small network."),
634 options, 608 options, &run, NULL);
635 &run, NULL);
636#if REMOVE_DIR 609#if REMOVE_DIR
637 GNUNET_DISK_directory_remove ("/tmp/test_mesh_small"); 610 GNUNET_DISK_directory_remove ("/tmp/test_mesh_small");
638#endif 611#endif