aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api_reliability.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r--src/core/test_core_api_reliability.c584
1 files changed, 291 insertions, 293 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 7bd4bfea0..745b0b7d9 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -16,7 +16,7 @@
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file core/test_core_api_reliability.c 21 * @file core/test_core_api_reliability.c
22 * @brief testcase for core_api.c focusing on reliable transmission (with TCP) 22 * @brief testcase for core_api.c focusing on reliable transmission (with TCP)
@@ -41,7 +41,7 @@
41/** 41/**
42 * How long until we give up on transmitting the message? 42 * How long until we give up on transmitting the message?
43 */ 43 */
44#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) 44#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 600)
45 45
46#define MTYPE 12345 46#define MTYPE 12345
47 47
@@ -53,8 +53,7 @@ static struct GNUNET_TIME_Absolute start_time;
53static struct GNUNET_SCHEDULER_Task *err_task; 53static struct GNUNET_SCHEDULER_Task *err_task;
54 54
55 55
56struct PeerContext 56struct PeerContext {
57{
58 struct GNUNET_CONFIGURATION_Handle *cfg; 57 struct GNUNET_CONFIGURATION_Handle *cfg;
59 struct GNUNET_CORE_Handle *ch; 58 struct GNUNET_CORE_Handle *ch;
60 struct GNUNET_MQ_Handle *mq; 59 struct GNUNET_MQ_Handle *mq;
@@ -77,296 +76,294 @@ static int ok;
77static int32_t tr_n; 76static int32_t tr_n;
78 77
79 78
80#define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) 79#define OKPP do { ok++; GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
81 80
82struct TestMessage 81struct TestMessage {
83{
84 struct GNUNET_MessageHeader header; 82 struct GNUNET_MessageHeader header;
85 uint32_t num GNUNET_PACKED; 83 uint32_t num GNUNET_PACKED;
86}; 84};
87 85
88 86
89static unsigned int 87static unsigned int
90get_size (unsigned int iter) 88get_size(unsigned int iter)
91{ 89{
92 unsigned int ret; 90 unsigned int ret;
93 91
94 if (iter < 60000) 92 if (iter < 60000)
95 return iter + sizeof (struct TestMessage); 93 return iter + sizeof(struct TestMessage);
96 ret = (iter * iter * iter); 94 ret = (iter * iter * iter);
97 return sizeof (struct TestMessage) + (ret % 60000); 95 return sizeof(struct TestMessage) + (ret % 60000);
98} 96}
99 97
100 98
101static void 99static void
102terminate_peer (struct PeerContext *p) 100terminate_peer(struct PeerContext *p)
103{ 101{
104 if (NULL != p->ch) 102 if (NULL != p->ch)
105 { 103 {
106 GNUNET_CORE_disconnect (p->ch); 104 GNUNET_CORE_disconnect(p->ch);
107 p->ch = NULL; 105 p->ch = NULL;
108 } 106 }
109 if (NULL != p->ghh) 107 if (NULL != p->ghh)
110 { 108 {
111 GNUNET_TRANSPORT_hello_get_cancel (p->ghh); 109 GNUNET_TRANSPORT_hello_get_cancel(p->ghh);
112 p->ghh = NULL; 110 p->ghh = NULL;
113 } 111 }
114 if (NULL != p->oh) 112 if (NULL != p->oh)
115 { 113 {
116 GNUNET_TRANSPORT_offer_hello_cancel (p->oh); 114 GNUNET_TRANSPORT_offer_hello_cancel(p->oh);
117 p->oh = NULL; 115 p->oh = NULL;
118 } 116 }
119 if (NULL != p->ats_sh) 117 if (NULL != p->ats_sh)
120 { 118 {
121 GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh); 119 GNUNET_ATS_connectivity_suggest_cancel(p->ats_sh);
122 p->ats_sh = NULL; 120 p->ats_sh = NULL;
123 } 121 }
124 if (NULL != p->ats) 122 if (NULL != p->ats)
125 { 123 {
126 GNUNET_ATS_connectivity_done (p->ats); 124 GNUNET_ATS_connectivity_done(p->ats);
127 p->ats = NULL; 125 p->ats = NULL;
128 } 126 }
129} 127}
130 128
131 129
132static void 130static void
133terminate_task_error (void *cls) 131terminate_task_error(void *cls)
134{ 132{
135 err_task = NULL; 133 err_task = NULL;
136 GNUNET_break (0); 134 GNUNET_break(0);
137 GNUNET_SCHEDULER_shutdown (); 135 GNUNET_SCHEDULER_shutdown();
138 ok = 42; 136 ok = 42;
139} 137}
140 138
141 139
142static void 140static void
143do_shutdown (void *cls) 141do_shutdown(void *cls)
144{ 142{
145 unsigned long long delta; 143 unsigned long long delta;
146 144
147 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; 145 delta = GNUNET_TIME_absolute_get_duration(start_time).rel_value_us;
148 if (0 == delta) 146 if (0 == delta)
149 delta = 1; 147 delta = 1;
150 fprintf (stderr, 148 fprintf(stderr,
151 "\nThroughput was %llu kb/s\n", 149 "\nThroughput was %llu kb/s\n",
152 total_bytes * 1000000LL / 1024 / delta); 150 total_bytes * 1000000LL / 1024 / delta);
153 GAUGER ("CORE", 151 GAUGER("CORE",
154 "Core throughput/s", 152 "Core throughput/s",
155 total_bytes * 1000000LL / 1024 / delta, 153 total_bytes * 1000000LL / 1024 / delta,
156 "kb/s"); 154 "kb/s");
157 if (NULL != err_task) 155 if (NULL != err_task)
158 { 156 {
159 GNUNET_SCHEDULER_cancel (err_task); 157 GNUNET_SCHEDULER_cancel(err_task);
160 err_task = NULL; 158 err_task = NULL;
161 } 159 }
162 terminate_peer (&p1); 160 terminate_peer(&p1);
163 terminate_peer (&p2); 161 terminate_peer(&p2);
164
165} 162}
166 163
167 164
168static void 165static void
169send_message (struct GNUNET_MQ_Handle *mq, 166send_message(struct GNUNET_MQ_Handle *mq,
170 int32_t num) 167 int32_t num)
171{ 168{
172 struct GNUNET_MQ_Envelope *env; 169 struct GNUNET_MQ_Envelope *env;
173 struct TestMessage *hdr; 170 struct TestMessage *hdr;
174 unsigned int s; 171 unsigned int s;
175 172
176 GNUNET_assert (NULL != mq); 173 GNUNET_assert(NULL != mq);
177 GNUNET_assert (tr_n < TOTAL_MSGS); 174 GNUNET_assert(tr_n < TOTAL_MSGS);
178 s = get_size (tr_n); 175 s = get_size(tr_n);
179 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 176 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
180 "Sending message %u of size %u\n", 177 "Sending message %u of size %u\n",
181 tr_n, 178 tr_n,
182 s); 179 s);
183 env = GNUNET_MQ_msg_extra (hdr, 180 env = GNUNET_MQ_msg_extra(hdr,
184 s - sizeof (struct TestMessage), 181 s - sizeof(struct TestMessage),
185 MTYPE); 182 MTYPE);
186 hdr->num = htonl (tr_n); 183 hdr->num = htonl(tr_n);
187 memset (&hdr[1], 184 memset(&hdr[1],
188 tr_n, 185 tr_n,
189 s - sizeof (struct TestMessage)); 186 s - sizeof(struct TestMessage));
190 tr_n++; 187 tr_n++;
191 GNUNET_SCHEDULER_cancel (err_task); 188 GNUNET_SCHEDULER_cancel(err_task);
192 err_task = 189 err_task =
193 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 190 GNUNET_SCHEDULER_add_delayed(TIMEOUT,
194 &terminate_task_error, 191 &terminate_task_error,
195 NULL); 192 NULL);
196 total_bytes += s; 193 total_bytes += s;
197 GNUNET_MQ_send (mq, 194 GNUNET_MQ_send(mq,
198 env); 195 env);
199} 196}
200 197
201 198
202static void * 199static void *
203connect_notify (void *cls, 200connect_notify(void *cls,
204 const struct GNUNET_PeerIdentity *peer, 201 const struct GNUNET_PeerIdentity *peer,
205 struct GNUNET_MQ_Handle *mq) 202 struct GNUNET_MQ_Handle *mq)
206{ 203{
207 struct PeerContext *pc = cls; 204 struct PeerContext *pc = cls;
208 205
209 if (0 == memcmp (&pc->id, 206 if (0 == memcmp(&pc->id,
210 peer, 207 peer,
211 sizeof (struct GNUNET_PeerIdentity))) 208 sizeof(struct GNUNET_PeerIdentity)))
212 return (void *) peer; 209 return (void *)peer;
213 pc->mq = mq; 210 pc->mq = mq;
214 GNUNET_assert (0 == pc->connect_status); 211 GNUNET_assert(0 == pc->connect_status);
215 pc->connect_status = 1; 212 pc->connect_status = 1;
216 if (pc == &p1) 213 if (pc == &p1)
217 { 214 {
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 215 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
219 "Encrypted connection established to peer `%s'\n", 216 "Encrypted connection established to peer `%s'\n",
220 GNUNET_i2s (peer)); 217 GNUNET_i2s(peer));
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 218 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
222 "Asking core (1) for transmission to peer `%s'\n", 219 "Asking core (1) for transmission to peer `%s'\n",
223 GNUNET_i2s (&p2.id)); 220 GNUNET_i2s(&p2.id));
224 GNUNET_SCHEDULER_cancel (err_task); 221 GNUNET_SCHEDULER_cancel(err_task);
225 err_task = 222 err_task =
226 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 223 GNUNET_SCHEDULER_add_delayed(TIMEOUT,
227 &terminate_task_error, 224 &terminate_task_error,
228 NULL); 225 NULL);
229 start_time = GNUNET_TIME_absolute_get (); 226 start_time = GNUNET_TIME_absolute_get();
230 send_message (mq, 227 send_message(mq,
231 0); 228 0);
232 } 229 }
233 return (void *) peer; 230 return (void *)peer;
234} 231}
235 232
236 233
237static void 234static void
238disconnect_notify (void *cls, 235disconnect_notify(void *cls,
239 const struct GNUNET_PeerIdentity *peer, 236 const struct GNUNET_PeerIdentity *peer,
240 void *internal_cls) 237 void *internal_cls)
241{ 238{
242 struct PeerContext *pc = cls; 239 struct PeerContext *pc = cls;
243 240
244 if (0 == memcmp (&pc->id, 241 if (0 == memcmp(&pc->id,
245 peer, 242 peer,
246 sizeof (struct GNUNET_PeerIdentity))) 243 sizeof(struct GNUNET_PeerIdentity)))
247 return; 244 return;
248 pc->mq = NULL; 245 pc->mq = NULL;
249 pc->connect_status = 0; 246 pc->connect_status = 0;
250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 247 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
251 "Encrypted connection to `%s' cut\n", 248 "Encrypted connection to `%s' cut\n",
252 GNUNET_i2s (peer)); 249 GNUNET_i2s(peer));
253} 250}
254 251
255 252
256static int 253static int
257check_test (void *cls, 254check_test(void *cls,
258 const struct TestMessage *hdr) 255 const struct TestMessage *hdr)
259{ 256{
260 return GNUNET_OK; /* accept all */ 257 return GNUNET_OK; /* accept all */
261} 258}
262 259
263 260
264static void 261static void
265handle_test (void *cls, 262handle_test(void *cls,
266 const struct TestMessage *hdr) 263 const struct TestMessage *hdr)
267{ 264{
268 static int n; 265 static int n;
269 unsigned int s; 266 unsigned int s;
270 267
271 s = get_size (n); 268 s = get_size(n);
272 if (ntohs (hdr->header.size) != s) 269 if (ntohs(hdr->header.size) != s)
273 { 270 {
274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 271 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
275 "Expected message %u of size %u, got %u bytes of message %u\n", 272 "Expected message %u of size %u, got %u bytes of message %u\n",
276 n, 273 n,
277 s, 274 s,
278 ntohs (hdr->header.size), 275 ntohs(hdr->header.size),
279 ntohl (hdr->num)); 276 ntohl(hdr->num));
280 GNUNET_SCHEDULER_cancel (err_task); 277 GNUNET_SCHEDULER_cancel(err_task);
281 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, 278 err_task = GNUNET_SCHEDULER_add_now(&terminate_task_error,
282 NULL); 279 NULL);
283 return; 280 return;
284 } 281 }
285 if (ntohl (hdr->num) != n) 282 if (ntohl(hdr->num) != n)
286 { 283 {
287 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 284 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
288 "Expected message %u of size %u, got %u bytes of message %u\n", 285 "Expected message %u of size %u, got %u bytes of message %u\n",
289 n, 286 n,
290 s, 287 s,
291 (unsigned int) ntohs (hdr->header.size), 288 (unsigned int)ntohs(hdr->header.size),
292 (unsigned int) ntohl (hdr->num)); 289 (unsigned int)ntohl(hdr->num));
293 GNUNET_SCHEDULER_cancel (err_task); 290 GNUNET_SCHEDULER_cancel(err_task);
294 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, 291 err_task = GNUNET_SCHEDULER_add_now(&terminate_task_error,
295 NULL); 292 NULL);
296 return; 293 return;
297 } 294 }
298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 295 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
299 "Got message %u of size %u\n", 296 "Got message %u of size %u\n",
300 (unsigned int) ntohl (hdr->num), 297 (unsigned int)ntohl(hdr->num),
301 (unsigned int) ntohs (hdr->header.size)); 298 (unsigned int)ntohs(hdr->header.size));
302 n++; 299 n++;
303 if (0 == (n % (TOTAL_MSGS / 100))) 300 if (0 == (n % (TOTAL_MSGS / 100)))
304 fprintf (stderr, 301 fprintf(stderr,
305 "%s", 302 "%s",
306 "."); 303 ".");
307 if (n == TOTAL_MSGS) 304 if (n == TOTAL_MSGS)
308 { 305 {
309 ok = 0; 306 ok = 0;
310 GNUNET_SCHEDULER_shutdown (); 307 GNUNET_SCHEDULER_shutdown();
311 } 308 }
312 else 309 else
313 {
314 if (n == tr_n)
315 { 310 {
316 send_message (p1.mq, 311 if (n == tr_n)
317 tr_n); 312 {
313 send_message(p1.mq,
314 tr_n);
315 }
318 } 316 }
319 }
320} 317}
321 318
322 319
323static void 320static void
324init_notify (void *cls, 321init_notify(void *cls,
325 const struct GNUNET_PeerIdentity *my_identity) 322 const struct GNUNET_PeerIdentity *my_identity)
326{ 323{
327 struct PeerContext *p = cls; 324 struct PeerContext *p = cls;
328 struct GNUNET_MQ_MessageHandler handlers[] = { 325 struct GNUNET_MQ_MessageHandler handlers[] = {
329 GNUNET_MQ_hd_var_size (test, 326 GNUNET_MQ_hd_var_size(test,
330 MTYPE, 327 MTYPE,
331 struct TestMessage, 328 struct TestMessage,
332 NULL), 329 NULL),
333 GNUNET_MQ_handler_end () 330 GNUNET_MQ_handler_end()
334 }; 331 };
335 332
336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 333 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
337 "Connection to CORE service of `%s' established\n", 334 "Connection to CORE service of `%s' established\n",
338 GNUNET_i2s (my_identity)); 335 GNUNET_i2s(my_identity));
339 p->id = *my_identity; 336 p->id = *my_identity;
340 if (cls == &p1) 337 if (cls == &p1)
341 { 338 {
342 GNUNET_assert (ok == 2); 339 GNUNET_assert(ok == 2);
343 OKPP; 340 OKPP;
344 /* connect p2 */ 341 /* connect p2 */
345 GNUNET_assert (NULL != 342 GNUNET_assert(NULL !=
346 (p2.ch = GNUNET_CORE_connect (p2.cfg, 343 (p2.ch = GNUNET_CORE_connect(p2.cfg,
347 &p2, 344 &p2,
348 &init_notify, 345 &init_notify,
349 &connect_notify, 346 &connect_notify,
350 &disconnect_notify, 347 &disconnect_notify,
351 handlers))); 348 handlers)));
352 } 349 }
353 else 350 else
354 { 351 {
355 GNUNET_assert (ok == 3); 352 GNUNET_assert(ok == 3);
356 OKPP; 353 OKPP;
357 GNUNET_assert (cls == &p2); 354 GNUNET_assert(cls == &p2);
358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 355 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
359 "Asking transport (1) to connect to peer `%s'\n", 356 "Asking transport (1) to connect to peer `%s'\n",
360 GNUNET_i2s (&p2.id)); 357 GNUNET_i2s(&p2.id));
361 p1.ats_sh = GNUNET_ATS_connectivity_suggest (p1.ats, 358 p1.ats_sh = GNUNET_ATS_connectivity_suggest(p1.ats,
362 &p2.id, 359 &p2.id,
363 1); 360 1);
364 } 361 }
365} 362}
366 363
367 364
368static void 365static void
369offer_hello_done (void *cls) 366offer_hello_done(void *cls)
370{ 367{
371 struct PeerContext *p = cls; 368 struct PeerContext *p = cls;
372 369
@@ -375,129 +372,129 @@ offer_hello_done (void *cls)
375 372
376 373
377static void 374static void
378process_hello (void *cls, 375process_hello(void *cls,
379 const struct GNUNET_MessageHeader *message) 376 const struct GNUNET_MessageHeader *message)
380{ 377{
381 struct PeerContext *p = cls; 378 struct PeerContext *p = cls;
382 379
383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 380 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
384 "Received (my) `%s' from transport service\n", "HELLO"); 381 "Received (my) `%s' from transport service\n", "HELLO");
385 GNUNET_assert (message != NULL); 382 GNUNET_assert(message != NULL);
386 GNUNET_free_non_null (p->hello); 383 GNUNET_free_non_null(p->hello);
387 p->hello = GNUNET_copy_message (message); 384 p->hello = GNUNET_copy_message(message);
388 if ((p == &p1) && (NULL == p2.oh)) 385 if ((p == &p1) && (NULL == p2.oh))
389 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg, 386 p2.oh = GNUNET_TRANSPORT_offer_hello(p2.cfg,
390 message, 387 message,
391 &offer_hello_done, 388 &offer_hello_done,
392 &p2); 389 &p2);
393 if ((p == &p2) && (NULL == p1.oh)) 390 if ((p == &p2) && (NULL == p1.oh))
394 p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg, 391 p1.oh = GNUNET_TRANSPORT_offer_hello(p1.cfg,
395 message, 392 message,
396 &offer_hello_done, 393 &offer_hello_done,
397 &p1); 394 &p1);
398 395
399 if ((p == &p1) && (p2.hello != NULL) && (NULL == p1.oh) ) 396 if ((p == &p1) && (p2.hello != NULL) && (NULL == p1.oh))
400 p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg, 397 p1.oh = GNUNET_TRANSPORT_offer_hello(p1.cfg,
401 p2.hello, 398 p2.hello,
402 &offer_hello_done, 399 &offer_hello_done,
403 &p1); 400 &p1);
404 if ((p == &p2) && (p1.hello != NULL) && (NULL == p2.oh) ) 401 if ((p == &p2) && (p1.hello != NULL) && (NULL == p2.oh))
405 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg, 402 p2.oh = GNUNET_TRANSPORT_offer_hello(p2.cfg,
406 p1.hello, 403 p1.hello,
407 &offer_hello_done, 404 &offer_hello_done,
408 &p2); 405 &p2);
409} 406}
410 407
411 408
412static void 409static void
413setup_peer (struct PeerContext *p, 410setup_peer(struct PeerContext *p,
414 const char *cfgname) 411 const char *cfgname)
415{ 412{
416 char *binary; 413 char *binary;
417 414
418 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); 415 binary = GNUNET_OS_get_libexec_binary_path("gnunet-service-arm");
419 p->cfg = GNUNET_CONFIGURATION_create (); 416 p->cfg = GNUNET_CONFIGURATION_create();
420 p->arm_proc 417 p->arm_proc
421 = GNUNET_OS_start_process (GNUNET_YES, 418 = GNUNET_OS_start_process(GNUNET_YES,
422 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 419 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
423 NULL, NULL, NULL, 420 NULL, NULL, NULL,
424 binary, 421 binary,
425 "gnunet-service-arm", 422 "gnunet-service-arm",
426 "-c", 423 "-c",
427 cfgname, 424 cfgname,
428 NULL); 425 NULL);
429 GNUNET_assert (GNUNET_OK == 426 GNUNET_assert(GNUNET_OK ==
430 GNUNET_CONFIGURATION_load (p->cfg, 427 GNUNET_CONFIGURATION_load(p->cfg,
431 cfgname)); 428 cfgname));
432 p->ats = GNUNET_ATS_connectivity_init (p->cfg); 429 p->ats = GNUNET_ATS_connectivity_init(p->cfg);
433 GNUNET_assert (NULL != p->ats); 430 GNUNET_assert(NULL != p->ats);
434 p->ghh = GNUNET_TRANSPORT_hello_get (p->cfg, 431 p->ghh = GNUNET_TRANSPORT_hello_get(p->cfg,
435 GNUNET_TRANSPORT_AC_ANY, 432 GNUNET_TRANSPORT_AC_ANY,
436 &process_hello, 433 &process_hello,
437 p); 434 p);
438 GNUNET_free (binary); 435 GNUNET_free(binary);
439} 436}
440 437
441 438
442static void 439static void
443run (void *cls, 440run(void *cls,
444 char *const *args, 441 char *const *args,
445 const char *cfgfile, 442 const char *cfgfile,
446 const struct GNUNET_CONFIGURATION_Handle *cfg) 443 const struct GNUNET_CONFIGURATION_Handle *cfg)
447{ 444{
448 struct GNUNET_MQ_MessageHandler handlers[] = { 445 struct GNUNET_MQ_MessageHandler handlers[] = {
449 GNUNET_MQ_hd_fixed_size (test, 446 GNUNET_MQ_hd_fixed_size(test,
450 MTYPE, 447 MTYPE,
451 struct TestMessage, 448 struct TestMessage,
452 NULL), 449 NULL),
453 GNUNET_MQ_handler_end () 450 GNUNET_MQ_handler_end()
454 }; 451 };
455 452
456 GNUNET_assert (ok == 1); 453 GNUNET_assert(ok == 1);
457 OKPP; 454 OKPP;
458 setup_peer (&p1, 455 setup_peer(&p1,
459 "test_core_api_peer1.conf"); 456 "test_core_api_peer1.conf");
460 setup_peer (&p2, 457 setup_peer(&p2,
461 "test_core_api_peer2.conf"); 458 "test_core_api_peer2.conf");
462 err_task = 459 err_task =
463 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 460 GNUNET_SCHEDULER_add_delayed(TIMEOUT,
464 &terminate_task_error, 461 &terminate_task_error,
465 NULL); 462 NULL);
466 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 463 GNUNET_SCHEDULER_add_shutdown(&do_shutdown,
467 NULL); 464 NULL);
468 465
469 GNUNET_assert (NULL != 466 GNUNET_assert(NULL !=
470 (p1.ch = GNUNET_CORE_connect (p1.cfg, 467 (p1.ch = GNUNET_CORE_connect(p1.cfg,
471 &p1, 468 &p1,
472 &init_notify, 469 &init_notify,
473 &connect_notify, 470 &connect_notify,
474 &disconnect_notify, 471 &disconnect_notify,
475 handlers))); 472 handlers)));
476} 473}
477 474
478 475
479static void 476static void
480stop_arm (struct PeerContext *p) 477stop_arm(struct PeerContext *p)
481{ 478{
482 if (0 != GNUNET_OS_process_kill (p->arm_proc, 479 if (0 != GNUNET_OS_process_kill(p->arm_proc,
483 GNUNET_TERM_SIG)) 480 GNUNET_TERM_SIG))
484 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, 481 GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING,
485 "kill"); 482 "kill");
486 if (GNUNET_OK != GNUNET_OS_process_wait (p->arm_proc)) 483 if (GNUNET_OK != GNUNET_OS_process_wait(p->arm_proc))
487 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, 484 GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING,
488 "waitpid"); 485 "waitpid");
489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 486 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
490 "ARM process %u stopped\n", 487 "ARM process %u stopped\n",
491 GNUNET_OS_process_get_pid (p->arm_proc)); 488 GNUNET_OS_process_get_pid(p->arm_proc));
492 GNUNET_OS_process_destroy (p->arm_proc); 489 GNUNET_OS_process_destroy(p->arm_proc);
493 p->arm_proc = NULL; 490 p->arm_proc = NULL;
494 GNUNET_CONFIGURATION_destroy (p->cfg); 491 GNUNET_CONFIGURATION_destroy(p->cfg);
495} 492}
496 493
497 494
498int 495int
499main (int argc, 496main(int argc,
500 char *argv1[]) 497 char *argv1[])
501{ 498{
502 char *const argv[] = { 499 char *const argv[] = {
503 "test-core-api-reliability", 500 "test-core-api-reliability",
@@ -508,23 +505,24 @@ main (int argc,
508 struct GNUNET_GETOPT_CommandLineOption options[] = { 505 struct GNUNET_GETOPT_CommandLineOption options[] = {
509 GNUNET_GETOPT_OPTION_END 506 GNUNET_GETOPT_OPTION_END
510 }; 507 };
508
511 ok = 1; 509 ok = 1;
512 GNUNET_log_setup ("test-core-api-reliability", 510 GNUNET_log_setup("test-core-api-reliability",
513 "WARNING", 511 "WARNING",
514 NULL); 512 NULL);
515 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 513 GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) - 1,
516 argv, 514 argv,
517 "test-core-api-reliability", 515 "test-core-api-reliability",
518 "nohelp", 516 "nohelp",
519 options, 517 options,
520 &run, 518 &run,
521 &ok); 519 &ok);
522 stop_arm (&p1); 520 stop_arm(&p1);
523 stop_arm (&p2); 521 stop_arm(&p2);
524 GNUNET_free_non_null (p1.hello); 522 GNUNET_free_non_null(p1.hello);
525 GNUNET_free_non_null (p2.hello); 523 GNUNET_free_non_null(p2.hello);
526 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); 524 GNUNET_DISK_directory_remove("/tmp/test-gnunet-core-peer-1");
527 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); 525 GNUNET_DISK_directory_remove("/tmp/test-gnunet-core-peer-2");
528 526
529 return ok; 527 return ok;
530} 528}