diff options
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop_testsystem.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop_testsystem.c | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c deleted file mode 100644 index 0ae82a26a..000000000 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c +++ /dev/null | |||
@@ -1,143 +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 | char *local_m; | ||
46 | |||
47 | char *global_n; | ||
48 | }; | ||
49 | |||
50 | |||
51 | /** | ||
52 | * Code to clean up resource this cmd used. | ||
53 | * | ||
54 | * @param cls closure | ||
55 | * @param cmd current CMD being cleaned up. | ||
56 | */ | ||
57 | static void | ||
58 | stop_testing_system_cleanup (void *cls, | ||
59 | const struct GNUNET_TESTING_Command *cmd) | ||
60 | { | ||
61 | |||
62 | } | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Trait function of this cmd does nothing. | ||
67 | * | ||
68 | */ | ||
69 | static int | ||
70 | stop_testing_system_traits (void *cls, | ||
71 | const void **ret, | ||
72 | const char *trait, | ||
73 | unsigned int index) | ||
74 | { | ||
75 | return GNUNET_OK; | ||
76 | } | ||
77 | |||
78 | |||
79 | /** | ||
80 | * This function stops the helper process for each node. | ||
81 | * | ||
82 | * @param cls closure. | ||
83 | * @param cmd CMD being run. | ||
84 | * @param is interpreter state. | ||
85 | */ | ||
86 | static void | ||
87 | stop_testing_system_run (void *cls, | ||
88 | const struct GNUNET_TESTING_Command *cmd, | ||
89 | struct GNUNET_TESTING_Interpreter *is) | ||
90 | { | ||
91 | struct StopHelperState *shs = cls; | ||
92 | struct GNUNET_HELPER_Handle **helper; | ||
93 | const struct GNUNET_TESTING_Command *start_helper_cmd; | ||
94 | |||
95 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( | ||
96 | shs->helper_start_label); | ||
97 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | ||
98 | &helper); | ||
99 | |||
100 | for (int i = 1; i <= atoi (shs->global_n); i++) | ||
101 | { | ||
102 | for (int j = 1; j <= atoi (shs->local_m); j++) | ||
103 | { | ||
104 | GNUNET_HELPER_stop (helper[(i - 1) * atoi (shs->local_m) + j - 1], | ||
105 | GNUNET_YES); | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | |||
110 | |||
111 | /** | ||
112 | * Create command. | ||
113 | * @param helper_start_label label of the cmd to start the test system. | ||
114 | * @param label name for command. | ||
115 | * @param . | ||
116 | * @param local_m Number of nodes in a network namespace. //TODO make this a unsigned int | ||
117 | * @param global_n Number of network namespaces. //TODO make this a unsigned int | ||
118 | * @return command. | ||
119 | */ | ||
120 | struct GNUNET_TESTING_Command | ||
121 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, | ||
122 | const char *helper_start_label, | ||
123 | char *local_m, | ||
124 | char *global_n | ||
125 | ) | ||
126 | { | ||
127 | struct StopHelperState *shs; | ||
128 | |||
129 | shs = GNUNET_new (struct StopHelperState); | ||
130 | shs->helper_start_label = helper_start_label; | ||
131 | shs->local_m = local_m; | ||
132 | shs->global_n = global_n; | ||
133 | |||
134 | struct GNUNET_TESTING_Command cmd = { | ||
135 | .cls = shs, | ||
136 | .label = label, | ||
137 | .run = &stop_testing_system_run, | ||
138 | .cleanup = &stop_testing_system_cleanup, | ||
139 | .traits = &stop_testing_system_traits | ||
140 | }; | ||
141 | |||
142 | return cmd; | ||
143 | } | ||