diff options
author | Reto Buerki <reet@codelabs.ch> | 2012-08-09 12:47:58 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-03-19 15:23:45 +0100 |
commit | 7aa573a50e06fa02c78740abaa4911b35d635b18 (patch) | |
tree | 9362872a8529651f5d954aca5e45f1df6d5ff8c6 /src/charon-tkm/tests/id_manager_tests.c | |
parent | 49c513c1d9361e21836003ed851a0b829a0e2a33 (diff) | |
download | strongswan-7aa573a50e06fa02c78740abaa4911b35d635b18.tar.bz2 strongswan-7aa573a50e06fa02c78740abaa4911b35d635b18.tar.xz |
id_manager: Use array of bool instead of list
Instead of storing the acquired context ids in a linked list, use an
array of booleans for the job. A boolean value of true in the array
designates an available context id.
Diffstat (limited to 'src/charon-tkm/tests/id_manager_tests.c')
-rw-r--r-- | src/charon-tkm/tests/id_manager_tests.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/charon-tkm/tests/id_manager_tests.c b/src/charon-tkm/tests/id_manager_tests.c index 0942c299a..a71727a38 100644 --- a/src/charon-tkm/tests/id_manager_tests.c +++ b/src/charon-tkm/tests/id_manager_tests.c @@ -66,6 +66,23 @@ START_TEST(test_acquire_id_invalid_kind) } END_TEST +START_TEST(test_acquire_id_same) +{ + int id1 = 0, id2 = 0; + tkm_id_manager_t *idmgr = tkm_id_manager_create(); + + id1 = idmgr->acquire_id(idmgr, TKM_CTX_NONCE); + fail_unless(id1 > 0, "Unable to acquire first id"); + + /* Acquire another id, must be different than first */ + id2 = idmgr->acquire_id(idmgr, TKM_CTX_NONCE); + fail_unless(id2 > 0, "Unable to acquire second id"); + fail_unless(id1 != id2, "Same id received twice"); + + idmgr->destroy(idmgr); +} +END_TEST + START_TEST(test_release_id) { int i, id = 0; @@ -123,6 +140,7 @@ TCase *make_id_manager_tests(void) tcase_add_test(tc, test_id_mgr_creation); tcase_add_test(tc, test_acquire_id); tcase_add_test(tc, test_acquire_id_invalid_kind); + tcase_add_test(tc, test_acquire_id_same); tcase_add_test(tc, test_release_id); tcase_add_test(tc, test_release_id_invalid_kind); tcase_add_test(tc, test_release_id_nonexistent); |