diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-07 10:54:03 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-07 10:54:03 +0000 |
commit | ea931ffc94e1f8145c30c98da50cd5ae9dd5147a (patch) | |
tree | a7bb3b5f0fafddeeb00394a7ae83191267e51acd /src | |
parent | ad25eef39dc8c15b85bd70c6585af95d7e687fd5 (diff) | |
download | gnunet-ea931ffc94e1f8145c30c98da50cd5ae9dd5147a.tar.gz gnunet-ea931ffc94e1f8145c30c98da50cd5ae9dd5147a.zip |
- add GNUNET_TESTING_peer_stop_async_cancel()
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_testing_lib.h | 13 | ||||
-rw-r--r-- | src/testing/test_testing_peerstartup2.c | 8 | ||||
-rw-r--r-- | src/testing/testing.c | 18 |
3 files changed, 37 insertions, 2 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index bf5e9e522..6bb92e05d 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -350,6 +350,19 @@ GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer, | |||
350 | 350 | ||
351 | 351 | ||
352 | /** | 352 | /** |
353 | * Cancel a previous asynchronous peer stop request. | ||
354 | * GNUNET_TESTING_peer_stop_async() should have been called before on the given | ||
355 | * peer. It is an error to call this function if the peer stop callback was | ||
356 | * already called | ||
357 | * | ||
358 | * @param peer the peer on which GNUNET_TESTING_peer_stop_async() was called | ||
359 | * before. | ||
360 | */ | ||
361 | void | ||
362 | GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer); | ||
363 | |||
364 | |||
365 | /** | ||
353 | * Signature of the 'main' function for a (single-peer) testcase that | 366 | * Signature of the 'main' function for a (single-peer) testcase that |
354 | * is run using 'GNUNET_TESTING_peer_run'. | 367 | * is run using 'GNUNET_TESTING_peer_run'. |
355 | * | 368 | * |
diff --git a/src/testing/test_testing_peerstartup2.c b/src/testing/test_testing_peerstartup2.c index cd8141b40..959651041 100644 --- a/src/testing/test_testing_peerstartup2.c +++ b/src/testing/test_testing_peerstartup2.c | |||
@@ -148,10 +148,9 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
148 | GNUNET_TESTING_peer_stop_async (test_ctx->peer, | 148 | GNUNET_TESTING_peer_stop_async (test_ctx->peer, |
149 | &peer_status_cb, | 149 | &peer_status_cb, |
150 | test_ctx)); | 150 | test_ctx)); |
151 | |||
152 | } | 151 | } |
153 | else | 152 | else |
154 | do_shutdown (test_ctx, tc); | 153 | do_shutdown2 (test_ctx, tc); |
155 | } | 154 | } |
156 | 155 | ||
157 | 156 | ||
@@ -187,6 +186,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
187 | if (GNUNET_OK != GNUNET_TESTING_peer_start (test_ctx->peer)) | 186 | if (GNUNET_OK != GNUNET_TESTING_peer_start (test_ctx->peer)) |
188 | goto end; | 187 | goto end; |
189 | test_ctx->state = PEER_STARTED; | 188 | test_ctx->state = PEER_STARTED; |
189 | FAIL_TEST (GNUNET_OK == | ||
190 | GNUNET_TESTING_peer_stop_async (test_ctx->peer, | ||
191 | &peer_status_cb, | ||
192 | test_ctx)); | ||
193 | GNUNET_TESTING_peer_stop_async_cancel (test_ctx->peer); | ||
190 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 194 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
191 | &do_shutdown, test_ctx); | 195 | &do_shutdown, test_ctx); |
192 | return; | 196 | return; |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 1b2448ffc..f268c38d1 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1539,6 +1539,24 @@ GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer, | |||
1539 | 1539 | ||
1540 | 1540 | ||
1541 | /** | 1541 | /** |
1542 | * Cancel a previous asynchronous peer stop request. | ||
1543 | * GNUNET_TESTING_peer_stop_async() should have been called before on the given | ||
1544 | * peer. It is an error to call this function if the peer stop callback was | ||
1545 | * already called | ||
1546 | * | ||
1547 | * @param peer the peer on which GNUNET_TESTING_peer_stop_async() was called | ||
1548 | * before. | ||
1549 | */ | ||
1550 | void | ||
1551 | GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer) | ||
1552 | { | ||
1553 | GNUNET_assert (NULL != peer->ah); | ||
1554 | GNUNET_ARM_disconnect_and_free (peer->ah); | ||
1555 | peer->ah = NULL; | ||
1556 | } | ||
1557 | |||
1558 | |||
1559 | /** | ||
1542 | * Destroy the peer. Releases resources locked during peer configuration. | 1560 | * Destroy the peer. Releases resources locked during peer configuration. |
1543 | * If the peer is still running, it will be stopped AND a warning will be | 1561 | * If the peer is still running, it will be stopped AND a warning will be |
1544 | * printed (users of the API should stop the peer explicitly first). | 1562 | * printed (users of the API should stop the peer explicitly first). |