diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-27 13:48:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-27 13:48:21 +0000 |
commit | beae62bfc73edc1784efbcbb8efd74c07a057865 (patch) | |
tree | 953a0890b0d2bbdea5427e57fa91c72ffee2b018 /src/conversation/test_conversation_api_twocalls.c | |
parent | 9db237899dd8db104328221e6911fcbbf9d0f3cf (diff) | |
download | gnunet-beae62bfc73edc1784efbcbb8efd74c07a057865.tar.gz gnunet-beae62bfc73edc1784efbcbb8efd74c07a057865.zip |
handle failures more gracefully in test
Diffstat (limited to 'src/conversation/test_conversation_api_twocalls.c')
-rw-r--r-- | src/conversation/test_conversation_api_twocalls.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/conversation/test_conversation_api_twocalls.c b/src/conversation/test_conversation_api_twocalls.c index 17a12eb4f..2e2a73e3f 100644 --- a/src/conversation/test_conversation_api_twocalls.c +++ b/src/conversation/test_conversation_api_twocalls.c | |||
@@ -73,7 +73,9 @@ static GNUNET_MICROPHONE_RecordedDataCallback phone_rdc; | |||
73 | 73 | ||
74 | static void *phone_rdc_cls; | 74 | static void *phone_rdc_cls; |
75 | 75 | ||
76 | static struct GNUNET_SCHEDULER_Task * phone_task; | 76 | static struct GNUNET_SCHEDULER_Task *phone_task; |
77 | |||
78 | static struct GNUNET_SCHEDULER_Task *timeout_task; | ||
77 | 79 | ||
78 | /** | 80 | /** |
79 | * Variable for recognizing caller1 | 81 | * Variable for recognizing caller1 |
@@ -338,14 +340,33 @@ static struct GNUNET_MICROPHONE_Handle phone_mic = { | |||
338 | 340 | ||
339 | 341 | ||
340 | /** | 342 | /** |
341 | * Signature of the main function of a task. | 343 | * Function run on timeout. |
342 | * | 344 | * |
343 | * @param cls closure | 345 | * @param cls closure |
344 | */ | 346 | */ |
345 | static void | 347 | static void |
346 | end_test (void *cls) | 348 | end_test (void *cls) |
347 | { | 349 | { |
350 | timeout_task = NULL; | ||
351 | fprintf (stderr, | ||
352 | "Timeout!\n"); | ||
348 | GNUNET_SCHEDULER_shutdown (); | 353 | GNUNET_SCHEDULER_shutdown (); |
354 | } | ||
355 | |||
356 | |||
357 | /** | ||
358 | * Function run on shutdown. | ||
359 | * | ||
360 | * @param cls closure | ||
361 | */ | ||
362 | static void | ||
363 | do_shutdown (void *cls) | ||
364 | { | ||
365 | if (NULL != timeout_task) | ||
366 | { | ||
367 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
368 | timeout_task = NULL; | ||
369 | } | ||
349 | if (NULL != op) | 370 | if (NULL != op) |
350 | { | 371 | { |
351 | GNUNET_IDENTITY_cancel (op); | 372 | GNUNET_IDENTITY_cancel (op); |
@@ -485,6 +506,11 @@ call_event_handler (void *cls, | |||
485 | break; | 506 | break; |
486 | case GNUNET_CONVERSATION_EC_CALL_ERROR: | 507 | case GNUNET_CONVERSATION_EC_CALL_ERROR: |
487 | GNUNET_break (0); | 508 | GNUNET_break (0); |
509 | if (0 == strcmp (cid, "call1")) | ||
510 | call1 = NULL; | ||
511 | else | ||
512 | call2 = NULL; | ||
513 | GNUNET_SCHEDULER_shutdown (); | ||
488 | break; | 514 | break; |
489 | } | 515 | } |
490 | } | 516 | } |
@@ -592,8 +618,11 @@ run (void *cls, | |||
592 | struct GNUNET_TESTING_Peer *peer) | 618 | struct GNUNET_TESTING_Peer *peer) |
593 | { | 619 | { |
594 | cfg = c; | 620 | cfg = c; |
595 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, | 621 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
596 | NULL); | 622 | &end_test, |
623 | NULL); | ||
624 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
625 | NULL); | ||
597 | id = GNUNET_IDENTITY_connect (cfg, | 626 | id = GNUNET_IDENTITY_connect (cfg, |
598 | &identity_cb, | 627 | &identity_cb, |
599 | NULL); | 628 | NULL); |