diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-21 10:25:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-21 10:25:12 +0000 |
commit | c78f6d6e8ab7af5d4c3912a057d6f67febab07f2 (patch) | |
tree | 334613b7280843a55b3fc8912b393159eb789ca7 /src/testing | |
parent | 6cf5f9bd46389b714bd32421ea64e670e2e2c5db (diff) | |
download | gnunet-c78f6d6e8ab7af5d4c3912a057d6f67febab07f2.tar.gz gnunet-c78f6d6e8ab7af5d4c3912a057d6f67febab07f2.zip |
nitpicks
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_group.c | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index d77738296..1de293617 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -1691,12 +1691,11 @@ copy_allowed_topology (struct GNUNET_TESTING_PeerGroup *pg) | |||
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | 1693 | ||
1694 | /* | 1694 | /** |
1695 | * Connect the topology as specified by the PeerConnection's | 1695 | * Connect the topology as specified by the PeerConnection's |
1696 | * of each peer in the peer group | 1696 | * of each peer in the peer group |
1697 | * | 1697 | * |
1698 | * @param pg the peer group we are dealing with | 1698 | * @param pg the peer group we are dealing with |
1699 | * | ||
1700 | * @return the number of connections that will be attempted | 1699 | * @return the number of connections that will be attempted |
1701 | */ | 1700 | */ |
1702 | static int | 1701 | static int |
@@ -1736,7 +1735,7 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg) | |||
1736 | } | 1735 | } |
1737 | 1736 | ||
1738 | 1737 | ||
1739 | /* | 1738 | /** |
1740 | * Takes a peer group and creates a topology based on the | 1739 | * Takes a peer group and creates a topology based on the |
1741 | * one specified. Creates a topology means generates friend | 1740 | * one specified. Creates a topology means generates friend |
1742 | * files for the peers so they can only connect to those allowed | 1741 | * files for the peers so they can only connect to those allowed |
@@ -1858,15 +1857,10 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, | |||
1858 | #endif | 1857 | #endif |
1859 | } | 1858 | } |
1860 | 1859 | ||
1861 | /** | 1860 | /* Use the create clique method to initially set all connections as blacklisted. */ |
1862 | * Use the create clique method to initially set all connections | ||
1863 | * as blacklisted. | ||
1864 | */ | ||
1865 | create_clique (pg, &blacklist_connections); | 1861 | create_clique (pg, &blacklist_connections); |
1866 | unblacklisted_connections = 0; | 1862 | unblacklisted_connections = 0; |
1867 | /** | 1863 | /* Un-blacklist connections as per the topology specified */ |
1868 | * Un-blacklist connections as per the topology specified | ||
1869 | */ | ||
1870 | switch (restrict_topology) | 1864 | switch (restrict_topology) |
1871 | { | 1865 | { |
1872 | case GNUNET_TESTING_TOPOLOGY_CLIQUE: | 1866 | case GNUNET_TESTING_TOPOLOGY_CLIQUE: |
@@ -1950,8 +1944,6 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, | |||
1950 | #endif | 1944 | #endif |
1951 | } | 1945 | } |
1952 | } | 1946 | } |
1953 | |||
1954 | |||
1955 | return num_connections; | 1947 | return num_connections; |
1956 | } | 1948 | } |
1957 | 1949 | ||
@@ -2331,12 +2323,7 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) | |||
2331 | 2323 | ||
2332 | } | 2324 | } |
2333 | 2325 | ||
2334 | /* | 2326 | /** |
2335 | * @param pg the peer group struct representing the running peers | ||
2336 | * @param topology which topology to connect the peers in | ||
2337 | * @param options options for connecting the topology | ||
2338 | * @param option_modifier modifier for options that take a parameter | ||
2339 | * | ||
2340 | * There are many ways to connect peers that are supported by this function. | 2327 | * There are many ways to connect peers that are supported by this function. |
2341 | * To connect peers in the same topology that was created via the | 2328 | * To connect peers in the same topology that was created via the |
2342 | * GNUNET_TESTING_create_topology, the topology variable must be set to | 2329 | * GNUNET_TESTING_create_topology, the topology variable must be set to |
@@ -2345,6 +2332,11 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) | |||
2345 | * connected. This could result in some connections being impossible, | 2332 | * connected. This could result in some connections being impossible, |
2346 | * because some topologies are non-deterministic. | 2333 | * because some topologies are non-deterministic. |
2347 | * | 2334 | * |
2335 | * @param pg the peer group struct representing the running peers | ||
2336 | * @param topology which topology to connect the peers in | ||
2337 | * @param options options for connecting the topology | ||
2338 | * @param option_modifier modifier for options that take a parameter | ||
2339 | * @return the number of connections that will be attempted, GNUNET_SYSERR on error | ||
2348 | */ | 2340 | */ |
2349 | int | 2341 | int |
2350 | GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, | 2342 | GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, |
@@ -2352,8 +2344,6 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, | |||
2352 | enum GNUNET_TESTING_TopologyOption options, | 2344 | enum GNUNET_TESTING_TopologyOption options, |
2353 | double option_modifier) | 2345 | double option_modifier) |
2354 | { | 2346 | { |
2355 | int num_connections; | ||
2356 | |||
2357 | switch (topology) | 2347 | switch (topology) |
2358 | { | 2348 | { |
2359 | case GNUNET_TESTING_TOPOLOGY_CLIQUE: | 2349 | case GNUNET_TESTING_TOPOLOGY_CLIQUE: |
@@ -2361,80 +2351,81 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, | |||
2361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2362 | _("Creating clique topology\n")); | 2352 | _("Creating clique topology\n")); |
2363 | #endif | 2353 | #endif |
2364 | num_connections = create_clique (pg, &add_actual_connections); | 2354 | create_clique (pg, &add_actual_connections); |
2365 | break; | 2355 | break; |
2366 | case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: | 2356 | case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: |
2367 | #if VERBOSE_TESTING | 2357 | #if VERBOSE_TESTING |
2368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2369 | _("Creating small world (ring) topology\n")); | 2359 | _("Creating small world (ring) topology\n")); |
2370 | #endif | 2360 | #endif |
2371 | num_connections = create_small_world_ring (pg, &add_actual_connections); | 2361 | create_small_world_ring (pg, &add_actual_connections); |
2372 | break; | 2362 | break; |
2373 | case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: | 2363 | case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: |
2374 | #if VERBOSE_TESTING | 2364 | #if VERBOSE_TESTING |
2375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2376 | _("Creating small world (2d-torus) topology\n")); | 2366 | _("Creating small world (2d-torus) topology\n")); |
2377 | #endif | 2367 | #endif |
2378 | num_connections = create_small_world (pg, &add_actual_connections); | 2368 | create_small_world (pg, &add_actual_connections); |
2379 | break; | 2369 | break; |
2380 | case GNUNET_TESTING_TOPOLOGY_RING: | 2370 | case GNUNET_TESTING_TOPOLOGY_RING: |
2381 | #if VERBOSE_TESTING | 2371 | #if VERBOSE_TESTING |
2382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2383 | _("Creating ring topology\n")); | 2373 | _("Creating ring topology\n")); |
2384 | #endif | 2374 | #endif |
2385 | num_connections = create_ring (pg, &add_actual_connections); | 2375 | create_ring (pg, &add_actual_connections); |
2386 | break; | 2376 | break; |
2387 | case GNUNET_TESTING_TOPOLOGY_2D_TORUS: | 2377 | case GNUNET_TESTING_TOPOLOGY_2D_TORUS: |
2388 | #if VERBOSE_TESTING | 2378 | #if VERBOSE_TESTING |
2389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2390 | _("Creating 2d torus topology\n")); | 2380 | _("Creating 2d torus topology\n")); |
2391 | #endif | 2381 | #endif |
2392 | num_connections = create_2d_torus (pg, &add_actual_connections); | 2382 | create_2d_torus (pg, &add_actual_connections); |
2393 | break; | 2383 | break; |
2394 | case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: | 2384 | case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: |
2395 | #if VERBOSE_TESTING | 2385 | #if VERBOSE_TESTING |
2396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2397 | _("Creating Erdos-Renyi topology\n")); | 2387 | _("Creating Erdos-Renyi topology\n")); |
2398 | #endif | 2388 | #endif |
2399 | num_connections = create_erdos_renyi (pg, &add_actual_connections); | 2389 | create_erdos_renyi (pg, &add_actual_connections); |
2400 | break; | 2390 | break; |
2401 | case GNUNET_TESTING_TOPOLOGY_INTERNAT: | 2391 | case GNUNET_TESTING_TOPOLOGY_INTERNAT: |
2402 | #if VERBOSE_TESTING | 2392 | #if VERBOSE_TESTING |
2403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2393 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2404 | _("Creating InterNAT topology\n")); | 2394 | _("Creating InterNAT topology\n")); |
2405 | #endif | 2395 | #endif |
2406 | num_connections = create_nated_internet (pg, &add_actual_connections); | 2396 | create_nated_internet (pg, &add_actual_connections); |
2407 | break; | 2397 | break; |
2408 | case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: | 2398 | case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: |
2409 | #if VERBOSE_TESTING | 2399 | #if VERBOSE_TESTING |
2410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2400 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2411 | _("Creating Scale Free topology\n")); | 2401 | _("Creating Scale Free topology\n")); |
2412 | #endif | 2402 | #endif |
2413 | num_connections = create_scale_free (pg, &add_actual_connections); | 2403 | create_scale_free (pg, &add_actual_connections); |
2414 | break; | 2404 | break; |
2415 | case GNUNET_TESTING_TOPOLOGY_NONE: | 2405 | case GNUNET_TESTING_TOPOLOGY_NONE: |
2416 | num_connections = copy_allowed_topology(pg); | 2406 | num_connections = copy_allowed_topology(pg); |
2417 | break; | 2407 | break; |
2418 | default: | 2408 | default: |
2419 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Unknown topology specification, can't connect peers!\n"); | 2409 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
2410 | _("Unknown topology specification, can't connect peers!\n")); | ||
2420 | return GNUNET_SYSERR; | 2411 | return GNUNET_SYSERR; |
2421 | } | 2412 | } |
2422 | 2413 | ||
2423 | switch (options) | 2414 | switch (options) |
2424 | { | 2415 | { |
2425 | case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: /* Create a random subset of total connections based on parameter */ | 2416 | case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: |
2426 | choose_random_connections(pg, option_modifier); | 2417 | choose_random_connections(pg, option_modifier); |
2427 | break; | 2418 | break; |
2428 | case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM: /* Create at least X connections per peer (if possible!) */ | 2419 | case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM: |
2429 | choose_minimum(pg, (unsigned int)option_modifier); | 2420 | choose_minimum(pg, (unsigned int)option_modifier); |
2430 | break; | 2421 | break; |
2431 | case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: /* Choose a random starting point, randomly walk graph, try to get each peer X connections */ | 2422 | case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: |
2432 | perform_dfs(pg, (int)option_modifier); | 2423 | perform_dfs(pg, (int)option_modifier); |
2433 | break; | 2424 | break; |
2434 | case GNUNET_TESTING_TOPOLOGY_OPTION_NONE: | 2425 | case GNUNET_TESTING_TOPOLOGY_OPTION_NONE: |
2435 | /* Fall through */ | 2426 | break; |
2436 | case GNUNET_TESTING_TOPOLOGY_OPTION_ALL: | 2427 | case GNUNET_TESTING_TOPOLOGY_OPTION_ALL: |
2437 | /* Fall through */ | 2428 | break; |
2438 | default: | 2429 | default: |
2439 | break; | 2430 | break; |
2440 | } | 2431 | } |