aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-17 15:29:40 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-17 15:29:40 +0000
commit7f06c82295b46f1c8f1f3b16d5e979abea3e5660 (patch)
tree2f30ab82eb3d4bdde81ca75b5fb5fccf4abe79da /src/testing/testing_group.c
parent344da83a5a06b4b4db4eb68972ee49333369f2db (diff)
downloadgnunet-7f06c82295b46f1c8f1f3b16d5e979abea3e5660.tar.gz
gnunet-7f06c82295b46f1c8f1f3b16d5e979abea3e5660.zip
some testing changes, including an api change that likely breaks things for others
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c155
1 files changed, 149 insertions, 6 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 9965bb2fb..b6ae14036 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -22,6 +22,15 @@
22 * @file testing/testing_group.c 22 * @file testing/testing_group.c
23 * @brief convenience API for writing testcases for GNUnet 23 * @brief convenience API for writing testcases for GNUnet
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 *
26 * FIXME: have connection processor functions take a cls argument
27 * which specifies where to write the connection information
28 * instead of assuming it's certain peergroup places. (maybe?)
29 * FIXME: create static struct which contains the TOPOLOGY enum, the
30 * associated string, and the function used to create it.
31 * Then replace the create_X calls with topology_struct[i][2]
32 * or something. (Store function pointers instead of using
33 * switch statements)
25 */ 34 */
26#include "platform.h" 35#include "platform.h"
27#include "gnunet_arm_service.h" 36#include "gnunet_arm_service.h"
@@ -108,6 +117,11 @@ static char * GNUNET_TESTING_TopologyStrings[] =
108 "SCALE_FREE", 117 "SCALE_FREE",
109 118
110 /** 119 /**
120 * Straight line topology.
121 */
122 "LINE",
123
124 /**
111 * All peers are disconnected. 125 * All peers are disconnected.
112 */ 126 */
113 "NONE" 127 "NONE"
@@ -902,6 +916,17 @@ create_scale_free (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_Connectio
902 return total_connections; 916 return total_connections;
903} 917}
904 918
919/**
920 * Create a topology given a peer group (set of running peers)
921 * and a connection processor.
922 *
923 * @param pg the peergroup to create the topology on
924 * @param proc the connection processor to call to actually set
925 * up connections between two peers
926 *
927 * @return the number of connections that were set up
928 *
929 */
905int 930int
906create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 931create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
907{ 932{
@@ -1013,7 +1038,17 @@ create_small_world_ring(struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_Conn
1013 return connect_attempts; 1038 return connect_attempts;
1014} 1039}
1015 1040
1016 1041/**
1042 * Create a topology given a peer group (set of running peers)
1043 * and a connection processor.
1044 *
1045 * @param pg the peergroup to create the topology on
1046 * @param proc the connection processor to call to actually set
1047 * up connections between two peers
1048 *
1049 * @return the number of connections that were set up
1050 *
1051 */
1017static int 1052static int
1018create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 1053create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1019{ 1054{
@@ -1065,8 +1100,17 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_Conne
1065 1100
1066} 1101}
1067 1102
1068 1103/**
1069 1104 * Create a topology given a peer group (set of running peers)
1105 * and a connection processor.
1106 *
1107 * @param pg the peergroup to create the topology on
1108 * @param proc the connection processor to call to actually set
1109 * up connections between two peers
1110 *
1111 * @return the number of connections that were set up
1112 *
1113 */
1070static int 1114static int
1071create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 1115create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1072{ 1116{
@@ -1208,8 +1252,17 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_Connecti
1208 return connect_attempts; 1252 return connect_attempts;
1209} 1253}
1210 1254
1211 1255/**
1212 1256 * Create a topology given a peer group (set of running peers)
1257 * and a connection processor.
1258 *
1259 * @param pg the peergroup to create the topology on
1260 * @param proc the connection processor to call to actually set
1261 * up connections between two peers
1262 *
1263 * @return the number of connections that were set up
1264 *
1265 */
1213static int 1266static int
1214create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 1267create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1215{ 1268{
@@ -1257,6 +1310,17 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_Connecti
1257 return connect_attempts; 1310 return connect_attempts;
1258} 1311}
1259 1312
1313/**
1314 * Create a topology given a peer group (set of running peers)
1315 * and a connection processor.
1316 *
1317 * @param pg the peergroup to create the topology on
1318 * @param proc the connection processor to call to actually set
1319 * up connections between two peers
1320 *
1321 * @return the number of connections that were set up
1322 *
1323 */
1260static int 1324static int
1261create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 1325create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1262{ 1326{
@@ -1334,7 +1398,17 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionP
1334} 1398}
1335 1399
1336 1400
1337 1401/**
1402 * Create a topology given a peer group (set of running peers)
1403 * and a connection processor.
1404 *
1405 * @param pg the peergroup to create the topology on
1406 * @param proc the connection processor to call to actually set
1407 * up connections between two peers
1408 *
1409 * @return the number of connections that were set up
1410 *
1411 */
1338static int 1412static int
1339create_clique (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 1413create_clique (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1340{ 1414{
@@ -1361,7 +1435,50 @@ create_clique (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionPro
1361 return connect_attempts; 1435 return connect_attempts;
1362} 1436}
1363 1437
1438/**
1439 * Create a topology given a peer group (set of running peers)
1440 * and a connection processor.
1441 *
1442 * @param pg the peergroup to create the topology on
1443 * @param proc the connection processor to call to actually set
1444 * up connections between two peers
1445 *
1446 * @return the number of connections that were set up
1447 *
1448 */
1449static int
1450create_line (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1451{
1452 unsigned int count;
1453 int connect_attempts;
1454
1455 connect_attempts = 0;
1456
1457 /* Connect each peer to the next highest numbered peer */
1458 for (count = 0; count < pg->total - 1; count++)
1459 {
1460#if VERBOSE_TESTING
1461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1462 "Connecting peer %d to peer %d\n",
1463 count, count + 1);
1464#endif
1465 connect_attempts += proc(pg, count, count + 1);
1466 }
1364 1467
1468 return connect_attempts;
1469}
1470
1471/**
1472 * Create a topology given a peer group (set of running peers)
1473 * and a connection processor.
1474 *
1475 * @param pg the peergroup to create the topology on
1476 * @param proc the connection processor to call to actually set
1477 * up connections between two peers
1478 *
1479 * @return the number of connections that were set up
1480 *
1481 */
1365static int 1482static int
1366create_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc) 1483create_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TESTING_ConnectionProcessor proc)
1367{ 1484{
@@ -1745,6 +1862,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, char *tran
1745static void internal_connect_notify (void *cls, 1862static void internal_connect_notify (void *cls,
1746 const struct GNUNET_PeerIdentity *first, 1863 const struct GNUNET_PeerIdentity *first,
1747 const struct GNUNET_PeerIdentity *second, 1864 const struct GNUNET_PeerIdentity *second,
1865 uint32_t distance,
1748 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 1866 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
1749 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 1867 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
1750 struct GNUNET_TESTING_Daemon *first_daemon, 1868 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -1754,12 +1872,16 @@ static void internal_connect_notify (void *cls,
1754 struct GNUNET_TESTING_PeerGroup *pg = cls; 1872 struct GNUNET_TESTING_PeerGroup *pg = cls;
1755 outstanding_connects--; 1873 outstanding_connects--;
1756 1874
1875<<<<<<< .mine
1876 pg->notify_connection(pg->notify_connection_cls, first, second, distance, first_cfg, second_cfg, first_daemon, second_daemon, emsg);
1877=======
1757 pg->notify_connection(pg->notify_connection_cls, 1878 pg->notify_connection(pg->notify_connection_cls,
1758 first, 1879 first,
1759 second, 1880 second,
1760 first_cfg, second_cfg, 1881 first_cfg, second_cfg,
1761 first_daemon, second_daemon, 1882 first_daemon, second_daemon,
1762 emsg); 1883 emsg);
1884>>>>>>> .r11782
1763 1885
1764} 1886}
1765 1887
@@ -2010,6 +2132,13 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
2010#endif 2132#endif
2011 num_connections = create_scale_free (pg, &add_allowed_connections); 2133 num_connections = create_scale_free (pg, &add_allowed_connections);
2012 break; 2134 break;
2135 case GNUNET_TESTING_TOPOLOGY_LINE:
2136#if VERBOSE_TESTING
2137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2138 _("Creating straight line topology\n"));
2139#endif
2140 num_connections = create_line (pg, &add_allowed_connections);
2141 break;
2013 case GNUNET_TESTING_TOPOLOGY_NONE: 2142 case GNUNET_TESTING_TOPOLOGY_NONE:
2014 num_connections = 0; 2143 num_connections = 0;
2015 break; 2144 break;
@@ -2103,6 +2232,13 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
2103#endif 2232#endif
2104 unblacklisted_connections = create_scale_free (pg, &unblacklist_connections); 2233 unblacklisted_connections = create_scale_free (pg, &unblacklist_connections);
2105 break; 2234 break;
2235 case GNUNET_TESTING_TOPOLOGY_LINE:
2236#if VERBOSE_TESTING
2237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2238 _("Blacklisting all but straight line topology\n"));
2239#endif
2240 unblacklisted_connections = create_line (pg, &unblacklist_connections);
2241 break;
2106 case GNUNET_TESTING_TOPOLOGY_NONE: 2242 case GNUNET_TESTING_TOPOLOGY_NONE:
2107 /* Fall through */ 2243 /* Fall through */
2108 default: 2244 default:
@@ -2581,6 +2717,13 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
2581#endif 2717#endif
2582 create_scale_free (pg, &add_actual_connections); 2718 create_scale_free (pg, &add_actual_connections);
2583 break; 2719 break;
2720 case GNUNET_TESTING_TOPOLOGY_LINE:
2721#if VERBOSE_TOPOLOGY
2722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2723 _("Creating straight line CONNECT topology\n"));
2724#endif
2725 create_line (pg, &add_actual_connections);
2726 break;
2584 case GNUNET_TESTING_TOPOLOGY_NONE: 2727 case GNUNET_TESTING_TOPOLOGY_NONE:
2585#if VERBOSE_TOPOLOGY 2728#if VERBOSE_TOPOLOGY
2586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,