diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 78 |
1 files changed, 53 insertions, 25 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 4f0b8eaa9..95651830f 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1319,7 +1319,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, | |||
1319 | peer->nports = nports; | 1319 | peer->nports = nports; |
1320 | return peer; | 1320 | return peer; |
1321 | 1321 | ||
1322 | err_ret: | 1322 | err_ret: |
1323 | GNUNET_free (ss_instances); | 1323 | GNUNET_free (ss_instances); |
1324 | GNUNET_free (ports); | 1324 | GNUNET_free (ports); |
1325 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_); | 1325 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_); |
@@ -2118,7 +2118,7 @@ get_node_info (unsigned int num, | |||
2118 | unsigned int node_m; | 2118 | unsigned int node_m; |
2119 | struct GNUNET_TESTING_NetjailNode *node; | 2119 | struct GNUNET_TESTING_NetjailNode *node; |
2120 | struct GNUNET_TESTING_NetjailNamespace *namespace; | 2120 | struct GNUNET_TESTING_NetjailNamespace *namespace; |
2121 | struct GNUNET_TESTING_NodeConnection *node_connections; | 2121 | struct GNUNET_TESTING_NodeConnection *node_connections = NULL; |
2122 | 2122 | ||
2123 | log_topo (topology); | 2123 | log_topo (topology); |
2124 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2124 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
@@ -2135,7 +2135,10 @@ get_node_info (unsigned int num, | |||
2135 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | 2135 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, |
2136 | hkey); | 2136 | hkey); |
2137 | if (NULL != node) | 2137 | if (NULL != node) |
2138 | node_connections = node->node_connections_head; | 2138 | { |
2139 | *node_ex = node; | ||
2140 | *node_connections_ex = node->node_connections_head; | ||
2141 | } | ||
2139 | } | 2142 | } |
2140 | else | 2143 | else |
2141 | { | 2144 | { |
@@ -2248,8 +2251,15 @@ free_nodes_cb (void *cls, | |||
2248 | { | 2251 | { |
2249 | while (NULL != (pos_prefix = pos_connection->address_prefixes_head)) | 2252 | while (NULL != (pos_prefix = pos_connection->address_prefixes_head)) |
2250 | { | 2253 | { |
2254 | GNUNET_CONTAINER_DLL_remove (pos_connection->address_prefixes_head, | ||
2255 | pos_connection->address_prefixes_tail, | ||
2256 | pos_prefix); | ||
2251 | GNUNET_free (pos_prefix->address_prefix); | 2257 | GNUNET_free (pos_prefix->address_prefix); |
2258 | GNUNET_free (pos_prefix); | ||
2252 | } | 2259 | } |
2260 | GNUNET_CONTAINER_DLL_remove (node->node_connections_head, | ||
2261 | node->node_connections_tail, | ||
2262 | pos_connection); | ||
2253 | GNUNET_free (pos_connection); | 2263 | GNUNET_free (pos_connection); |
2254 | } | 2264 | } |
2255 | 2265 | ||
@@ -2398,9 +2408,11 @@ GNUNET_TESTING_get_additional_connects (unsigned int num, | |||
2398 | get_node_info (num, topology, &node, &namespace, &node_connections); | 2408 | get_node_info (num, topology, &node, &namespace, &node_connections); |
2399 | 2409 | ||
2400 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2410 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2401 | "node additional_connects: %u %p\n", | 2411 | "node additional_connects for node %p\n", |
2402 | node->additional_connects, | ||
2403 | node); | 2412 | node); |
2413 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2414 | "node additional_connects: %u\n", | ||
2415 | node->additional_connects); | ||
2404 | 2416 | ||
2405 | return node->additional_connects; | 2417 | return node->additional_connects; |
2406 | } | 2418 | } |
@@ -2409,28 +2421,47 @@ GNUNET_TESTING_get_additional_connects (unsigned int num, | |||
2409 | /** | 2421 | /** |
2410 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. | 2422 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. |
2411 | * | 2423 | * |
2412 | * @param rv The result of the local test as GNUNET_GenericReturnValue. | ||
2413 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. | 2424 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. |
2414 | */ | 2425 | */ |
2415 | struct GNUNET_MessageHeader * | 2426 | struct GNUNET_MessageHeader * |
2416 | GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv) | 2427 | GNUNET_TESTING_send_local_test_finished_msg () |
2417 | { | 2428 | { |
2418 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | 2429 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; |
2419 | size_t msg_length; | 2430 | size_t msg_length; |
2420 | 2431 | ||
2421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2422 | "Local test exits with status %d\n", | ||
2423 | rv); | ||
2424 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); | 2432 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); |
2425 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); | 2433 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); |
2426 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | 2434 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); |
2427 | reply->header.size = htons ((uint16_t) msg_length); | 2435 | reply->header.size = htons ((uint16_t) msg_length); |
2428 | reply->result = htons (rv); | ||
2429 | 2436 | ||
2430 | return (struct GNUNET_MessageHeader *) reply; | 2437 | return (struct GNUNET_MessageHeader *) reply; |
2431 | } | 2438 | } |
2432 | 2439 | ||
2433 | 2440 | ||
2441 | static void | ||
2442 | parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token) | ||
2443 | { | ||
2444 | char *ac_value; | ||
2445 | |||
2446 | ac_value = get_value ("AC", token); | ||
2447 | if (NULL != ac_value) | ||
2448 | { | ||
2449 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2450 | "ac value: %s\n", | ||
2451 | ac_value); | ||
2452 | sscanf (ac_value, "%u", &p_node->additional_connects); | ||
2453 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2454 | "AC %u\n", | ||
2455 | p_node->additional_connects); | ||
2456 | } | ||
2457 | else | ||
2458 | { | ||
2459 | p_node->additional_connects = 0; | ||
2460 | } | ||
2461 | GNUNET_free (ac_value); | ||
2462 | } | ||
2463 | |||
2464 | |||
2434 | /** | 2465 | /** |
2435 | * Parse the topology data. | 2466 | * Parse the topology data. |
2436 | * | 2467 | * |
@@ -2446,7 +2477,6 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2446 | char *rest = NULL; | 2477 | char *rest = NULL; |
2447 | char *value = NULL; | 2478 | char *value = NULL; |
2448 | char *value2; | 2479 | char *value2; |
2449 | char *ac_value; | ||
2450 | int ret; | 2480 | int ret; |
2451 | struct GNUNET_TESTING_NetjailTopology *topo; | 2481 | struct GNUNET_TESTING_NetjailTopology *topo; |
2452 | struct GNUNET_TESTING_NetjailRouter *router; | 2482 | struct GNUNET_TESTING_NetjailRouter *router; |
@@ -2555,6 +2585,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2555 | "value: %s\n", | 2585 | "value: %s\n", |
2556 | value); | 2586 | value); |
2557 | k_node->plugin = value; | 2587 | k_node->plugin = value; |
2588 | parse_ac (k_node, token); | ||
2558 | node_connections (token, k_node); | 2589 | node_connections (token, k_node); |
2559 | GNUNET_free (value); | 2590 | GNUNET_free (value); |
2560 | } | 2591 | } |
@@ -2617,6 +2648,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2617 | { | 2648 | { |
2618 | struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct | 2649 | struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct |
2619 | GNUNET_TESTING_NetjailNode); | 2650 | GNUNET_TESTING_NetjailNode); |
2651 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
2620 | 2652 | ||
2621 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2653 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2622 | "Get first Value for P.\n"); | 2654 | "Get first Value for P.\n"); |
@@ -2672,26 +2704,22 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2672 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2704 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2673 | "Get value for key plugin on P.\n"); | 2705 | "Get value for key plugin on P.\n"); |
2674 | value = get_value ("plugin", token); | 2706 | value = get_value ("plugin", token); |
2675 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2707 | if (NULL != value) |
2676 | "plugin: %s\n", | 2708 | { |
2677 | value); | 2709 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2678 | memcpy (p_node->plugin, value, sizeof (*value)); | 2710 | "plugin: %s\n", |
2711 | value); | ||
2712 | p_node->plugin = GNUNET_malloc (sizeof(*value)); | ||
2713 | memcpy (p_node->plugin, value, sizeof (*value)); | ||
2714 | } | ||
2679 | GNUNET_free (value); | 2715 | GNUNET_free (value); |
2680 | p_node->node_n = out; | 2716 | p_node->node_n = out; |
2681 | p_node->namespace_n = namespace->namespace_n; | 2717 | p_node->namespace_n = namespace->namespace_n; |
2682 | } | 2718 | } |
2683 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2719 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2684 | "Get AC Value for P.\n"); | 2720 | "Get AC Value for P.\n"); |
2685 | ac_value = get_value ("AC", token); | 2721 | parse_ac (p_node, token); |
2686 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2687 | "ac value: %s\n", | ||
2688 | ac_value); | ||
2689 | sscanf (ac_value, "%u", &p_node->additional_connects); | ||
2690 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2691 | "P:AC %u\n", | ||
2692 | p_node->additional_connects); | ||
2693 | node_connections (token, p_node); | 2722 | node_connections (token, p_node); |
2694 | GNUNET_free (ac_value); | ||
2695 | } | 2723 | } |
2696 | token = strtok_r (NULL, "\n", &rest); | 2724 | token = strtok_r (NULL, "\n", &rest); |
2697 | if (NULL != token) | 2725 | if (NULL != token) |