aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c
diff options
context:
space:
mode:
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.c141
1 files changed, 0 insertions, 141 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 65eb85d9a..000000000
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c
+++ /dev/null
@@ -1,141 +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 */
35struct 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
51/**
52* Code to clean up resource this cmd used.
53*
54* @param cls closure
55*/
56static void
57stop_testing_system_cleanup (void *cls)
58{
59
60}
61
62
63/**
64 * Trait function of this cmd does nothing.
65 *
66 */
67static enum GNUNET_GenericReturnValue
68stop_testing_system_traits (void *cls,
69 const void **ret,
70 const char *trait,
71 unsigned int index)
72{
73 return GNUNET_NO;
74}
75
76
77/**
78* This function stops the helper process for each node.
79*
80* @param cls closure.
81* @param is interpreter state.
82*/
83static void
84stop_testing_system_run (void *cls,
85 struct GNUNET_TESTING_Interpreter *is)
86{
87 struct StopHelperState *shs = cls;
88 struct GNUNET_HELPER_Handle **helper;
89 const struct GNUNET_TESTING_Command *start_helper_cmd;
90
91 start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (
92 is,
93 shs->helper_start_label);
94 GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd,
95 &helper);
96
97 for (int i = 1; i <= shs->global_n; i++)
98 {
99 for (int j = 1; j <= shs->local_m; j++)
100 {
101 GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j - 1],
102 GNUNET_YES);
103 }
104 }
105}
106
107
108/**
109 * Create command.
110 *
111 * @param label name for command.
112 * @param helper_start_label label of the cmd to start the test system.
113 * @param topology_config Configuration file for the test topology.
114 * @return command.
115 */
116struct GNUNET_TESTING_Command
117GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label,
118 const char *helper_start_label,
119 const char *topology_config)
120{
121 struct StopHelperState *shs;
122
123 struct GNUNET_TESTING_NetjailTopology *topology =
124 GNUNET_TESTING_get_topo_from_file (topology_config);
125
126 shs = GNUNET_new (struct StopHelperState);
127 shs->helper_start_label = helper_start_label;
128 shs->local_m = topology->nodes_m;
129 shs->global_n = topology->namespaces_n;
130 {
131 struct GNUNET_TESTING_Command cmd = {
132 .cls = shs,
133 .label = label,
134 .run = &stop_testing_system_run,
135 .cleanup = &stop_testing_system_cleanup,
136 .traits = &stop_testing_system_traits
137 };
138
139 return cmd;
140 }
141}