diff options
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c b/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c deleted file mode 100644 index 6ce106eaa..000000000 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c +++ /dev/null | |||
@@ -1,163 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing/testing_api_cmd_hello_world.c | ||
23 | * @brief Command to start the netjail peers. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "testing_cmds.h" | ||
29 | |||
30 | |||
31 | /** | ||
32 | * Struct to store information handed over to callbacks. | ||
33 | * | ||
34 | */ | ||
35 | struct StopHelperState | ||
36 | { | ||
37 | |||
38 | const char *helper_start_label; | ||
39 | |||
40 | /** | ||
41 | * The process handle | ||
42 | */ | ||
43 | struct GNUNET_HELPER_Handle **helper; | ||
44 | |||
45 | unsigned int local_m; | ||
46 | |||
47 | unsigned int global_n; | ||
48 | |||
49 | /** | ||
50 | * Number of global known nodes. | ||
51 | * | ||
52 | */ | ||
53 | unsigned int known; | ||
54 | }; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Code to clean up resource this cmd used. | ||
59 | * | ||
60 | * @param cls closure | ||
61 | * @param cmd current CMD being cleaned up. | ||
62 | */ | ||
63 | static void | ||
64 | stop_testing_system_cleanup (void *cls, | ||
65 | const struct GNUNET_TESTING_Command *cmd) | ||
66 | { | ||
67 | |||
68 | } | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Trait function of this cmd does nothing. | ||
73 | * | ||
74 | */ | ||
75 | static int | ||
76 | stop_testing_system_traits (void *cls, | ||
77 | const void **ret, | ||
78 | const char *trait, | ||
79 | unsigned int index) | ||
80 | { | ||
81 | return GNUNET_OK; | ||
82 | } | ||
83 | |||
84 | |||
85 | /** | ||
86 | * This function stops the helper process for each node. | ||
87 | * | ||
88 | * @param cls closure. | ||
89 | * @param cmd CMD being run. | ||
90 | * @param is interpreter state. | ||
91 | */ | ||
92 | static void | ||
93 | stop_testing_system_run (void *cls, | ||
94 | const struct GNUNET_TESTING_Command *cmd, | ||
95 | struct GNUNET_TESTING_Interpreter *is) | ||
96 | { | ||
97 | struct StopHelperState *shs = cls; | ||
98 | struct GNUNET_HELPER_Handle **helper; | ||
99 | const struct GNUNET_TESTING_Command *start_helper_cmd; | ||
100 | |||
101 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( | ||
102 | shs->helper_start_label); | ||
103 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | ||
104 | &helper); | ||
105 | |||
106 | for (int i = 1; i <= shs->known; i++) | ||
107 | { | ||
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
109 | "i: %u\n", | ||
110 | i); | ||
111 | GNUNET_HELPER_stop (helper[i - 1], | ||
112 | GNUNET_YES); | ||
113 | } | ||
114 | |||
115 | for (int i = 1; i <= shs->global_n; i++) | ||
116 | { | ||
117 | for (int j = 1; j <= shs->local_m; j++) | ||
118 | { | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
120 | "i: %u j: %u\n", | ||
121 | i, | ||
122 | j); | ||
123 | GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j + shs->known - 1], | ||
124 | GNUNET_YES); | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Create command. | ||
132 | * | ||
133 | * @param label name for command. | ||
134 | * @param helper_start_label label of the cmd to start the test system. | ||
135 | * @param topology_config Configuration file for the test topology. | ||
136 | * @return command. | ||
137 | */ | ||
138 | struct GNUNET_TESTING_Command | ||
139 | GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label, | ||
140 | const char *helper_start_label, | ||
141 | const char *topology_config) | ||
142 | { | ||
143 | struct StopHelperState *shs; | ||
144 | |||
145 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
146 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
147 | |||
148 | shs = GNUNET_new (struct StopHelperState); | ||
149 | shs->helper_start_label = helper_start_label; | ||
150 | shs->local_m = topology->nodes_m; | ||
151 | shs->global_n = topology->namespaces_n; | ||
152 | shs->known = topology->nodes_x; | ||
153 | |||
154 | struct GNUNET_TESTING_Command cmd = { | ||
155 | .cls = shs, | ||
156 | .label = label, | ||
157 | .run = &stop_testing_system_run, | ||
158 | .cleanup = &stop_testing_system_cleanup, | ||
159 | .traits = &stop_testing_system_traits | ||
160 | }; | ||
161 | |||
162 | return cmd; | ||
163 | } | ||