diff options
author | t3sserakt <t3ss@posteo.de> | 2021-10-15 21:02:03 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-10-15 21:02:03 +0200 |
commit | 513f23e74650db9408267e82ef8bcb8f770d1015 (patch) | |
tree | 312db7072dc444e9d1e6a13000b79482eb14de82 /src/testing/testing_api_cmd_netjail_stop_testsystem.c | |
parent | d190d23831dae1a77075557f2ff6e0c713d747d5 (diff) | |
parent | d64ac269856744b9bab170964e1d6f36896ecc55 (diff) | |
download | gnunet-513f23e74650db9408267e82ef8bcb8f770d1015.tar.gz gnunet-513f23e74650db9408267e82ef8bcb8f770d1015.zip |
Merge branch 'master' into dev/t3ss/tng
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop_testsystem.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop_testsystem.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c index 0ae82a26a..d3754153d 100644 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c | |||
@@ -42,9 +42,15 @@ struct StopHelperState | |||
42 | */ | 42 | */ |
43 | struct GNUNET_HELPER_Handle **helper; | 43 | struct GNUNET_HELPER_Handle **helper; |
44 | 44 | ||
45 | char *local_m; | 45 | unsigned int local_m; |
46 | 46 | ||
47 | char *global_n; | 47 | unsigned int global_n; |
48 | |||
49 | /** | ||
50 | * Number of global known nodes. | ||
51 | * | ||
52 | */ | ||
53 | unsigned int known; | ||
48 | }; | 54 | }; |
49 | 55 | ||
50 | 56 | ||
@@ -55,8 +61,7 @@ struct StopHelperState | |||
55 | * @param cmd current CMD being cleaned up. | 61 | * @param cmd current CMD being cleaned up. |
56 | */ | 62 | */ |
57 | static void | 63 | static void |
58 | stop_testing_system_cleanup (void *cls, | 64 | stop_testing_system_cleanup (void *cls) |
59 | const struct GNUNET_TESTING_Command *cmd) | ||
60 | { | 65 | { |
61 | 66 | ||
62 | } | 67 | } |
@@ -80,28 +85,40 @@ stop_testing_system_traits (void *cls, | |||
80 | * This function stops the helper process for each node. | 85 | * This function stops the helper process for each node. |
81 | * | 86 | * |
82 | * @param cls closure. | 87 | * @param cls closure. |
83 | * @param cmd CMD being run. | ||
84 | * @param is interpreter state. | 88 | * @param is interpreter state. |
85 | */ | 89 | */ |
86 | static void | 90 | static void |
87 | stop_testing_system_run (void *cls, | 91 | stop_testing_system_run (void *cls, |
88 | const struct GNUNET_TESTING_Command *cmd, | ||
89 | struct GNUNET_TESTING_Interpreter *is) | 92 | struct GNUNET_TESTING_Interpreter *is) |
90 | { | 93 | { |
91 | struct StopHelperState *shs = cls; | 94 | struct StopHelperState *shs = cls; |
92 | struct GNUNET_HELPER_Handle **helper; | 95 | struct GNUNET_HELPER_Handle **helper; |
93 | const struct GNUNET_TESTING_Command *start_helper_cmd; | 96 | const struct GNUNET_TESTING_Command *start_helper_cmd; |
94 | 97 | ||
95 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( | 98 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (NULL, |
96 | shs->helper_start_label); | 99 | shs-> |
100 | helper_start_label); | ||
97 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | 101 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, |
98 | &helper); | 102 | &helper); |
99 | 103 | ||
100 | for (int i = 1; i <= atoi (shs->global_n); i++) | 104 | for (int i = 1; i <= shs->known; i++) |
105 | { | ||
106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
107 | "i: %u\n", | ||
108 | i); | ||
109 | GNUNET_HELPER_stop (helper[i - 1], | ||
110 | GNUNET_YES); | ||
111 | } | ||
112 | |||
113 | for (int i = 1; i <= shs->global_n; i++) | ||
101 | { | 114 | { |
102 | for (int j = 1; j <= atoi (shs->local_m); j++) | 115 | for (int j = 1; j <= shs->local_m; j++) |
103 | { | 116 | { |
104 | GNUNET_HELPER_stop (helper[(i - 1) * atoi (shs->local_m) + j - 1], | 117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
118 | "i: %u j: %u\n", | ||
119 | i, | ||
120 | j); | ||
121 | GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j + shs->known - 1], | ||
105 | GNUNET_YES); | 122 | GNUNET_YES); |
106 | } | 123 | } |
107 | } | 124 | } |
@@ -110,26 +127,27 @@ stop_testing_system_run (void *cls, | |||
110 | 127 | ||
111 | /** | 128 | /** |
112 | * Create command. | 129 | * Create command. |
113 | * @param helper_start_label label of the cmd to start the test system. | 130 | * |
114 | * @param label name for command. | 131 | * @param label name for command. |
115 | * @param . | 132 | * @param helper_start_label label of the cmd to start the test system. |
116 | * @param local_m Number of nodes in a network namespace. //TODO make this a unsigned int | 133 | * @param topology_config Configuration file for the test topology. |
117 | * @param global_n Number of network namespaces. //TODO make this a unsigned int | ||
118 | * @return command. | 134 | * @return command. |
119 | */ | 135 | */ |
120 | struct GNUNET_TESTING_Command | 136 | struct GNUNET_TESTING_Command |
121 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, | 137 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, |
122 | const char *helper_start_label, | 138 | const char *helper_start_label, |
123 | char *local_m, | 139 | const char *topology_config) |
124 | char *global_n | ||
125 | ) | ||
126 | { | 140 | { |
127 | struct StopHelperState *shs; | 141 | struct StopHelperState *shs; |
128 | 142 | ||
143 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
144 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
145 | |||
129 | shs = GNUNET_new (struct StopHelperState); | 146 | shs = GNUNET_new (struct StopHelperState); |
130 | shs->helper_start_label = helper_start_label; | 147 | shs->helper_start_label = helper_start_label; |
131 | shs->local_m = local_m; | 148 | shs->local_m = topology->nodes_m; |
132 | shs->global_n = global_n; | 149 | shs->global_n = topology->namespaces_n; |
150 | shs->known = topology->nodes_x; | ||
133 | 151 | ||
134 | struct GNUNET_TESTING_Command cmd = { | 152 | struct GNUNET_TESTING_Command cmd = { |
135 | .cls = shs, | 153 | .cls = shs, |