aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_netjail_start_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_start_v2.c')
-rw-r--r--src/testing/testing_api_cmd_netjail_start_v2.c55
1 files changed, 11 insertions, 44 deletions
diff --git a/src/testing/testing_api_cmd_netjail_start_v2.c b/src/testing/testing_api_cmd_netjail_start_v2.c
index faabed98e..69d5e6a45 100644
--- a/src/testing/testing_api_cmd_netjail_start_v2.c
+++ b/src/testing/testing_api_cmd_netjail_start_v2.c
@@ -35,6 +35,11 @@
35 */ 35 */
36struct NetJailState 36struct NetJailState
37{ 37{
38 /**
39 * Context for our asynchronous completion.
40 */
41 struct GNUNET_TESTING_AsyncContext ac;
42
38 // Child Wait handle 43 // Child Wait handle
39 struct GNUNET_ChildWaitHandle *cwh; 44 struct GNUNET_ChildWaitHandle *cwh;
40 45
@@ -86,20 +91,6 @@ netjail_start_cleanup (void *cls)
86 91
87 92
88/** 93/**
89 * Trait function of this cmd does nothing.
90 *
91 */
92static enum GNUNET_GenericReturnValue
93netjail_start_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. 94 * Callback which will be called if the setup script finished.
104 * 95 *
105 */ 96 */
@@ -110,19 +101,19 @@ child_completed_callback (void *cls,
110{ 101{
111 struct NetJailState *ns = cls; 102 struct NetJailState *ns = cls;
112 103
104 GNUNET_OS_process_destroy (ns->start_proc);
105 ns->start_proc = NULL;
113 if (0 == exit_code) 106 if (0 == exit_code)
114 { 107 {
115 ns->finished = GNUNET_YES; 108 GNUNET_TESTING_async_finish (&ns->ac);
116 } 109 }
117 else 110 else
118 { 111 {
119 // FIXME: log status code 112 // FIXME: log status code
120 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
121 "Child completed with an error!\n"); 114 "Child completed with an error!\n");
122 ns->finished = GNUNET_SYSERR; 115 GNUNET_TESTING_async_fail (&ns->ac);
123 } 116 }
124 GNUNET_OS_process_destroy (ns->start_proc);
125 ns->start_proc = NULL;
126} 117}
127 118
128 119
@@ -193,29 +184,6 @@ netjail_start_run (void *cls,
193 184
194 185
195/** 186/**
196 * This function checks the flag NetJailState
197 *
198 * FIXME: fix comment!
199 * #finished, if this cmd finished.
200 *
201 */
202static enum GNUNET_GenericReturnValue
203netjail_start_finish (void *cls,
204 GNUNET_SCHEDULER_TaskCallback cont,
205 void *cont_cls)
206{
207 struct NetJailState *ns = cls;
208
209 if (GNUNET_NO != ns->finished)
210 {
211 cont (cont_cls);
212 }
213 // FIXME: cont should be called later in the else case!
214 return ns->finished;
215}
216
217
218/**
219 * Create command. 187 * Create command.
220 * 188 *
221 * @param label name for command. 189 * @param label name for command.
@@ -235,9 +203,8 @@ GNUNET_TESTING_cmd_netjail_start_v2 (const char *label,
235 .cls = ns, 203 .cls = ns,
236 .label = label, 204 .label = label,
237 .run = &netjail_start_run, 205 .run = &netjail_start_run,
238 .finish = &netjail_start_finish, 206 .ac = &ns->ac,
239 .cleanup = &netjail_start_cleanup, 207 .cleanup = &netjail_start_cleanup
240 .traits = &netjail_start_traits
241 }; 208 };
242 209
243 return cmd; 210 return cmd;