aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_netjail_stop_testsystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop_testsystem.c')
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
new file mode 100644
index 000000000..bed9f3ebf
--- /dev/null
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -0,0 +1,141 @@
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
31struct StopHelperState
32{
33
34 const char *helper_start_label;
35
36 /**
37 * The process handle
38 */
39 struct GNUNET_HELPER_Handle **helper;
40
41 char *local_m;
42
43 char *global_n;
44};
45
46
47/**
48*
49*
50* @param cls closure
51* @param cmd current CMD being cleaned up.
52*/
53static void
54stop_testing_system_cleanup (void *cls,
55 const struct GNUNET_TESTING_Command *cmd)
56{
57
58}
59
60
61/**
62*
63*
64* @param cls closure.
65* @param[out] ret result
66* @param trait name of the trait.
67* @param index index number of the object to offer.
68* @return #GNUNET_OK on success.
69*/
70static int
71stop_testing_system_traits (void *cls,
72 const void **ret,
73 const char *trait,
74 unsigned int index)
75{
76 return GNUNET_OK;
77}
78
79
80/**
81* Run the "hello world" CMD.
82*
83* @param cls closure.
84* @param cmd CMD being run.
85* @param is interpreter state.
86*/
87static void
88stop_testing_system_run (void *cls,
89 const struct GNUNET_TESTING_Command *cmd,
90 struct GNUNET_TESTING_Interpreter *is)
91{
92 struct StopHelperState *shs = cls;
93 struct GNUNET_HELPER_Handle **helper;
94 const struct GNUNET_TESTING_Command *start_helper_cmd;
95
96 start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (
97 shs->helper_start_label);
98 GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd,
99 &helper);
100
101 for (int i = 1; i <= atoi (shs->global_n); i++) {
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 *
114 * @param label name for command.
115 * @param binaryname to exec.
116 * @return command.
117 */
118struct GNUNET_TESTING_Command
119GNUNET_TESTING_cmd_stop_testing_system (const char *label,
120 const char *helper_start_label,
121 char *local_m,
122 char *global_n
123 )
124{
125 struct StopHelperState *shs;
126
127 shs = GNUNET_new (struct StopHelperState);
128 shs->helper_start_label = helper_start_label;
129 shs->local_m = local_m;
130 shs->global_n = global_n;
131
132 struct GNUNET_TESTING_Command cmd = {
133 .cls = shs,
134 .label = label,
135 .run = &stop_testing_system_run,
136 .cleanup = &stop_testing_system_cleanup,
137 .traits = &stop_testing_system_traits
138 };
139
140 return cmd;
141}