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.c58
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*/
57static void 63static void
58stop_testing_system_cleanup (void *cls, 64stop_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*/
86static void 90static void
87stop_testing_system_run (void *cls, 91stop_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 */
120struct GNUNET_TESTING_Command 136struct GNUNET_TESTING_Command
121GNUNET_TESTING_cmd_stop_testing_system (const char *label, 137GNUNET_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,