diff options
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_start.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_start.c | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c index 9cd84cb4f..35fb90f3c 100644 --- a/src/testing/testing_api_cmd_netjail_start.c +++ b/src/testing/testing_api_cmd_netjail_start.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testing/testing_api_cmd_hello_world.c | 22 | * @file testing/testing_api_cmd_netjail_start.c |
23 | * @brief Command to start the netjail script. | 23 | * @brief Command to start the netjail script. |
24 | * @author t3sserakt | 24 | * @author t3sserakt |
25 | */ | 25 | */ |
@@ -43,16 +43,16 @@ struct NetJailState | |||
43 | // Child Wait handle | 43 | // Child Wait handle |
44 | struct GNUNET_ChildWaitHandle *cwh; | 44 | struct GNUNET_ChildWaitHandle *cwh; |
45 | 45 | ||
46 | // Number of local nodes in each namespace. | ||
47 | char *local_m; | ||
48 | |||
49 | // The number of namespaces. | ||
50 | char *global_n; | ||
51 | |||
52 | /** | 46 | /** |
53 | * The process id of the start script. | 47 | * The process id of the start script. |
54 | */ | 48 | */ |
55 | struct GNUNET_OS_Process *start_proc; | 49 | struct GNUNET_OS_Process *start_proc; |
50 | |||
51 | /** | ||
52 | * Configuration file for the test topology. | ||
53 | */ | ||
54 | char *topology_config; | ||
55 | |||
56 | }; | 56 | }; |
57 | 57 | ||
58 | 58 | ||
@@ -67,6 +67,7 @@ netjail_start_cleanup (void *cls) | |||
67 | 67 | ||
68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
69 | "netjail_start_cleanup!\n"); | 69 | "netjail_start_cleanup!\n"); |
70 | |||
70 | if (NULL != ns->cwh) | 71 | if (NULL != ns->cwh) |
71 | { | 72 | { |
72 | GNUNET_wait_child_cancel (ns->cwh); | 73 | GNUNET_wait_child_cancel (ns->cwh); |
@@ -105,9 +106,9 @@ child_completed_callback (void *cls, | |||
105 | } | 106 | } |
106 | else | 107 | else |
107 | { | 108 | { |
108 | // FIXME: log status code | ||
109 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 109 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
110 | "Child completed with an error!\n"); | 110 | "Child failed with error %lu!\n", |
111 | exit_code); | ||
111 | GNUNET_TESTING_async_fail (&ns->ac); | 112 | GNUNET_TESTING_async_fail (&ns->ac); |
112 | } | 113 | } |
113 | } | 114 | } |
@@ -124,13 +125,13 @@ netjail_start_run (void *cls, | |||
124 | struct GNUNET_TESTING_Interpreter *is) | 125 | struct GNUNET_TESTING_Interpreter *is) |
125 | { | 126 | { |
126 | struct NetJailState *ns = cls; | 127 | struct NetJailState *ns = cls; |
127 | char *const script_argv[] = { | 128 | char pid[15]; |
128 | NETJAIL_START_SCRIPT, | 129 | enum GNUNET_GenericReturnValue helper_check; |
129 | ns->local_m, | 130 | |
130 | ns->global_n, | 131 | // FIXME: NETJAIL_START_SCRIPT like this is bad, |
131 | NULL | 132 | // use location from share/gnunet/ of installed |
132 | }; | 133 | // binary in case libgnunettesting is used as a lib! |
133 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | 134 | helper_check = GNUNET_OS_check_helper_binary ( |
134 | NETJAIL_START_SCRIPT, | 135 | NETJAIL_START_SCRIPT, |
135 | GNUNET_YES, | 136 | GNUNET_YES, |
136 | NULL); | 137 | NULL); |
@@ -141,22 +142,37 @@ netjail_start_run (void *cls, | |||
141 | "No SUID for %s!\n", | 142 | "No SUID for %s!\n", |
142 | NETJAIL_START_SCRIPT); | 143 | NETJAIL_START_SCRIPT); |
143 | GNUNET_TESTING_interpreter_fail (is); | 144 | GNUNET_TESTING_interpreter_fail (is); |
145 | return; | ||
144 | } | 146 | } |
145 | else if (GNUNET_NO == helper_check) | 147 | if (GNUNET_SYSERR == helper_check) |
146 | { | 148 | { |
147 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 149 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
148 | "%s not found!\n", | 150 | "%s not found!\n", |
149 | NETJAIL_START_SCRIPT); | 151 | NETJAIL_START_SCRIPT); |
150 | GNUNET_TESTING_interpreter_fail (is); | 152 | GNUNET_TESTING_interpreter_fail (is); |
153 | return; | ||
151 | } | 154 | } |
152 | 155 | ||
153 | ns->start_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | 156 | GNUNET_snprintf (pid, |
154 | NULL, | 157 | sizeof (pid), |
155 | NULL, | 158 | "%u", |
156 | NULL, | 159 | getpid ()); |
157 | NETJAIL_START_SCRIPT, | 160 | { |
158 | script_argv); | 161 | char *const script_argv[] = { |
162 | NETJAIL_START_SCRIPT, | ||
163 | ns->topology_config, | ||
164 | pid, | ||
165 | NULL | ||
166 | }; | ||
159 | 167 | ||
168 | ns->start_proc | ||
169 | = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, | ||
170 | NULL, | ||
171 | NULL, | ||
172 | NULL, | ||
173 | NETJAIL_START_SCRIPT, | ||
174 | script_argv); | ||
175 | } | ||
160 | ns->cwh = GNUNET_wait_child (ns->start_proc, | 176 | ns->cwh = GNUNET_wait_child (ns->start_proc, |
161 | &child_completed_callback, | 177 | &child_completed_callback, |
162 | ns); | 178 | ns); |
@@ -168,20 +184,17 @@ netjail_start_run (void *cls, | |||
168 | * Create command. | 184 | * Create command. |
169 | * | 185 | * |
170 | * @param label name for command. | 186 | * @param label name for command. |
171 | * @param local_m Number of local nodes in each namespace. | 187 | * @param topology_config Configuration file for the test topology. |
172 | * @param global_n The number of namespaces. | ||
173 | * @return command. | 188 | * @return command. |
174 | */ | 189 | */ |
175 | struct GNUNET_TESTING_Command | 190 | struct GNUNET_TESTING_Command |
176 | GNUNET_TESTING_cmd_netjail_start (const char *label, | 191 | GNUNET_TESTING_cmd_netjail_start (const char *label, |
177 | char *local_m, | 192 | char *topology_config) |
178 | char *global_n) | ||
179 | { | 193 | { |
180 | struct NetJailState *ns; | 194 | struct NetJailState *ns; |
181 | 195 | ||
182 | ns = GNUNET_new (struct NetJailState); | 196 | ns = GNUNET_new (struct NetJailState); |
183 | ns->local_m = local_m; | 197 | ns->topology_config = topology_config; |
184 | ns->global_n = global_n; | ||
185 | { | 198 | { |
186 | struct GNUNET_TESTING_Command cmd = { | 199 | struct GNUNET_TESTING_Command cmd = { |
187 | .cls = ns, | 200 | .cls = ns, |