diff options
author | t3sserakt <t3ss@posteo.de> | 2021-10-28 16:13:47 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-10-28 16:13:47 +0200 |
commit | 6fb788ca2ec44837ea10a36be7fd0030fb08955b (patch) | |
tree | cba4a385aa8ab914d02db9a702f6c6230aa89a2a /src/testing | |
parent | 1609d627e509043a946f611d7589105cfae2364d (diff) | |
download | gnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.tar.gz gnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.zip |
- fixed coverity issues
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing.c | 140 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_netjail_start_testsystem.c | 109 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop_testsystem.c | 24 |
3 files changed, 197 insertions, 76 deletions
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 | |||
2056 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | 2062 | log_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 | ||
2187 | int | ||
2188 | free_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 | |||
2218 | int | ||
2219 | free_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 | */ | ||
2239 | void | ||
2240 | GNUNET_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 | |||
67 | struct NetJailState | 67 | struct 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 | */ |
562 | static void | 617 | static void |
563 | start_helper (struct NetJailState *ns, struct | 618 | start_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 @@ | |||
35 | struct StopHelperState | 35 | struct 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 | |||
63 | static void | 68 | static void |
64 | stop_testing_system_cleanup (void *cls) | 69 | stop_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 | */ | ||
74 | static int | ||
75 | stop_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; |