diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-07-10 15:37:07 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-07-10 15:37:07 +0000 |
commit | eb0f79e5639370554f2cf196354aaba36854dd0c (patch) | |
tree | bb82f55f8a3de87cdd35f8cf875aaae66e4f3315 /src/testbed/test_testbed_api.c | |
parent | 5678bfb6e0ec1dd3e3dd4ee9b9e1604571c2725d (diff) | |
download | gnunet-eb0f79e5639370554f2cf196354aaba36854dd0c.tar.gz gnunet-eb0f79e5639370554f2cf196354aaba36854dd0c.zip |
-fixing 2494
Diffstat (limited to 'src/testbed/test_testbed_api.c')
-rw-r--r-- | src/testbed/test_testbed_api.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/testbed/test_testbed_api.c b/src/testbed/test_testbed_api.c index 5fab40573..6c50c93d7 100644 --- a/src/testbed/test_testbed_api.c +++ b/src/testbed/test_testbed_api.c | |||
@@ -48,6 +48,11 @@ | |||
48 | static struct GNUNET_TESTBED_Host *host; | 48 | static struct GNUNET_TESTBED_Host *host; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * The controller process | ||
52 | */ | ||
53 | static struct GNUNET_TESTBED_ControllerProc *cp; | ||
54 | |||
55 | /** | ||
51 | * The controller handle | 56 | * The controller handle |
52 | */ | 57 | */ |
53 | static struct GNUNET_TESTBED_Controller *controller; | 58 | static struct GNUNET_TESTBED_Controller *controller; |
@@ -102,6 +107,8 @@ do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
102 | if (NULL != reg_handle) | 107 | if (NULL != reg_handle) |
103 | GNUNET_TESTBED_cancel_registration (reg_handle); | 108 | GNUNET_TESTBED_cancel_registration (reg_handle); |
104 | GNUNET_TESTBED_controller_disconnect (controller); | 109 | GNUNET_TESTBED_controller_disconnect (controller); |
110 | if (NULL != cp) | ||
111 | GNUNET_TESTBED_controller_stop (cp); | ||
105 | GNUNET_TESTBED_host_destroy (neighbour); | 112 | GNUNET_TESTBED_host_destroy (neighbour); |
106 | GNUNET_TESTBED_host_destroy (host); | 113 | GNUNET_TESTBED_host_destroy (host); |
107 | } | 114 | } |
@@ -163,18 +170,23 @@ registration_comp (void *cls, const char *emsg) | |||
163 | 170 | ||
164 | 171 | ||
165 | /** | 172 | /** |
166 | * Main point of test execution | 173 | * Main run function. |
174 | * | ||
175 | * @param cls NULL | ||
176 | * @param args arguments passed to GNUNET_PROGRAM_run | ||
177 | * @param cfgfile the path to configuration file | ||
178 | * @param cfg the configuration file handle | ||
167 | */ | 179 | */ |
168 | static void | 180 | static void |
169 | run (void *cls, | 181 | run (void *cls, char *const *args, const char *cfgfile, |
170 | const struct GNUNET_CONFIGURATION_Handle *config, | 182 | const struct GNUNET_CONFIGURATION_Handle *config) |
171 | struct GNUNET_TESTING_Peer *peer) | ||
172 | { | 183 | { |
173 | uint64_t event_mask; | 184 | uint64_t event_mask; |
174 | 185 | ||
175 | cfg = config; | 186 | cfg = config; |
176 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); | 187 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); |
177 | GNUNET_assert (NULL != host); | 188 | GNUNET_assert (NULL != host); |
189 | cp = GNUNET_TESTBED_controller_start (host); | ||
178 | event_mask = 0; | 190 | event_mask = 0; |
179 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); | 191 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); |
180 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); | 192 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); |
@@ -199,15 +211,20 @@ run (void *cls, | |||
199 | */ | 211 | */ |
200 | int main (int argc, char **argv) | 212 | int main (int argc, char **argv) |
201 | { | 213 | { |
202 | struct GNUNET_TESTBED_ControllerProc *cp; | 214 | int ret; |
203 | 215 | ||
204 | cp = GNUNET_TESTBED_controller_start (NULL); | 216 | char *const argv2[] = { "test_testbed_api", |
205 | 217 | "-c", "test_testbed_api.conf", | |
218 | NULL | ||
219 | }; | ||
220 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
221 | GNUNET_GETOPT_OPTION_END | ||
222 | }; | ||
206 | result = GNUNET_SYSERR; | 223 | result = GNUNET_SYSERR; |
207 | if (0 != GNUNET_TESTING_peer_run ("test_testbed_api", | 224 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
208 | "test_testbed_api.conf", | 225 | "test_testbed_api", "nohelp", options, &run, |
209 | &run, NULL)) | 226 | NULL); |
227 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) | ||
210 | return 1; | 228 | return 1; |
211 | GNUNET_TESTBED_controller_stop (cp); | 229 | return 0; |
212 | return result; | ||
213 | } | 230 | } |