aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-10-28 16:13:47 +0200
committert3sserakt <t3ss@posteo.de>2021-10-28 16:13:47 +0200
commit6fb788ca2ec44837ea10a36be7fd0030fb08955b (patch)
treecba4a385aa8ab914d02db9a702f6c6230aa89a2a /src
parent1609d627e509043a946f611d7589105cfae2364d (diff)
downloadgnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.tar.gz
gnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.zip
- fixed coverity issues
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_testing_ng_lib.h9
-rw-r--r--src/testing/testing.c140
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c109
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c24
-rw-r--r--src/transport/gnunet-communicator-tcp.c29
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c62
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c17
-rwxr-xr-xsrc/transport/test_transport_simple_send.sh7
-rw-r--r--src/transport/test_transport_simple_send_topo.conf4
-rwxr-xr-xsrc/transport/test_transport_udp_backchannel.sh5
-rw-r--r--src/transport/transport-testing-cmds.h17
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c23
-rw-r--r--src/transport/transport_api_cmd_send_simple.c119
-rw-r--r--src/transport/transport_api_cmd_start_peer.c14
14 files changed, 397 insertions, 182 deletions
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 45e58299e..7ce73baef 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -681,6 +681,15 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
681 681
682 682
683/** 683/**
684 * Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
685 *
686 * @param topology The GNUNET_TESTING_NetjailTopology to be deallocated.
687 */
688void
689GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology);
690
691
692/**
684 * Calculate the unique id identifying a node from a given connction. 693 * Calculate the unique id identifying a node from a given connction.
685 * 694 *
686 * @param node_connection The connection we calculate the id from. 695 * @param node_connection The connection we calculate the id from.
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 4d9b7c0cb..02cedc744 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1798,7 +1798,7 @@ get_first_value (char *line)
1798 memcpy (copy, line, slen); 1798 memcpy (copy, line, slen);
1799 token = strtok_r (copy, ":", &rest); 1799 token = strtok_r (copy, ":", &rest);
1800 token = strtok_r (NULL, ":", &rest); 1800 token = strtok_r (NULL, ":", &rest);
1801 sscanf (token, "%u", &ret); 1801 GNUNET_assert (1 == sscanf (token, "%u", &ret));
1802 GNUNET_free (copy); 1802 GNUNET_free (copy);
1803 return ret; 1803 return ret;
1804} 1804}
@@ -1864,7 +1864,7 @@ get_second_value (char *line)
1864 token = strtok_r (copy, ":", &rest); 1864 token = strtok_r (copy, ":", &rest);
1865 token = strtok_r (NULL, ":", &rest); 1865 token = strtok_r (NULL, ":", &rest);
1866 token = strtok_r (NULL, ":", &rest); 1866 token = strtok_r (NULL, ":", &rest);
1867 sscanf (token, "%u", &ret); 1867 GNUNET_assert (1 == sscanf (token, "%u", &ret));
1868 GNUNET_free (copy); 1868 GNUNET_free (copy);
1869 return ret; 1869 return ret;
1870} 1870}
@@ -1923,7 +1923,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1923 { 1923 {
1924 node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE; 1924 node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE;
1925 token = strtok_r (NULL, ":", &rest); 1925 token = strtok_r (NULL, ":", &rest);
1926 sscanf (token, "%u", &node_n); 1926 GNUNET_assert (1 == sscanf (token, "%u", &node_n));
1927 LOG (GNUNET_ERROR_TYPE_ERROR, 1927 LOG (GNUNET_ERROR_TYPE_ERROR,
1928 "node_n %u\n", 1928 "node_n %u\n",
1929 node_n); 1929 node_n);
@@ -1934,15 +1934,17 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node)
1934 { 1934 {
1935 node_connection->node_type = GNUNET_TESTING_SUBNET_NODE; 1935 node_connection->node_type = GNUNET_TESTING_SUBNET_NODE;
1936 token = strtok_r (NULL, ":", &rest); 1936 token = strtok_r (NULL, ":", &rest);
1937 sscanf (token, "%u", &node_n);
1938 node_connection->node_n = node_n;
1939 token = strtok_r (NULL, ":", &rest);
1940 sscanf (token, "%u", &namespace_n); 1937 sscanf (token, "%u", &namespace_n);
1941 node_connection->namespace_n = namespace_n; 1938 node_connection->namespace_n = namespace_n;
1939 token = strtok_r (NULL, ":", &rest);
1940 sscanf (token, "%u", &node_n);
1941 node_connection->node_n = node_n;
1942 LOG (GNUNET_ERROR_TYPE_ERROR, 1942 LOG (GNUNET_ERROR_TYPE_ERROR,
1943 "node_n %u namespace_n %u\n", 1943 "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n",
1944 node_n, 1944 node_n,
1945 namespace_n); 1945 namespace_n,
1946 node->node_n,
1947 node->namespace_n);
1946 } 1948 }
1947 while (NULL != (token = strtok_r (NULL, ":", &rest))) 1949 while (NULL != (token = strtok_r (NULL, ":", &rest)))
1948 { 1950 {
@@ -1994,13 +1996,16 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
1994 if (NULL != temp) 1996 if (NULL != temp)
1995 { 1997 {
1996 slen = strlen (temp) + 1; 1998 slen = strlen (temp) + 1;
1997 copy = malloc (slen); 1999 copy = GNUNET_malloc (slen);
1998 memcpy (copy, temp, slen); 2000 memcpy (copy, temp, slen);
1999 strtok_r (copy, ":", &rest); 2001 strtok_r (copy, ":", &rest);
2000 value = strtok_r (rest, "|", &rest2); 2002 value = strtok_r (rest, "|", &rest2);
2001 2003
2002 while (NULL != value) 2004 while (NULL != value)
2003 { 2005 {
2006 LOG (GNUNET_ERROR_TYPE_DEBUG,
2007 "node_connections value %s\n",
2008 value);
2004 node_connection = get_connect_value (value, node); 2009 node_connection = get_connect_value (value, node);
2005 GNUNET_CONTAINER_DLL_insert (node->node_connections_head, 2010 GNUNET_CONTAINER_DLL_insert (node->node_connections_head,
2006 node->node_connections_tail, 2011 node->node_connections_tail,
@@ -2011,6 +2016,7 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node)
2011 value = strtok_r (NULL, "|", &rest2); 2016 value = strtok_r (NULL, "|", &rest2);
2012 2017
2013 } 2018 }
2019 GNUNET_free (copy);
2014 } 2020 }
2015} 2021}
2016 2022
@@ -2056,13 +2062,7 @@ static int
2056log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) 2062log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
2057{ 2063{
2058 struct GNUNET_TESTING_NetjailNamespace *namespace = value; 2064 struct GNUNET_TESTING_NetjailNamespace *namespace = value;
2059 struct GNUNET_TESTING_NetjailRouter *router = namespace->router;
2060 2065
2061 LOG (GNUNET_ERROR_TYPE_ERROR,
2062 "router_tcp: %u router_udp: %u spaces: %u\n",
2063 router->tcp_port,
2064 router->udp_port,
2065 namespace->namespace_n);
2066 GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, &log_nodes, NULL); 2066 GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, &log_nodes, NULL);
2067 return GNUNET_YES; 2067 return GNUNET_YES;
2068} 2068}
@@ -2103,9 +2103,15 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
2103 struct GNUNET_TESTING_NetjailNamespace *namespace; 2103 struct GNUNET_TESTING_NetjailNamespace *namespace;
2104 unsigned int namespace_n, node_m; 2104 unsigned int namespace_n, node_m;
2105 2105
2106 LOG (GNUNET_ERROR_TYPE_DEBUG,
2107 "gaga 1\n");
2106 log_topo (topology); 2108 log_topo (topology);
2107 2109 LOG (GNUNET_ERROR_TYPE_DEBUG,
2110 "gaga 2\n");
2108 hkey = GNUNET_new (struct GNUNET_ShortHashCode); 2111 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2112 LOG (GNUNET_ERROR_TYPE_DEBUG,
2113 "num: %u \n",
2114 num);
2109 if (topology->nodes_x >= num) 2115 if (topology->nodes_x >= num)
2110 { 2116 {
2111 2117
@@ -2118,10 +2124,10 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
2118 } 2124 }
2119 else 2125 else
2120 { 2126 {
2121 namespace_n = (unsigned int) floor ((num - topology->nodes_x) 2127 namespace_n = (unsigned int) ceil ((double) (num - topology->nodes_x)
2122 / topology->nodes_m); 2128 / topology->nodes_m);
2123 LOG (GNUNET_ERROR_TYPE_ERROR, 2129 LOG (GNUNET_ERROR_TYPE_ERROR,
2124 "num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", 2130 "ceil num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n",
2125 num, 2131 num,
2126 topology->nodes_x, 2132 topology->nodes_x,
2127 topology->nodes_m, 2133 topology->nodes_m,
@@ -2143,7 +2149,7 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
2143 hkey); 2149 hkey);
2144 } 2150 }
2145 2151
2146 2152 GNUNET_free (hkey);
2147 return node->node_connections_head; 2153 return node->node_connections_head;
2148} 2154}
2149 2155
@@ -2172,10 +2178,74 @@ GNUNET_TESTING_get_pub_key (unsigned int num, struct
2172 GNUNET_CRYPTO_eddsa_key_get_public (priv_key, 2178 GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
2173 pub_key); 2179 pub_key);
2174 peer->public_key = *pub_key; 2180 peer->public_key = *pub_key;
2181 GNUNET_free (priv_key);
2182 GNUNET_free (pub_key);
2175 return peer; 2183 return peer;
2176} 2184}
2177 2185
2178 2186
2187int
2188free_nodes_cb (void *cls,
2189 const struct GNUNET_ShortHashCode *key,
2190 void *value)
2191{
2192 (void) cls;
2193 struct GNUNET_TESTING_NetjailNode *node = value;
2194 struct GNUNET_TESTING_NodeConnection *pos_connection;
2195 struct GNUNET_TESTING_NodeConnection *tmp_connection;
2196 struct GNUNET_TESTING_AddressPrefix *pos_prefix;
2197 struct GNUNET_TESTING_AddressPrefix *tmp_prefix;
2198
2199 pos_connection = node->node_connections_head;
2200
2201 while (NULL != pos_connection->next)
2202 {
2203 pos_prefix = pos_connection->address_prefixes_head;
2204 while (NULL != pos_prefix->next)
2205 {
2206 tmp_prefix = pos_prefix->next;
2207 GNUNET_free (pos_prefix);
2208 pos_prefix = tmp_prefix;
2209 }
2210 tmp_connection = pos_connection->next;
2211 GNUNET_free (pos_connection);
2212 pos_connection = tmp_connection;
2213 }
2214 return GNUNET_OK;
2215}
2216
2217
2218int
2219free_namespaces_cb (void *cls,
2220 const struct GNUNET_ShortHashCode *key,
2221 void *value)
2222{
2223 (void) cls;
2224 struct GNUNET_TESTING_NetjailNamespace *namespace = value;
2225
2226 GNUNET_free (namespace->router);
2227 GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, free_nodes_cb,
2228 NULL);
2229 return GNUNET_OK;
2230
2231}
2232
2233
2234/**
2235 * Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
2236 *
2237 * @param topology The GNUNET_TESTING_NetjailTopology to be deallocated.
2238 */
2239void
2240GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology)
2241{
2242 GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces,
2243 free_namespaces_cb, NULL);
2244 GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb,
2245 NULL);
2246 GNUNET_free (topology);
2247}
2248
2179/** 2249/**
2180 * Calculate the unique id identifying a node from a given connction. 2250 * Calculate the unique id identifying a node from a given connction.
2181 * 2251 *
@@ -2252,7 +2322,7 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
2252 } 2322 }
2253 else 2323 else
2254 { 2324 {
2255 GNUNET_break (0); 2325 GNUNET_assert (0);
2256 } 2326 }
2257 2327
2258 return addr; 2328 return addr;
@@ -2296,24 +2366,19 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2296 uint64_t fs; 2366 uint64_t fs;
2297 char *data; 2367 char *data;
2298 char *token; 2368 char *token;
2299 char *key; 2369 char *key = NULL;
2300 unsigned int out; 2370 unsigned int out;
2301 char *rest = NULL; 2371 char *rest = NULL;
2302 char *value; 2372 char *value;
2373 char *value2;
2303 int ret; 2374 int ret;
2304 struct GNUNET_TESTING_NetjailTopology *topo = GNUNET_new (struct 2375 struct GNUNET_TESTING_NetjailTopology *topo;
2305 GNUNET_TESTING_NetjailTopology);
2306 struct GNUNET_TESTING_NetjailNode *node; 2376 struct GNUNET_TESTING_NetjailNode *node;
2307 struct GNUNET_TESTING_NetjailRouter *router; 2377 struct GNUNET_TESTING_NetjailRouter *router;
2308 struct GNUNET_TESTING_NetjailNamespace *namespace; 2378 struct GNUNET_TESTING_NetjailNamespace *namespace;
2309 struct GNUNET_ShortHashCode *hkey; 2379 struct GNUNET_ShortHashCode *hkey;
2310 struct GNUNET_HashCode hc; 2380 struct GNUNET_HashCode hc;
2311 2381
2312 topo->map_namespaces =
2313 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2314 topo->map_globals =
2315 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2316
2317 if (GNUNET_YES != GNUNET_DISK_file_test (filename)) 2382 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
2318 { 2383 {
2319 LOG (GNUNET_ERROR_TYPE_ERROR, 2384 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -2339,14 +2404,22 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2339 return NULL; 2404 return NULL;
2340 } 2405 }
2341 2406
2342 LOG (GNUNET_ERROR_TYPE_ERROR, 2407 LOG (GNUNET_ERROR_TYPE_DEBUG,
2343 "data: %s\n", 2408 "data: %s\n",
2344 data); 2409 data);
2345 2410
2411 data[fs] = '\0';
2346 token = strtok_r (data, "\n", &rest); 2412 token = strtok_r (data, "\n", &rest);
2413 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology);
2414 topo->map_namespaces =
2415 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2416 topo->map_globals =
2417 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2347 2418
2348 while (NULL != token) 2419 while (NULL != token)
2349 { 2420 {
2421 if (NULL != key)
2422 free (key);
2350 key = get_key (token); 2423 key = get_key (token);
2351 LOG (GNUNET_ERROR_TYPE_ERROR, 2424 LOG (GNUNET_ERROR_TYPE_ERROR,
2352 "In the loop with token: %s beginning with %s\n", 2425 "In the loop with token: %s beginning with %s\n",
@@ -2457,12 +2530,12 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2457 2530
2458 LOG (GNUNET_ERROR_TYPE_ERROR, 2531 LOG (GNUNET_ERROR_TYPE_ERROR,
2459 "Get value for key udp_port on R.\n"); 2532 "Get value for key udp_port on R.\n");
2460 value = get_value ("udp_port", token); 2533 value2 = get_value ("udp_port", token);
2461 ret = sscanf (value, "%u", &(router->udp_port)); 2534 ret = sscanf (value2, "%u", &(router->udp_port));
2462 GNUNET_break (0 != ret && 1 >= router->udp_port); 2535 GNUNET_break (0 != ret && 1 >= router->udp_port);
2463 LOG (GNUNET_ERROR_TYPE_ERROR, 2536 LOG (GNUNET_ERROR_TYPE_ERROR,
2464 "udp_port: %s\n", 2537 "udp_port: %s\n",
2465 value); 2538 value2);
2466 2539
2467 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( 2540 if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
2468 topo->map_namespaces, 2541 topo->map_namespaces,
@@ -2554,6 +2627,7 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2554 } 2627 }
2555 token = strtok_r (NULL, "\n", &rest); 2628 token = strtok_r (NULL, "\n", &rest);
2556 } 2629 }
2630 GNUNET_free (data);
2557 2631
2558 return topo; 2632 return topo;
2559} 2633}
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 9b567a01f..c3598d174 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -67,6 +67,12 @@ struct HelperMessage
67struct NetJailState 67struct NetJailState
68{ 68{
69 /** 69 /**
70 * Global state of the interpreter, used by a command
71 * to access information about other commands.
72 */
73 struct GNUNET_TESTING_Interpreter *is;
74
75 /**
70 * Context for our asynchronous completion. 76 * Context for our asynchronous completion.
71 */ 77 */
72 struct GNUNET_TESTING_AsyncContext ac; 78 struct GNUNET_TESTING_AsyncContext ac;
@@ -77,12 +83,6 @@ struct NetJailState
77 struct GNUNET_TESTING_NetjailTopology *topology; 83 struct GNUNET_TESTING_NetjailTopology *topology;
78 84
79 /** 85 /**
80 * Pointer to the return value of the test.
81 *
82 */
83 unsigned int *rv;
84
85 /**
86 * Head of the DLL which stores messages received by the helper. 86 * Head of the DLL which stores messages received by the helper.
87 * 87 *
88 */ 88 */
@@ -254,6 +254,7 @@ netjail_exec_cleanup (void *cls)
254 tbc_pos); 254 tbc_pos);
255 GNUNET_free (tbc_pos); 255 GNUNET_free (tbc_pos);
256 } 256 }
257 GNUNET_TESTING_free_topology (ns->topology);
257 GNUNET_free (ns); 258 GNUNET_free (ns);
258} 259}
259 260
@@ -429,18 +430,63 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
429 struct NetJailState *ns = cls;// tbc->ns; 430 struct NetJailState *ns = cls;// tbc->ns;
430 struct HelperMessage *hp_msg; 431 struct HelperMessage *hp_msg;
431 unsigned int total_number = ns->local_m * ns->global_n + ns->known; 432 unsigned int total_number = ns->local_m * ns->global_n + ns->known;
433 // uint16_t message_type = ntohs (message->type);
432 434
433 LOG (GNUNET_ERROR_TYPE_DEBUG, 435 /*switch (message_type)
434 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", 436 {
435 total_number, 437 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY:
436 ns->number_of_testsystems_started, 438 ns->number_of_testsystems_started++;
437 ns->number_of_peers_started, 439 break;
438 ns->number_of_local_tests_prepared, 440 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED:
439 ns->number_of_local_tests_finished, 441 ns->number_of_peers_started++;
440 ns->local_m, 442 if (ns->number_of_peers_started == total_number)
441 ns->global_n, 443 {
442 ns->known); 444 for (int i = 1; i <= ns->known; i++)
445 {
446 send_all_peers_started (0,i, ns);
447 }
448 for (int i = 1; i <= ns->global_n; i++)
449 {
450 for (int j = 1; j <= ns->local_m; j++)
451 {
452 send_all_peers_started (i,j, ns);
453 }
454 }
455 ns->number_of_peers_started = 0;
456 }
457 break;
458 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED:
459 ns->number_of_local_tests_prepared++;
460 if (ns->number_of_local_tests_prepared == total_number)
461 {
462 for (int i = 1; i <= ns->known; i++)
463 {
464 send_all_local_tests_prepared (0,i, ns);
465 }
443 466
467 for (int i = 1; i <= ns->global_n; i++)
468 {
469 for (int j = 1; j <= ns->local_m; j++)
470 {
471 send_all_local_tests_prepared (i,j, ns);
472 }
473 }
474 }
475 break;
476 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED:
477 ns->number_of_local_tests_finished++;
478 if (ns->number_of_local_tests_finished == total_number)
479 {
480 GNUNET_TESTING_async_finish (&ns->ac);
481 }
482 break;
483 default:
484 hp_msg = GNUNET_new (struct HelperMessage);
485 hp_msg->bytes_msg = message->size;
486 memcpy (&hp_msg[1], message, message->size);
487 GNUNET_CONTAINER_DLL_insert (ns->hp_messages_head, ns->hp_messages_tail,
488 hp_msg);
489 }*/
444 if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) 490 if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type))
445 { 491 {
446 ns->number_of_testsystems_started++; 492 ns->number_of_testsystems_started++;
@@ -505,7 +551,16 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
505 } 551 }
506 552
507 553
508 554 LOG (GNUNET_ERROR_TYPE_DEBUG,
555 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
556 total_number,
557 ns->number_of_testsystems_started,
558 ns->number_of_peers_started,
559 ns->number_of_local_tests_prepared,
560 ns->number_of_local_tests_finished,
561 ns->local_m,
562 ns->global_n,
563 ns->known);
509 564
510 565
511 566
@@ -524,7 +579,7 @@ exp_cb (void *cls)
524 struct TestingSystemCount *tbc = cls; 579 struct TestingSystemCount *tbc = cls;
525 580
526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); 581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
527 GNUNET_TESTING_interpreter_fail (tbc->ns->ac.is); 582 GNUNET_TESTING_async_fail (&(tbc->ns->ac));
528} 583}
529 584
530 585
@@ -560,8 +615,7 @@ create_helper_init_msg_ (const char *plugin_name)
560 * 615 *
561 */ 616 */
562static void 617static void
563start_helper (struct NetJailState *ns, struct 618start_helper (struct NetJailState *ns,
564 GNUNET_CONFIGURATION_Handle *config,
565 unsigned int m, 619 unsigned int m,
566 unsigned int n) 620 unsigned int n)
567{ 621{
@@ -582,7 +636,6 @@ start_helper (struct NetJailState *ns, struct
582 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; 636 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
583 struct GNUNET_TESTING_NetjailNode *node; 637 struct GNUNET_TESTING_NetjailNode *node;
584 struct GNUNET_TESTING_NetjailNamespace *namespace; 638 struct GNUNET_TESTING_NetjailNamespace *namespace;
585 unsigned int *rv = ns->rv;
586 639
587 640
588 if (0 == n) 641 if (0 == n)
@@ -633,14 +686,14 @@ start_helper (struct NetJailState *ns, struct
633 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 686 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
634 "No SUID for %s!\n", 687 "No SUID for %s!\n",
635 NETJAIL_EXEC_SCRIPT); 688 NETJAIL_EXEC_SCRIPT);
636 *rv = 1; 689 GNUNET_TESTING_interpreter_fail (ns->is);
637 } 690 }
638 else if (GNUNET_NO == helper_check) 691 else if (GNUNET_NO == helper_check)
639 { 692 {
640 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 693 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
641 "%s not found!\n", 694 "%s not found!\n",
642 NETJAIL_EXEC_SCRIPT); 695 NETJAIL_EXEC_SCRIPT);
643 *rv = 1; 696 GNUNET_TESTING_interpreter_fail (ns->is);
644 } 697 }
645 698
646 LOG (GNUNET_ERROR_TYPE_DEBUG, 699 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -729,8 +782,9 @@ start_helper (struct NetJailState *ns, struct
729 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 782 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
730 "Send handle is NULL!\n"); 783 "Send handle is NULL!\n");
731 GNUNET_free (msg); 784 GNUNET_free (msg);
732 *rv = 1; 785 GNUNET_TESTING_interpreter_fail (ns->is);
733 } 786 }
787 GNUNET_free (hkey);
734} 788}
735 789
736 790
@@ -746,12 +800,11 @@ netjail_exec_run (void *cls,
746 struct GNUNET_TESTING_Interpreter *is) 800 struct GNUNET_TESTING_Interpreter *is)
747{ 801{
748 struct NetJailState *ns = cls; 802 struct NetJailState *ns = cls;
749 struct GNUNET_CONFIGURATION_Handle *config =
750 GNUNET_CONFIGURATION_create ();
751 803
804 ns->is = is;
752 for (int i = 1; i <= ns->known; i++) 805 for (int i = 1; i <= ns->known; i++)
753 { 806 {
754 start_helper (ns, config, 807 start_helper (ns,
755 i, 808 i,
756 0); 809 0);
757 } 810 }
@@ -760,7 +813,7 @@ netjail_exec_run (void *cls,
760 { 813 {
761 for (int j = 1; j <= ns->local_m; j++) 814 for (int j = 1; j <= ns->local_m; j++)
762 { 815 {
763 start_helper (ns, config, 816 start_helper (ns,
764 j, 817 j,
765 i); 818 i);
766 } 819 }
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
index 33792f1b0..e37e955be 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -35,6 +35,11 @@
35struct StopHelperState 35struct StopHelperState
36{ 36{
37 37
38 /**
39 * The complete topology information.
40 */
41 struct GNUNET_TESTING_NetjailTopology *topology;
42
38 const char *helper_start_label; 43 const char *helper_start_label;
39 44
40 /** 45 /**
@@ -63,21 +68,10 @@ struct StopHelperState
63static void 68static void
64stop_testing_system_cleanup (void *cls) 69stop_testing_system_cleanup (void *cls)
65{ 70{
71 struct StopHelperState *shs = cls;
66 72
67} 73 GNUNET_TESTING_free_topology (shs->topology);
68 74 GNUNET_free (shs);
69
70/**
71 * Trait function of this cmd does nothing.
72 *
73 */
74static int
75stop_testing_system_traits (void *cls,
76 const void **ret,
77 const char *trait,
78 unsigned int index)
79{
80 return GNUNET_OK;
81} 75}
82 76
83 77
@@ -148,13 +142,13 @@ GNUNET_TESTING_cmd_stop_testing_system (const char *label,
148 shs->local_m = topology->nodes_m; 142 shs->local_m = topology->nodes_m;
149 shs->global_n = topology->namespaces_n; 143 shs->global_n = topology->namespaces_n;
150 shs->known = topology->nodes_x; 144 shs->known = topology->nodes_x;
145 shs->topology = topology;
151 146
152 struct GNUNET_TESTING_Command cmd = { 147 struct GNUNET_TESTING_Command cmd = {
153 .cls = shs, 148 .cls = shs,
154 .label = label, 149 .label = label,
155 .run = &stop_testing_system_run, 150 .run = &stop_testing_system_run,
156 .cleanup = &stop_testing_system_cleanup, 151 .cleanup = &stop_testing_system_cleanup,
157 .traits = &stop_testing_system_traits
158 }; 152 };
159 153
160 return cmd; 154 return cmd;
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 025326de7..0bf919787 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -2119,10 +2119,9 @@ tcp_address_to_sockaddr_port_only (const char *bindto, unsigned int *port)
2119 * @param bindto String we extract the address part from. 2119 * @param bindto String we extract the address part from.
2120 * @return The extracted address string. 2120 * @return The extracted address string.
2121 */ 2121 */
2122static char * 2122static void
2123extract_address (const char *bindto) 2123extract_address (const char *bindto, char **addr)
2124{ 2124{
2125
2126 char *start; 2125 char *start;
2127 char *token; 2126 char *token;
2128 char *cp; 2127 char *cp;
@@ -2147,6 +2146,7 @@ extract_address (const char *bindto)
2147 { 2146 {
2148 start++; /* skip over '['*/ 2147 start++; /* skip over '['*/
2149 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/ 2148 cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
2149 *addr = GNUNET_strdup (start);
2150 } 2150 }
2151 else 2151 else
2152 { 2152 {
@@ -2154,23 +2154,20 @@ extract_address (const char *bindto)
2154 if (strlen (bindto) == strlen (token)) 2154 if (strlen (bindto) == strlen (token))
2155 { 2155 {
2156 token = strtok_r (cp, ":", &rest); 2156 token = strtok_r (cp, ":", &rest);
2157 *addr = strdup (token);
2157 } 2158 }
2158 else 2159 else
2159 { 2160 {
2160 token++; 2161 token++;
2161 res = GNUNET_strdup (token); 2162 res = GNUNET_strdup (token);
2162 GNUNET_free (cp); 2163 *addr = GNUNET_strdup (res);
2163 return res;
2164 } 2164 }
2165 } 2165 }
2166 2166
2167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2168 "extract address 3\n"); 2168 "tcp address: %s\n",
2169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2169 *addr);
2170 "extract address with start %s\n", 2170 GNUNET_free (cp);
2171 start);
2172
2173 return GNUNET_strdup (start);
2174} 2171}
2175 2172
2176 2173
@@ -2241,6 +2238,7 @@ extract_port (const char *addr_and_port)
2241 GNUNET_free (cp); 2238 GNUNET_free (cp);
2242 return 0; 2239 return 0;
2243 } 2240 }
2241 GNUNET_free (cp);
2244 } 2242 }
2245 else 2243 else
2246 { 2244 {
@@ -2250,7 +2248,6 @@ extract_port (const char *addr_and_port)
2250 port = 0; 2248 port = 0;
2251 } 2249 }
2252 2250
2253
2254 return port; 2251 return port;
2255} 2252}
2256 2253
@@ -2269,10 +2266,11 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
2269 unsigned int port; 2266 unsigned int port;
2270 struct sockaddr_in v4; 2267 struct sockaddr_in v4;
2271 struct sockaddr_in6 v6; 2268 struct sockaddr_in6 v6;
2272 char *start; 2269 char *start = GNUNET_malloc (sizeof(bindto));
2273 2270
2274 // cp = GNUNET_strdup (bindto); 2271 // cp = GNUNET_strdup (bindto);
2275 start = extract_address (bindto); 2272 start = GNUNET_malloc (sizeof(bindto));
2273 extract_address (bindto, &start);
2276 2274
2277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2278 "start %s\n", 2276 "start %s\n",
@@ -3604,7 +3602,8 @@ run (void *cls,
3604 return; 3602 return;
3605 } 3603 }
3606 3604
3607 start = extract_address (bindto); 3605 start = GNUNET_malloc (sizeof(bindto));
3606 extract_address (bindto, &start);
3608 3607
3609 if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) 3608 if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
3610 { 3609 {
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index f0b47084b..c374fc2d0 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -58,6 +58,11 @@ struct TestState
58 * 58 *
59 */ 59 */
60 char *cfgname; 60 char *cfgname;
61
62 /**
63 * The complete topology information.
64 */
65 struct GNUNET_TESTING_NetjailTopology *topology;
61}; 66};
62 67
63static struct GNUNET_TESTING_Command block_send; 68static struct GNUNET_TESTING_Command block_send;
@@ -66,6 +71,8 @@ static struct GNUNET_TESTING_Command block_receive;
66 71
67static struct GNUNET_TESTING_Command connect_peers; 72static struct GNUNET_TESTING_Command connect_peers;
68 73
74static struct GNUNET_TESTING_Command local_prepared;
75
69 76
70/** 77/**
71 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being 78 * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
@@ -93,7 +100,8 @@ handle_test (void *cls,
93 100
94 GNUNET_TESTING_get_trait_async_context (&block_receive, 101 GNUNET_TESTING_get_trait_async_context (&block_receive,
95 &ac); 102 &ac);
96 if ((NULL == ac) || (NULL == ac->cont)) 103 GNUNET_assert (NULL != ac);
104 if (NULL == ac->cont)
97 GNUNET_TESTING_async_fail (ac); 105 GNUNET_TESTING_async_fail (ac);
98 else 106 else
99 GNUNET_TESTING_async_finish (ac); 107 GNUNET_TESTING_async_finish (ac);
@@ -111,7 +119,8 @@ all_peers_started ()
111 119
112 GNUNET_TESTING_get_trait_async_context (&block_send, 120 GNUNET_TESTING_get_trait_async_context (&block_send,
113 &ac); 121 &ac);
114 if ((NULL == ac) || (NULL == ac->cont)) 122 GNUNET_assert (NULL != ac);
123 if (NULL == ac->cont)
115 GNUNET_TESTING_async_fail (ac); 124 GNUNET_TESTING_async_fail (ac);
116 else 125 else
117 GNUNET_TESTING_async_finish (ac); 126 GNUNET_TESTING_async_finish (ac);
@@ -136,10 +145,15 @@ handle_result (void *cls,
136 rv); 145 rv);
137 reply = GNUNET_TESTING_send_local_test_finished_msg (rv); 146 reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
138 147
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
149 "message prepared\n");
139 ts->write_message (reply, 150 ts->write_message (reply,
140 ntohs (reply->size)); 151 ntohs (reply->size));
152 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
153 "message send\n");
141 GNUNET_free (ts->testdir); 154 GNUNET_free (ts->testdir);
142 GNUNET_free (ts->cfgname); 155 GNUNET_free (ts->cfgname);
156 GNUNET_TESTING_free_topology (ts->topology);
143 GNUNET_free (ts); 157 GNUNET_free (ts);
144} 158}
145 159
@@ -167,6 +181,24 @@ notify_connect (void *cls,
167 181
168 182
169/** 183/**
184 * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.
185 */
186static void
187all_local_tests_prepared ()
188{
189 struct LocalPreparedState *lfs;
190
191 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
192 &lfs);
193 GNUNET_assert (NULL != &lfs->ac);
194 if (NULL == lfs->ac.cont)
195 GNUNET_TESTING_async_fail (&lfs->ac);
196 else
197 GNUNET_TESTING_async_finish (&lfs->ac);
198}
199
200
201/**
170 * Function to start a local test case. 202 * Function to start a local test case.
171 * 203 *
172 * @param write_message Callback to send a message to the master loop. 204 * @param write_message Callback to send a message to the master loop.
@@ -192,8 +224,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
192 struct GNUNET_TESTING_NetjailTopology *topology = 224 struct GNUNET_TESTING_NetjailTopology *topology =
193 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); 225 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
194 226
195 if (0 == m_int) 227 ts->topology = topology;
196 num = n_int; 228
229 sscanf (m, "%u", &m_int);
230 sscanf (n, "%u", &n_int);
231 sscanf (local_m, "%u", &local_m_int);
232
233 if (0 == n_int)
234 num = m_int;
197 else 235 else
198 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; 236 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
199 237
@@ -205,13 +243,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
205 "system-create", 243 "system-create",
206 num, 244 num,
207 topology); 245 topology);
246 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
247 "local-test-prepared",
248 write_message);
208 249
209 250
210
211 sscanf (m, "%u", &m_int);
212 sscanf (n, "%u", &n_int);
213 sscanf (local_m, "%u", &local_m_int);
214
215 GNUNET_asprintf (&ts->cfgname, 251 GNUNET_asprintf (&ts->cfgname,
216 "test_transport_api2_tcp_node1.conf"); 252 "test_transport_api2_tcp_node1.conf");
217 253
@@ -253,8 +289,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
253 connect_peers, 289 connect_peers,
254 GNUNET_TRANSPORT_cmd_send_simple ("send-simple", 290 GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
255 "start-peer", 291 "start-peer",
256 num), 292 "system-create",
293 num,
294 topology),
257 block_receive, 295 block_receive,
296 local_prepared,
258 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", 297 GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
259 "start-peer"), 298 "start-peer"),
260 GNUNET_TESTING_cmd_system_destroy ("system-destroy", 299 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
@@ -262,6 +301,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
262 GNUNET_TESTING_cmd_end () 301 GNUNET_TESTING_cmd_end ()
263 }; 302 };
264 303
304 ts->write_message = write_message;
305
265 GNUNET_TESTING_run (commands, 306 GNUNET_TESTING_run (commands,
266 GNUNET_TIME_UNIT_FOREVER_REL, 307 GNUNET_TIME_UNIT_FOREVER_REL,
267 &handle_result, 308 &handle_result,
@@ -288,6 +329,7 @@ libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls)
288 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); 329 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
289 api->start_testcase = &start_testcase; 330 api->start_testcase = &start_testcase;
290 api->all_peers_started = &all_peers_started; 331 api->all_peers_started = &all_peers_started;
332 api->all_local_tests_prepared = all_local_tests_prepared;
291 return api; 333 return api;
292} 334}
293 335
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index ee6dc0274..f3afbec48 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -58,11 +58,17 @@ struct TestState
58 * 58 *
59 */ 59 */
60 char *cfgname; 60 char *cfgname;
61
62 /**
63 * The complete topology information.
64 */
65 struct GNUNET_TESTING_NetjailTopology *topology;
61}; 66};
62 67
63static struct GNUNET_TESTING_Command block_send; 68static struct GNUNET_TESTING_Command block_send;
64 69
65static struct GNUNET_TESTING_Command connect_peers; 70static struct GNUNET_TESTING_Command connect_peers;
71
66static struct GNUNET_TESTING_Command local_prepared; 72static struct GNUNET_TESTING_Command local_prepared;
67 73
68 74
@@ -110,7 +116,8 @@ all_peers_started ()
110 116
111 GNUNET_TESTING_get_trait_async_context (&block_send, 117 GNUNET_TESTING_get_trait_async_context (&block_send,
112 &ac); 118 &ac);
113 if ((NULL == ac) || (NULL == ac->cont)) 119 GNUNET_assert (NULL != ac);
120 if ((NULL == ac->cont))
114 GNUNET_TESTING_async_fail (ac); 121 GNUNET_TESTING_async_fail (ac);
115 else 122 else
116 GNUNET_TESTING_async_finish (ac); 123 GNUNET_TESTING_async_finish (ac);
@@ -142,6 +149,7 @@ handle_result (void *cls,
142 149
143 GNUNET_free (ts->testdir); 150 GNUNET_free (ts->testdir);
144 GNUNET_free (ts->cfgname); 151 GNUNET_free (ts->cfgname);
152 GNUNET_TESTING_free_topology (ts->topology);
145 GNUNET_free (ts); 153 GNUNET_free (ts);
146} 154}
147 155
@@ -174,10 +182,11 @@ static void
174all_local_tests_prepared () 182all_local_tests_prepared ()
175{ 183{
176 struct LocalPreparedState *lfs; 184 struct LocalPreparedState *lfs;
185
177 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, 186 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
178 &lfs); 187 &lfs);
179 188 GNUNET_assert (NULL != &lfs->ac);
180 if ((NULL == &lfs->ac) || (NULL == lfs->ac.cont)) 189 if (NULL == lfs->ac.cont)
181 GNUNET_TESTING_async_fail (&lfs->ac); 190 GNUNET_TESTING_async_fail (&lfs->ac);
182 else 191 else
183 GNUNET_TESTING_async_finish (&lfs->ac); 192 GNUNET_TESTING_async_finish (&lfs->ac);
@@ -210,6 +219,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
210 struct GNUNET_TESTING_NetjailTopology *topology = 219 struct GNUNET_TESTING_NetjailTopology *topology =
211 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); 220 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG);
212 221
222 ts->topology = topology;
223
213 sscanf (m, "%u", &m_int); 224 sscanf (m, "%u", &m_int);
214 sscanf (n, "%u", &n_int); 225 sscanf (n, "%u", &n_int);
215 sscanf (local_m, "%u", &local_m_int); 226 sscanf (local_m, "%u", &local_m_int);
diff --git a/src/transport/test_transport_simple_send.sh b/src/transport/test_transport_simple_send.sh
index 2dd269fcc..7e3ee032f 100755
--- a/src/transport/test_transport_simple_send.sh
+++ b/src/transport/test_transport_simple_send.sh
@@ -1,2 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf" 2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
3 exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf"
4else
5 echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
6 exit 78
7fi
diff --git a/src/transport/test_transport_simple_send_topo.conf b/src/transport/test_transport_simple_send_topo.conf
index f878f9719..2c16201f5 100644
--- a/src/transport/test_transport_simple_send_topo.conf
+++ b/src/transport/test_transport_simple_send_topo.conf
@@ -1,4 +1,6 @@
1M:2 1M:2
2N:1 2N:1
3X:0 3X:0
4T:libgnunet_test_transport_plugin_cmd_simple_send \ No newline at end of file 4T:libgnunet_test_transport_plugin_cmd_simple_send
5P:1:1|{connect:{P:1:2:tcp}}
6P:1:2|{connect:{P:1:1:tcp}} \ No newline at end of file
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh
index 0c37be469..9c0b11fad 100755
--- a/src/transport/test_transport_udp_backchannel.sh
+++ b/src/transport/test_transport_udp_backchannel.sh
@@ -1,4 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
2#exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" 3#exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
3exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" 4exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
4# exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" 5# exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
6else
7 echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
8 exit 78
9fi
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index d6bb46f7d..10729990d 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -63,12 +63,6 @@ struct ConnectPeersState
63 const char *start_peer_label; 63 const char *start_peer_label;
64 64
65 /** 65 /**
66 * The peer identity of this peer.
67 *
68 */
69 struct GNUNET_PeerIdentity *id;
70
71 /**
72 * The topology of the test setup. 66 * The topology of the test setup.
73 */ 67 */
74 struct GNUNET_TESTING_NetjailTopology *topology; 68 struct GNUNET_TESTING_NetjailTopology *topology;
@@ -222,16 +216,19 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
222 * Create command. 216 * Create command.
223 * 217 *
224 * @param label name for command. 218 * @param label name for command.
225 * @param m The number of the local node of the actual network namespace.
226 * @param n The number of the actual namespace.
227 * @param num Number globally identifying the node.
228 * @param start_peer_label Label of the cmd to start a peer. 219 * @param start_peer_label Label of the cmd to start a peer.
220 * @param start_peer_label Label of the cmd which started the test system.
221 * @param num Number globally identifying the node.
222 * @param The topology for the test setup.
229 * @return command. 223 * @return command.
230 */ 224 */
231struct GNUNET_TESTING_Command 225struct GNUNET_TESTING_Command
232GNUNET_TRANSPORT_cmd_send_simple (const char *label, 226GNUNET_TRANSPORT_cmd_send_simple (const char *label,
233 const char *start_peer_label, 227 const char *start_peer_label,
234 uint32_t num); 228 const char *create_label,
229 uint32_t num,
230 struct GNUNET_TESTING_NetjailTopology *
231 topology);
235 232
236 233
237/** 234/**
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 017d1bca3..2eb1b0914 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -72,6 +72,10 @@ connect_peers_run (void *cls,
72 72
73 cps->tl_system = tl_system; 73 cps->tl_system = tl_system;
74 74
75 LOG (GNUNET_ERROR_TYPE_DEBUG,
76 "cps->num: %u \n",
77 cps->num);
78
75 cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num, 79 cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num,
76 cps->topology); 80 cps->topology);
77 81
@@ -84,28 +88,15 @@ connect_peers_run (void *cls,
84 pos_prefix = 88 pos_prefix =
85 pos_prefix->next) 89 pos_prefix->next)
86 { 90 {
87
88 LOG (GNUNET_ERROR_TYPE_ERROR,
89 "prefix: %s\n",
90 pos_prefix->address_prefix);
91
92 addr = GNUNET_TESTING_get_address (pos_connection, 91 addr = GNUNET_TESTING_get_address (pos_connection,
93 pos_prefix->address_prefix); 92 pos_prefix->address_prefix);
94
95 peer = GNUNET_TESTING_get_pub_key (num, tl_system); 93 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
96
97 LOG (GNUNET_ERROR_TYPE_ERROR,
98 "num: %u pub_key %s addr: %s\n",
99 num,
100 GNUNET_CRYPTO_eddsa_public_key_to_string (&(peer->public_key)),
101 addr);
102
103 cps->id = peer;
104
105 GNUNET_TRANSPORT_application_validate (ah, 94 GNUNET_TRANSPORT_application_validate (ah,
106 peer, 95 peer,
107 nt, 96 nt,
108 addr); 97 addr);
98 GNUNET_free (peer);
99 GNUNET_free (addr);
109 } 100 }
110 } 101 }
111 cps->con_num = con_num; 102 cps->con_num = con_num;
@@ -136,6 +127,7 @@ notify_connect (void *cls,
136 if (0 == GNUNET_memcmp (peer, 127 if (0 == GNUNET_memcmp (peer,
137 peer_connection)) 128 peer_connection))
138 con_num++; 129 con_num++;
130 GNUNET_free (peer_connection);
139 } 131 }
140 132
141 133
@@ -156,7 +148,6 @@ connect_peers_cleanup (void *cls)
156{ 148{
157 struct ConnectPeersState *cps = cls; 149 struct ConnectPeersState *cps = cls;
158 150
159 GNUNET_free (cps->id);
160 GNUNET_free (cps); 151 GNUNET_free (cps);
161} 152}
162 153
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 0631f7051..9c34c50d7 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -46,21 +46,18 @@ struct SendSimpleState
46 * 46 *
47 */ 47 */
48 const char *start_peer_label; 48 const char *start_peer_label;
49};
50 49
50 /**
51 * Label of the cmd which started the test system.
52 *
53 */
54 const char *create_label;
51 55
52/** 56 /**
53 * Trait function of this cmd does nothing. 57 * The topology we get the connected nodes from.
54 * 58 */
55 */ 59 struct GNUNET_TESTING_NetjailTopology *topology;
56static int 60};
57send_simple_traits (void *cls,
58 const void **ret,
59 const char *trait,
60 unsigned int index)
61{
62 return GNUNET_OK;
63}
64 61
65 62
66/** 63/**
@@ -77,7 +74,7 @@ send_simple_cleanup (void *cls)
77 74
78 75
79/** 76/**
80 * The run method of this cmd will send a simple message to the connected peer. 77 * The run method of this cmd will send a simple message to the connected peers.
81 * 78 *
82 */ 79 */
83static void 80static void
@@ -92,31 +89,54 @@ send_simple_run (void *cls,
92 const struct GNUNET_TESTING_Command *peer1_cmd; 89 const struct GNUNET_TESTING_Command *peer1_cmd;
93 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); 90 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
94 struct GNUNET_HashCode hc; 91 struct GNUNET_HashCode hc;
95 int node_number; 92 struct GNUNET_TESTING_NodeConnection *node_connections_head;
93 struct GNUNET_PeerIdentity *peer;
94 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
95 uint32_t num;
96 struct GNUNET_TESTING_NodeConnection *pos_connection;
97 const struct GNUNET_TESTING_Command *system_cmd;
98 struct GNUNET_TESTING_System *tl_system;
96 99
97 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, 100 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
98 sss->start_peer_label); 101 sss->start_peer_label);
99 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, 102 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
100 &connected_peers_map); 103 &connected_peers_map);
101 104
102 node_number = 1; 105 system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
103 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); 106 sss->create_label);
104 memcpy (key, 107 GNUNET_TESTING_get_trait_test_system (system_cmd,
105 &hc, 108 &tl_system);
106 sizeof (*key)); 109
107 110 node_connections_head = GNUNET_TESTING_get_connections (sss->num,
108 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, 111 sss->topology);
109 key); 112
110 113 for (int i = 0; i < 1; i++)
111 env = GNUNET_MQ_msg_extra (test, 114 {
112 2600 - sizeof(*test), 115 for (pos_connection = node_connections_head; NULL != pos_connection;
113 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE); 116 pos_connection = pos_connection->next)
114 test->num = htonl (sss->num); 117 {
115 memset (&test[1], 118 num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology);
116 sss->num, 119 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
117 2600 - sizeof(*test)); 120 public_key = peer->public_key;
118 GNUNET_MQ_send (mq, 121 GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
119 env); 122
123 memcpy (key,
124 &hc,
125 sizeof (*key));
126 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
127 key);
128 env = GNUNET_MQ_msg_extra (test,
129 1000 - sizeof(*test),
130 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
131 test->num = htonl (sss->num);
132 memset (&test[1],
133 sss->num,
134 1000 - sizeof(*test));
135 GNUNET_MQ_send (mq,
136 env);
137 }
138 }
139
120 GNUNET_free (key); 140 GNUNET_free (key);
121 141
122} 142}
@@ -126,31 +146,34 @@ send_simple_run (void *cls,
126 * Create command. 146 * Create command.
127 * 147 *
128 * @param label name for command. 148 * @param label name for command.
129 * @param m The number of the local node of the actual network namespace.
130 * @param n The number of the actual namespace.
131 * @param num Number globally identifying the node.
132 * @param start_peer_label Label of the cmd to start a peer. 149 * @param start_peer_label Label of the cmd to start a peer.
150 * @param start_peer_label Label of the cmd which started the test system.
151 * @param num Number globally identifying the node.
152 * @param The topology for the test setup.
133 * @return command. 153 * @return command.
134 */ 154 */
135struct GNUNET_TESTING_Command 155struct GNUNET_TESTING_Command
136GNUNET_TRANSPORT_cmd_send_simple (const char *label, 156GNUNET_TRANSPORT_cmd_send_simple (const char *label,
137 const char *start_peer_label, 157 const char *start_peer_label,
138 uint32_t num) 158 const char *create_label,
159 uint32_t num,
160 struct GNUNET_TESTING_NetjailTopology *
161 topology)
139{ 162{
140 struct SendSimpleState *sss; 163 struct SendSimpleState *sss;
141 164
142 sss = GNUNET_new (struct SendSimpleState); 165 sss = GNUNET_new (struct SendSimpleState);
143 sss->num = num; 166 sss->num = num;
144 sss->start_peer_label = start_peer_label; 167 sss->start_peer_label = start_peer_label;
145 { 168 sss->create_label = create_label;
146 struct GNUNET_TESTING_Command cmd = { 169 sss->topology = topology;
147 .cls = sss, 170
148 .label = label, 171 struct GNUNET_TESTING_Command cmd = {
149 .run = &send_simple_run, 172 .cls = sss,
150 .cleanup = &send_simple_cleanup, 173 .label = label,
151 .traits = &send_simple_traits 174 .run = &send_simple_run,
152 }; 175 .cleanup = &send_simple_cleanup
153 176 };
154 return cmd; 177
155 } 178 return cmd;
156} 179}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index dc19f10eb..a026d48cc 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -235,6 +235,10 @@ start_peer_run (void *cls,
235 235
236 sps->tl_system = tl_system; 236 sps->tl_system = tl_system;
237 237
238 LOG (GNUNET_ERROR_TYPE_ERROR,
239 "Creating testing library with key number %u\n",
240 sps->no);
241
238 if (GNUNET_SYSERR == 242 if (GNUNET_SYSERR ==
239 GNUNET_TESTING_configuration_create (tl_system, 243 GNUNET_TESTING_configuration_create (tl_system,
240 sps->cfg)) 244 sps->cfg))
@@ -255,9 +259,10 @@ start_peer_run (void *cls,
255 if (NULL == sps->peer) 259 if (NULL == sps->peer)
256 { 260 {
257 LOG (GNUNET_ERROR_TYPE_ERROR, 261 LOG (GNUNET_ERROR_TYPE_ERROR,
258 "Testing library failed to create unique configuration based on `%s': `%s'\n", 262 "Testing library failed to create unique configuration based on `%s': `%s' with key number %u\n",
259 sps->cfgname, 263 sps->cfgname,
260 emsg); 264 emsg,
265 sps->no);
261 GNUNET_free (emsg); 266 GNUNET_free (emsg);
262 GNUNET_TESTING_interpreter_fail (is); 267 GNUNET_TESTING_interpreter_fail (is);
263 return; 268 return;
@@ -337,6 +342,11 @@ start_peer_run (void *cls,
337 return; 342 return;
338 } 343 }
339 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); 344 sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
345 GNUNET_free (home);
346 GNUNET_free (transport_unix_path);
347 GNUNET_free (tcp_communicator_unix_path);
348 GNUNET_free (udp_communicator_unix_path);
349 GNUNET_free (bindto);
340} 350}
341 351
342 352