diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/charon/tests.c | 9 | ||||
-rw-r--r-- | Source/charon/tests/ike_sa_id_test.c | 92 | ||||
-rw-r--r-- | Source/charon/tests/ike_sa_id_test.h | 38 |
3 files changed, 138 insertions, 1 deletions
diff --git a/Source/charon/tests.c b/Source/charon/tests.c index 992117976..23e9a44ad 100644 --- a/Source/charon/tests.c +++ b/Source/charon/tests.c @@ -37,6 +37,7 @@ #include "tests/sender_test.h" #include "tests/scheduler_test.h" #include "tests/receiver_test.h" +#include "tests/ike_sa_id_test.h" /* output for test messages */ @@ -91,11 +92,16 @@ test_t sender_test = {test_sender,"Sender"}; * Test for scheduler_t */ test_t scheduler_test = {test_scheduler,"Scheduler"}; + /** * Test for receiver_t */ test_t receiver_test = {test_receiver,"Receiver"}; +/** + * Test for ike_sa_id_t + */ +test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"}; /** * Global job-queue @@ -133,6 +139,7 @@ socket_t *global_socket; &sender_test, &scheduler_test, &receiver_test, + &ike_sa_id_test, NULL }; @@ -145,7 +152,7 @@ socket_t *global_socket; tester_t *tester = tester_create(test_output, FALSE); tester->perform_tests(tester,all_tests); - /* tester->perform_test(tester,&receiver_test); */ +/* tester->perform_test(tester,&ike_sa_id_test); */ tester->destroy(tester); diff --git a/Source/charon/tests/ike_sa_id_test.c b/Source/charon/tests/ike_sa_id_test.c new file mode 100644 index 000000000..d822bb58a --- /dev/null +++ b/Source/charon/tests/ike_sa_id_test.c @@ -0,0 +1,92 @@ +/** + * @file ike_sa_id_test.c + * + * @brief Tests to test the IKE_SA Identifier class ike_sa_id_test_t + * + */ + +/* + * Copyright (C) 2005 Jan Hutter, Martin Willi + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "ike_sa_id_test.h" +#include "../tester.h" +#include "../ike_sa_id.h" + +/* + * described in Header-File + */ +void test_ike_sa_id(tester_t *tester) +{ + ike_sa_id_t *ike_sa_id, *clone, *equal, *other1, *other2, *other3, *other4; + spi_t initiator, initiator2, responder, responder2; + ike_sa_role_t role; + bool are_equal = FALSE; + + initiator.high = 0; + initiator.low = 0; + + initiator2.high = 12345612; + initiator2.low = 978675; + + responder.high = 34334; + responder.low = 9655; + + responder2.high = 987863; + responder2.low = 3827; + + role = INITIATOR; + + ike_sa_id = ike_sa_id_create(initiator, responder, role); + equal = ike_sa_id_create(initiator, responder, role); + other1 = ike_sa_id_create(initiator, responder2, role); + other2 = ike_sa_id_create(initiator2, responder2, role); + other3 = ike_sa_id_create(initiator2, responder, role); + role = RESPONDER; + other4 = ike_sa_id_create(initiator, responder, role); + + /* check equality */ + tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,equal,&are_equal) == SUCCESS), "equal call check"); + tester->assert_true(tester,(are_equal == TRUE), "equal check"); + tester->assert_true(tester,(equal->equals(equal,ike_sa_id,&are_equal) == SUCCESS), "equal call check"); + tester->assert_true(tester,(are_equal == TRUE), "equal check"); + + /* check clone functionality and equality*/ + tester->assert_true(tester,(ike_sa_id->clone(ike_sa_id,&clone) == SUCCESS), "clone call check"); + tester->assert_false(tester,(clone == ike_sa_id), "clone pointer check"); + tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,clone,&are_equal) == SUCCESS), "equal call check"); + tester->assert_true(tester,(are_equal == TRUE), "equal check"); + + /* check for non equality */ + tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other1,&are_equal) == SUCCESS), "equal call check"); + tester->assert_false(tester,(are_equal == TRUE), "equal check"); + + tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other2,&are_equal) == SUCCESS), "equal call check"); + tester->assert_false(tester,(are_equal == TRUE), "equal check"); + + tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other3,&are_equal) == SUCCESS), "equal call check"); + tester->assert_false(tester,(are_equal == TRUE), "equal check"); + + tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4,&are_equal) == SUCCESS), "equal call check"); + tester->assert_false(tester,(are_equal == TRUE), "equal check"); + + /* check destroy functionality */ + tester->assert_true(tester,(ike_sa_id->destroy(ike_sa_id) == SUCCESS), "destroy call check"); + tester->assert_true(tester,(equal->destroy(equal) == SUCCESS), "destroy call check"); + tester->assert_true(tester,(clone->destroy(clone) == SUCCESS), "destroy call check"); + tester->assert_true(tester,(clone->destroy(other1) == SUCCESS), "destroy call check"); + tester->assert_true(tester,(clone->destroy(other2) == SUCCESS), "destroy call check"); + tester->assert_true(tester,(clone->destroy(other3) == SUCCESS), "destroy call check"); + tester->assert_true(tester,(clone->destroy(other4) == SUCCESS), "destroy call check"); +} diff --git a/Source/charon/tests/ike_sa_id_test.h b/Source/charon/tests/ike_sa_id_test.h new file mode 100644 index 000000000..3f2820cbf --- /dev/null +++ b/Source/charon/tests/ike_sa_id_test.h @@ -0,0 +1,38 @@ +/** + * @file ike_sa_id_test.h + * + * @brief Tests to test the IKE_SA Identifier class ike_sa_id_test_t + * + */ + +/* + * Copyright (C) 2005 Jan Hutter, Martin Willi + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#ifndef IKE_SA_ID_TEST_H_ +#define IKE_SA_ID_TEST_H_ + +#include "../tester.h" + +/** + * @brief Test function used to test the ike_sa_id functionality + * + * Tests are performed using one thread to test the + * features of the ike_sa_id_t. + * + * @param tester associated tester object + */ +void test_ike_sa_id(tester_t *tester); + +#endif /*IKE_SA_ID_TEST_H_*/ |