diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/gnunet-cmds-helper.c | 2 | ||||
-rw-r--r-- | src/testing/testing.c | 58 |
2 files changed, 34 insertions, 26 deletions
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index be58f6f6a..8114d156d 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -606,7 +606,7 @@ main (int argc, char **argv) | |||
606 | int i; | 606 | int i; |
607 | size_t topology_data_length = 0; | 607 | size_t topology_data_length = 0; |
608 | unsigned int read_file; | 608 | unsigned int read_file; |
609 | char cr[1] = "\n"; | 609 | char cr[2] = "\n\0"; |
610 | 610 | ||
611 | GNUNET_log_setup ("gnunet-cmds-helper", | 611 | GNUNET_log_setup ("gnunet-cmds-helper", |
612 | "DEBUG", | 612 | "DEBUG", |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 22375bc98..aa8dd339c 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -2102,7 +2102,6 @@ get_node_info (unsigned int num, | |||
2102 | topology->nodes_x, | 2102 | topology->nodes_x, |
2103 | topology->nodes_m, | 2103 | topology->nodes_m, |
2104 | namespace_n); | 2104 | namespace_n); |
2105 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
2106 | GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); | 2105 | GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); |
2107 | memcpy (hkey, | 2106 | memcpy (hkey, |
2108 | &hc, | 2107 | &hc, |
@@ -2131,8 +2130,8 @@ get_node_info (unsigned int num, | |||
2131 | *namespace_ex = namespace; | 2130 | *namespace_ex = namespace; |
2132 | *node_connections_ex = node_connections; | 2131 | *node_connections_ex = node_connections; |
2133 | } | 2132 | } |
2134 | GNUNET_free (hkey); | ||
2135 | } | 2133 | } |
2134 | GNUNET_free (hkey); | ||
2136 | } | 2135 | } |
2137 | 2136 | ||
2138 | 2137 | ||
@@ -2382,6 +2381,7 @@ static void | |||
2382 | parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token) | 2381 | parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token) |
2383 | { | 2382 | { |
2384 | char *ac_value; | 2383 | char *ac_value; |
2384 | int ret; | ||
2385 | 2385 | ||
2386 | ac_value = get_value ("AC", token); | 2386 | ac_value = get_value ("AC", token); |
2387 | if (NULL != ac_value) | 2387 | if (NULL != ac_value) |
@@ -2389,7 +2389,13 @@ parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token) | |||
2389 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2389 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2390 | "ac value: %s\n", | 2390 | "ac value: %s\n", |
2391 | ac_value); | 2391 | ac_value); |
2392 | sscanf (ac_value, "%u", &p_node->additional_connects); | 2392 | errno = 0; |
2393 | ret = sscanf (ac_value, "%u", &p_node->additional_connects); | ||
2394 | if (errno != 0) | ||
2395 | { | ||
2396 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
2397 | } | ||
2398 | GNUNET_assert (0 < ret); | ||
2393 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2399 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2394 | "AC %u\n", | 2400 | "AC %u\n", |
2395 | p_node->additional_connects); | 2401 | p_node->additional_connects); |
@@ -2421,7 +2427,6 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2421 | struct GNUNET_TESTING_NetjailTopology *topo; | 2427 | struct GNUNET_TESTING_NetjailTopology *topo; |
2422 | struct GNUNET_TESTING_NetjailRouter *router; | 2428 | struct GNUNET_TESTING_NetjailRouter *router; |
2423 | struct GNUNET_TESTING_NetjailNamespace *namespace; | 2429 | struct GNUNET_TESTING_NetjailNamespace *namespace; |
2424 | struct GNUNET_ShortHashCode *hkey; | ||
2425 | struct GNUNET_HashCode hc; | 2430 | struct GNUNET_HashCode hc; |
2426 | 2431 | ||
2427 | token = strtok_r (data, "\n", &rest); | 2432 | token = strtok_r (data, "\n", &rest); |
@@ -2492,7 +2497,8 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2492 | } | 2497 | } |
2493 | else if (0 == strcmp (key, "K")) | 2498 | else if (0 == strcmp (key, "K")) |
2494 | { | 2499 | { |
2495 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2500 | struct GNUNET_ShortHashCode *hkey_k = GNUNET_new (struct |
2501 | GNUNET_ShortHashCode); | ||
2496 | struct GNUNET_TESTING_NetjailNode *k_node = GNUNET_new (struct | 2502 | struct GNUNET_TESTING_NetjailNode *k_node = GNUNET_new (struct |
2497 | GNUNET_TESTING_NetjailNode); | 2503 | GNUNET_TESTING_NetjailNode); |
2498 | 2504 | ||
@@ -2504,18 +2510,18 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2504 | out); | 2510 | out); |
2505 | k_node->node_n = out; | 2511 | k_node->node_n = out; |
2506 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); | 2512 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); |
2507 | memcpy (hkey, | 2513 | memcpy (hkey_k, |
2508 | &hc, | 2514 | &hc, |
2509 | sizeof (*hkey)); | 2515 | sizeof (*hkey_k)); |
2510 | k_node->is_global = GNUNET_YES; | 2516 | k_node->is_global = GNUNET_YES; |
2511 | 2517 | ||
2512 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( | 2518 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( |
2513 | topo->map_globals, | 2519 | topo->map_globals, |
2514 | hkey)) | 2520 | hkey_k)) |
2515 | GNUNET_break (0); | 2521 | GNUNET_break (0); |
2516 | else | 2522 | else |
2517 | GNUNET_CONTAINER_multishortmap_put (topo->map_globals, | 2523 | GNUNET_CONTAINER_multishortmap_put (topo->map_globals, |
2518 | hkey, | 2524 | hkey_k, |
2519 | k_node, | 2525 | k_node, |
2520 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2526 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2521 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2527 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2531,7 +2537,8 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2531 | } | 2537 | } |
2532 | else if (0 == strcmp (key, "R")) | 2538 | else if (0 == strcmp (key, "R")) |
2533 | { | 2539 | { |
2534 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2540 | struct GNUNET_ShortHashCode *hkey_r = GNUNET_new (struct |
2541 | GNUNET_ShortHashCode); | ||
2535 | router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); | 2542 | router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); |
2536 | 2543 | ||
2537 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2544 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2541,9 +2548,9 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2541 | "R: %u\n", | 2548 | "R: %u\n", |
2542 | out); | 2549 | out); |
2543 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); | 2550 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); |
2544 | memcpy (hkey, | 2551 | memcpy (hkey_r, |
2545 | &hc, | 2552 | &hc, |
2546 | sizeof (*hkey)); | 2553 | sizeof (*hkey_r)); |
2547 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2554 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2548 | "Get value for key tcp_port on R.\n"); | 2555 | "Get value for key tcp_port on R.\n"); |
2549 | value = get_value ("tcp_port", token); | 2556 | value = get_value ("tcp_port", token); |
@@ -2566,10 +2573,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2566 | GNUNET_free (value2); | 2573 | GNUNET_free (value2); |
2567 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( | 2574 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( |
2568 | topo->map_namespaces, | 2575 | topo->map_namespaces, |
2569 | hkey)) | 2576 | hkey_r)) |
2570 | { | 2577 | { |
2571 | namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces, | 2578 | namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces, |
2572 | hkey); | 2579 | hkey_r); |
2573 | } | 2580 | } |
2574 | else | 2581 | else |
2575 | { | 2582 | { |
@@ -2577,7 +2584,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2577 | namespace->namespace_n = out; | 2584 | namespace->namespace_n = out; |
2578 | namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | 2585 | namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); |
2579 | GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces, | 2586 | GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces, |
2580 | hkey, | 2587 | hkey_r, |
2581 | namespace, | 2588 | namespace, |
2582 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2589 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2583 | } | 2590 | } |
@@ -2588,7 +2595,8 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2588 | { | 2595 | { |
2589 | struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct | 2596 | struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct |
2590 | GNUNET_TESTING_NetjailNode); | 2597 | GNUNET_TESTING_NetjailNode); |
2591 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2598 | struct GNUNET_ShortHashCode *hkey_p = GNUNET_new (struct |
2599 | GNUNET_ShortHashCode); | ||
2592 | 2600 | ||
2593 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2601 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2594 | "Get first Value for P.\n"); | 2602 | "Get first Value for P.\n"); |
@@ -2597,16 +2605,16 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2597 | "P: %u\n", | 2605 | "P: %u\n", |
2598 | out); | 2606 | out); |
2599 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); | 2607 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); |
2600 | memcpy (hkey, | 2608 | memcpy (hkey_p, |
2601 | &hc, | 2609 | &hc, |
2602 | sizeof (*hkey)); | 2610 | sizeof (*hkey_p)); |
2603 | 2611 | ||
2604 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( | 2612 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( |
2605 | topo->map_namespaces, | 2613 | topo->map_namespaces, |
2606 | hkey)) | 2614 | hkey_p)) |
2607 | { | 2615 | { |
2608 | namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces, | 2616 | namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces, |
2609 | hkey); | 2617 | hkey_p); |
2610 | } | 2618 | } |
2611 | else | 2619 | else |
2612 | { | 2620 | { |
@@ -2614,7 +2622,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2614 | namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | 2622 | namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); |
2615 | namespace->namespace_n = out; | 2623 | namespace->namespace_n = out; |
2616 | GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces, | 2624 | GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces, |
2617 | hkey, | 2625 | hkey_p, |
2618 | namespace, | 2626 | namespace, |
2619 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2627 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2620 | } | 2628 | } |
@@ -2625,12 +2633,12 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2625 | "P: %u\n", | 2633 | "P: %u\n", |
2626 | out); | 2634 | out); |
2627 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); | 2635 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); |
2628 | memcpy (hkey, | 2636 | memcpy (hkey_p, |
2629 | &hc, | 2637 | &hc, |
2630 | sizeof (*hkey)); | 2638 | sizeof (*hkey_p)); |
2631 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( | 2639 | if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( |
2632 | namespace->nodes, | 2640 | namespace->nodes, |
2633 | hkey)) | 2641 | hkey_p)) |
2634 | { | 2642 | { |
2635 | GNUNET_break (0); | 2643 | GNUNET_break (0); |
2636 | } | 2644 | } |
@@ -2638,7 +2646,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2638 | { | 2646 | { |
2639 | 2647 | ||
2640 | GNUNET_CONTAINER_multishortmap_put (namespace->nodes, | 2648 | GNUNET_CONTAINER_multishortmap_put (namespace->nodes, |
2641 | hkey, | 2649 | hkey_p, |
2642 | p_node, | 2650 | p_node, |
2643 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2651 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2644 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2652 | LOG (GNUNET_ERROR_TYPE_DEBUG, |