aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-18 15:55:12 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-18 15:55:12 +0000
commit6d91f133149ea81040340e8853d7d6e94e57947c (patch)
tree909f05982b8be5c7cf6de927aabc3a9bb6312d60 /src/testing
parent475452849162e7c123141d9710b2cf3480e8f868 (diff)
downloadgnunet-6d91f133149ea81040340e8853d7d6e94e57947c.tar.gz
gnunet-6d91f133149ea81040340e8853d7d6e94e57947c.zip
cleanup
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing_group.c244
1 files changed, 120 insertions, 124 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 98610a28b..a54d7f2b6 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -67,99 +67,10 @@
67 * Prototype of a function called whenever two peers would be connected 67 * Prototype of a function called whenever two peers would be connected
68 * in a certain topology. 68 * in a certain topology.
69 */ 69 */
70typedef int (*GNUNET_TESTING_ConnectionProcessor) 70typedef int (*GNUNET_TESTING_ConnectionProcessor)(struct GNUNET_TESTING_PeerGroup *pg,
71(struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, unsigned int second); 71 unsigned int first,
72 unsigned int second);
72 73
73/**
74 * Strings representing topologies in enum
75 */
76static char * GNUNET_TESTING_TopologyStrings[] =
77{
78 /**
79 * A clique (everyone connected to everyone else).
80 */
81 "CLIQUE",
82
83 /**
84 * Small-world network (2d torus plus random links).
85 */
86 "SMALL_WORLD",
87
88 /**
89 * Small-world network (ring plus random links).
90 */
91 "SMALL_WORLD_RING",
92
93 /**
94 * Ring topology.
95 */
96 "RING",
97
98 /**
99 * 2-d torus.
100 */
101 "2D_TORUS",
102
103 /**
104 * Random graph.
105 */
106 "ERDOS_RENYI",
107
108 /**
109 * Certain percentage of peers are unable to communicate directly
110 * replicating NAT conditions
111 */
112 "INTERNAT",
113
114 /**
115 * Scale free topology.
116 */
117 "SCALE_FREE",
118
119 /**
120 * Straight line topology.
121 */
122 "LINE",
123
124 /**
125 * All peers are disconnected.
126 */
127 "NONE"
128};
129
130/**
131 * Options for connecting a topology as strings.
132 */
133static char * GNUNET_TESTING_TopologyOptionStrings[] =
134{
135 /**
136 * Try to connect all peers specified in the topology.
137 */
138 "CONNECT_ALL",
139
140 /**
141 * Choose a random subset of connections to create.
142 */
143 "CONNECT_RANDOM_SUBSET",
144
145 /**
146 * Create at least X connections for each peer.
147 */
148 "CONNECT_MINIMUM",
149
150 /**
151 * Using a depth first search, create one connection
152 * per peer. If any are missed (graph disconnected)
153 * start over at those peers until all have at least one
154 * connection.
155 */
156 "CONNECT_DFS",
157
158 /**
159 * No options specified.
160 */
161 "CONNECT_NONE"
162};
163 74
164/** 75/**
165 * Context for handling churning a peer group 76 * Context for handling churning a peer group
@@ -448,60 +359,145 @@ static int outstanding_connects;
448int 359int
449GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topology_string) 360GNUNET_TESTING_topology_get(enum GNUNET_TESTING_Topology *topology, char * topology_string)
450{ 361{
451 int found = 0; 362 /**
452 int curr = 0; 363 * Strings representing topologies in enum
364 */
365 static const char * topology_strings[] =
366 {
367 /**
368 * A clique (everyone connected to everyone else).
369 */
370 "CLIQUE",
371
372 /**
373 * Small-world network (2d torus plus random links).
374 */
375 "SMALL_WORLD",
376
377 /**
378 * Small-world network (ring plus random links).
379 */
380 "SMALL_WORLD_RING",
381
382 /**
383 * Ring topology.
384 */
385 "RING",
386
387 /**
388 * 2-d torus.
389 */
390 "2D_TORUS",
391
392 /**
393 * Random graph.
394 */
395 "ERDOS_RENYI",
396
397 /**
398 * Certain percentage of peers are unable to communicate directly
399 * replicating NAT conditions
400 */
401 "INTERNAT",
402
403 /**
404 * Scale free topology.
405 */
406 "SCALE_FREE",
407
408 /**
409 * Straight line topology.
410 */
411 "LINE",
412
413 /**
414 * All peers are disconnected.
415 */
416 "NONE",
417
418 NULL
419 };
453 420
421 int curr = 0;
454 if (topology_string == NULL) 422 if (topology_string == NULL)
455 return GNUNET_NO; 423 return GNUNET_NO;
456 424 while (topology_strings[curr] != NULL)
457 do
458 {
459 if (strcmp(GNUNET_TESTING_TopologyStrings[curr], topology_string) == 0)
460 { 425 {
461 found = GNUNET_YES; 426 if (strcmp(topology_strings[curr], topology_string) == 0)
462 break; 427 {
428 *topology = curr;
429 return GNUNET_YES;
430 }
431 curr++;
463 } 432 }
464 curr++; 433 *topology = GNUNET_TESTING_TOPOLOGY_NONE;
465 } while (strcmp(GNUNET_TESTING_TopologyStrings[curr], "NONE") != 0); 434 return GNUNET_NO;
466 *topology = curr;
467 if (found)
468 return GNUNET_YES;
469 else
470 return GNUNET_NO;
471} 435}
472 436
437
473/** 438/**
474 * Get connect topology option from string input. 439 * Get connect topology option from string input.
475 * 440 *
476 * @param topology where to write the retrieved topology 441 * @param topology_option where to write the retrieved topology
477 * @param topology_string The string to attempt to 442 * @param topology_string The string to attempt to
478 * get a configuration value from 443 * get a configuration value from
479 * @return GNUNET_YES if string matched a known 444 * @return GNUNET_YES if string matched a known
480 * topology option, GNUNET_NO if not 445 * topology option, GNUNET_NO if not
481 */ 446 */
482int 447int
483GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology, char * topology_string) 448GNUNET_TESTING_topology_option_get(enum GNUNET_TESTING_TopologyOption *topology_option,
449 char * topology_string)
484{ 450{
485 int found = 0; 451 /**
452 * Options for connecting a topology as strings.
453 */
454 static const char * topology_option_strings[] =
455 {
456 /**
457 * Try to connect all peers specified in the topology.
458 */
459 "CONNECT_ALL",
460
461 /**
462 * Choose a random subset of connections to create.
463 */
464 "CONNECT_RANDOM_SUBSET",
465
466 /**
467 * Create at least X connections for each peer.
468 */
469 "CONNECT_MINIMUM",
470
471 /**
472 * Using a depth first search, create one connection
473 * per peer. If any are missed (graph disconnected)
474 * start over at those peers until all have at least one
475 * connection.
476 */
477 "CONNECT_DFS",
478
479 /**
480 * No options specified.
481 */
482 "CONNECT_NONE",
483
484 NULL
485 };
486 int curr = 0; 486 int curr = 0;
487 487
488 if (topology_string == NULL) 488 if (topology_string == NULL)
489 return GNUNET_NO; 489 return GNUNET_NO;
490 490 while (NULL != topology_option_strings[curr])
491 do
492 {
493 if (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], topology_string) == 0)
494 { 491 {
495 found = GNUNET_YES; 492 if (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], topology_string) == 0)
496 break; 493 {
497 } 494 *topology_option = curr;
498 curr++; 495 return GNUNET_YES;
499 } while (strcmp(GNUNET_TESTING_TopologyOptionStrings[curr], "CONNECT_NONE") != 0); 496 }
500 *topology = curr; 497 curr++;
501 if (found) 498 }
502 return GNUNET_YES; 499 *topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_NONE;
503 else 500 return GNUNET_NO;
504 return GNUNET_NO;
505} 501}
506 502
507/** 503/**