aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-03-04 09:07:22 +0000
committerChristian Grothoff <christian@grothoff.org>2010-03-04 09:07:22 +0000
commitab53175c8b0ce3547d1d9b0ee9e12ca0f46cd250 (patch)
treedf74fc69e03d8c73d91285fa3e35374bb1c10a94 /src/testing/testing_group.c
parent5c73adc53f10ed8af7dcc42f13440829d71212a3 (diff)
downloadgnunet-ab53175c8b0ce3547d1d9b0ee9e12ca0f46cd250.tar.gz
gnunet-ab53175c8b0ce3547d1d9b0ee9e12ca0f46cd250.zip
code clean up
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c118
1 files changed, 81 insertions, 37 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 8a41c1a7f..4d94aa866 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -311,18 +311,34 @@ create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg)
311 unsigned int useAnd; 311 unsigned int useAnd;
312 int connect_attempts; 312 int connect_attempts;
313 313
314 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "LOGNMODIFIER", &p_string); 314 logNModifier = 0.5; /* FIXME: default value? */
315 if ((p_string == NULL) || (sscanf(p_string, "%lf", &logNModifier) != 1)) 315 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
316 logNModifier = 0.5; /* FIXME: default modifier? */ 316 "TESTING",
317 317 "LOGNMODIFIER",
318 GNUNET_free_non_null(p_string); 318 &p_string))
319 319 {
320 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PERCENTAGE", &p_string); 320 if (sscanf(p_string, "%lf", &logNModifier) != 1)
321 if ((p_string == NULL) || (sscanf(p_string, "%lf", &percentage) != 1)) 321 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
322 percentage = 0.5; /* FIXME: default percentage? */ 322 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
323 323 p_string,
324 GNUNET_free_non_null(p_string); 324 "LOGNMODIFIER",
325 325 "TESTING");
326 GNUNET_free (p_string);
327 }
328 percentage = 0.5; /* FIXME: default percentage? */
329 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
330 "TESTING",
331 "PERCENTAGE",
332 &p_string))
333 {
334 if (sscanf(p_string, "%lf", &percentage) != 1)
335 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
336 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
337 p_string,
338 "PERCENTAGE",
339 "TESTING");
340 GNUNET_free (p_string);
341 }
326 natLog = log (pg->total); 342 natLog = log (pg->total);
327 connsPerPeer = ceil (natLog * logNModifier); 343 connsPerPeer = ceil (natLog * logNModifier);
328 344
@@ -400,11 +416,22 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg)
400 double nat_percentage; 416 double nat_percentage;
401 char *p_string; 417 char *p_string;
402 418
403 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "NATPERCENTAGE", &p_string); 419 nat_percentage = 0.6; /* FIXME: default percentage? */
404 if ((p_string == NULL) || (sscanf(p_string, "%lf", &nat_percentage) != 1)) 420 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
405 nat_percentage = 0.6; /* FIXME: default modifier? */ 421 "TESTING",
422 "NATPERCENTAGE",
423 &p_string))
424 {
425 if (sscanf(p_string, "%lf", &nat_percentage) != 1)
426 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
427 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
428 p_string,
429 "NATPERCENTAGE",
430 "TESTING");
431 GNUNET_free (p_string);
432 }
433
406 434
407 GNUNET_free_non_null(p_string);
408 435
409 cutoff = (unsigned int) (nat_percentage * pg->total); 436 cutoff = (unsigned int) (nat_percentage * pg->total);
410 437
@@ -455,19 +482,35 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg)
455 square = floor (sqrt (pg->total)); 482 square = floor (sqrt (pg->total));
456 rows = square; 483 rows = square;
457 cols = square; 484 cols = square;
458 485
459 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PERCENTAGE", &p_string); 486 percentage = 0.5; /* FIXME: default percentage? */
460 if ((p_string == NULL) || (sscanf(p_string, "%lf", &percentage) != 1)) 487 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
461 percentage = 0.5; /* FIXME: default percentage? */ 488 "TESTING",
462 489 "PERCENTAGE",
463 GNUNET_free_non_null(p_string); 490 &p_string))
464 491 {
465 GNUNET_CONFIGURATION_get_value_string(pg->cfg, "TESTING", "PROBABILITY", &p_string); 492 if (sscanf(p_string, "%lf", &percentage) != 1)
466 if ((p_string == NULL) || (sscanf(p_string, "%lf", &probability) != 1)) 493 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
467 probability = 0.5; /* FIXME: default probability? */ 494 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
468 495 p_string,
469 GNUNET_free_non_null(p_string); 496 "PERCENTAGE",
470 497 "TESTING");
498 GNUNET_free (p_string);
499 }
500 probability = 0.5; /* FIXME: default percentage? */
501 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
502 "TESTING",
503 "PROBABILITY",
504 &p_string))
505 {
506 if (sscanf(p_string, "%lf", &probability) != 1)
507 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
508 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
509 p_string,
510 "PROBABILITY",
511 "TESTING");
512 GNUNET_free (p_string);
513 }
471 if (square * square != pg->total) 514 if (square * square != pg->total)
472 { 515 {
473 while (rows * cols < pg->total) 516 while (rows * cols < pg->total)
@@ -770,13 +813,14 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
770 813
771 fclose(temp_friend_handle); 814 fclose(temp_friend_handle);
772 815
773 GNUNET_CONFIGURATION_get_value_string(pg->peers[pg_iter].daemon->cfg, "PATHS", "SERVICEHOME", &temp_service_path); 816 if (GNUNET_OK !=
774 817 GNUNET_CONFIGURATION_get_value_string(pg->peers[pg_iter].daemon->cfg, "PATHS", "SERVICEHOME", &temp_service_path))
775 if (temp_service_path == NULL) 818 {
776 {
777 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 819 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
778 _("No SERVICEHOME specified in peer configuration, can't copy friends file!\n")); 820 _("No `%s' specified in peer configuration in section `%s', cannot copy friends file!\n"),
779 if (unlink(mytemp) != 0) 821 "SERVICEHOME",
822 "PATHS");
823 if (UNLINK (mytemp) != 0)
780 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", mytemp); 824 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", mytemp);
781 GNUNET_free (mytemp); 825 GNUNET_free (mytemp);
782 break; 826 break;
@@ -917,7 +961,7 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg)
917 int num_connections; 961 int num_connections;
918 962
919 GNUNET_assert (pg->notify_connection != NULL); 963 GNUNET_assert (pg->notify_connection != NULL);
920 ret = 0; 964 ret = GNUNET_OK;
921 if (GNUNET_YES == 965 if (GNUNET_YES ==
922 GNUNET_CONFIGURATION_get_value_number (pg->cfg, "testing", "topology", 966 GNUNET_CONFIGURATION_get_value_number (pg->cfg, "testing", "topology",
923 &topology_num)) 967 &topology_num))
@@ -977,7 +1021,7 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg)
977 num_connections = 0; 1021 num_connections = 0;
978 break; 1022 break;
979 default: 1023 default:
980 ret = GNUNET_SYSERR; 1024 num_connections = 0;
981 break; 1025 break;
982 } 1026 }
983 if (num_connections < 1) 1027 if (num_connections < 1)