aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_netjail_stop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop.c')
-rw-r--r--src/testing/testing_api_cmd_netjail_stop.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c
index 8c78b5e93..5033272a3 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -31,7 +31,7 @@
31#define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" 31#define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh"
32 32
33// Child Wait handle 33// Child Wait handle
34struct GNUNET_ChildWaitHandle *cwh; 34static struct GNUNET_ChildWaitHandle *cwh;
35 35
36/** 36/**
37 * Struct to hold information for callbacks. 37 * Struct to hold information for callbacks.
@@ -44,11 +44,10 @@ struct NetJailState
44 */ 44 */
45 struct GNUNET_TESTING_AsyncContext ac; 45 struct GNUNET_TESTING_AsyncContext ac;
46 46
47 // Number of local nodes in each namespace. 47 /**
48 char *local_m; 48 * Configuration file for the test topology.
49 49 */
50 // The number of namespaces. 50 char *topology_config;
51 char *global_n;
52 51
53 /** 52 /**
54 * The process id of the start script. 53 * The process id of the start script.
@@ -86,20 +85,6 @@ netjail_stop_cleanup (void *cls)
86 85
87 86
88/** 87/**
89 * Trait function of this cmd does nothing.
90 *
91 */
92static enum GNUNET_GenericReturnValue
93netjail_stop_traits (void *cls,
94 const void **ret,
95 const char *trait,
96 unsigned int index)
97{
98 return GNUNET_NO;
99}
100
101
102/**
103 * Callback which will be called if the setup script finished. 88 * Callback which will be called if the setup script finished.
104 * 89 *
105 */ 90 */
@@ -110,7 +95,7 @@ child_completed_callback (void *cls,
110{ 95{
111 struct NetJailState *ns = cls; 96 struct NetJailState *ns = cls;
112 97
113 cwh = NULL; 98 cwh = NULL; // WTF? globals!?!?!
114 GNUNET_OS_process_destroy (ns->stop_proc); 99 GNUNET_OS_process_destroy (ns->stop_proc);
115 ns->stop_proc = NULL; 100 ns->stop_proc = NULL;
116 if (0 == exit_code) 101 if (0 == exit_code)
@@ -119,7 +104,6 @@ child_completed_callback (void *cls,
119 } 104 }
120 else 105 else
121 { 106 {
122 // FIXME: log exit code!
123 GNUNET_TESTING_async_fail (&ns->ac); 107 GNUNET_TESTING_async_fail (&ns->ac);
124 } 108 }
125} 109}
@@ -129,7 +113,6 @@ child_completed_callback (void *cls,
129* The run method starts the script which deletes the network namespaces. 113* The run method starts the script which deletes the network namespaces.
130* 114*
131* @param cls closure. 115* @param cls closure.
132* @param cmd CMD being run.
133* @param is interpreter state. 116* @param is interpreter state.
134*/ 117*/
135static void 118static void
@@ -137,12 +120,15 @@ netjail_stop_run (void *cls,
137 struct GNUNET_TESTING_Interpreter *is) 120 struct GNUNET_TESTING_Interpreter *is)
138{ 121{
139 struct NetJailState *ns = cls; 122 struct NetJailState *ns = cls;
140 char *const script_argv[] = { 123 char *pid;
141 NETJAIL_STOP_SCRIPT, 124
142 ns->local_m, 125 GNUNET_asprintf (&pid,
143 ns->global_n, 126 "%u",
144 NULL 127 getpid ());
145 }; 128 char *const script_argv[] = {NETJAIL_STOP_SCRIPT,
129 ns->topology_config,
130 pid,
131 NULL};
146 unsigned int helper_check = GNUNET_OS_check_helper_binary ( 132 unsigned int helper_check = GNUNET_OS_check_helper_binary (
147 NETJAIL_STOP_SCRIPT, 133 NETJAIL_STOP_SCRIPT,
148 GNUNET_YES, 134 GNUNET_YES,
@@ -174,28 +160,24 @@ netjail_stop_run (void *cls,
174 &child_completed_callback, 160 &child_completed_callback,
175 ns); 161 ns);
176 GNUNET_break (NULL != cwh); 162 GNUNET_break (NULL != cwh);
177
178} 163}
179 164
180 165
181struct GNUNET_TESTING_Command 166struct GNUNET_TESTING_Command
182GNUNET_TESTING_cmd_netjail_stop (const char *label, 167GNUNET_TESTING_cmd_netjail_stop (const char *label,
183 char *local_m, 168 char *topology_config)
184 char *global_n)
185{ 169{
186 struct NetJailState *ns; 170 struct NetJailState *ns;
187 171
188 ns = GNUNET_new (struct NetJailState); 172 ns = GNUNET_new (struct NetJailState);
189 ns->local_m = local_m; 173 ns->topology_config = topology_config;
190 ns->global_n = global_n;
191 { 174 {
192 struct GNUNET_TESTING_Command cmd = { 175 struct GNUNET_TESTING_Command cmd = {
193 .cls = ns, 176 .cls = ns,
194 .label = label, 177 .label = label,
195 .run = &netjail_stop_run, 178 .run = &netjail_stop_run,
196 .ac = &ns->ac, 179 .ac = &ns->ac,
197 .cleanup = &netjail_stop_cleanup, 180 .cleanup = &netjail_stop_cleanup
198 .traits = &netjail_stop_traits
199 }; 181 };
200 182
201 return cmd; 183 return cmd;