diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/charon/ike_sa.h | 4 | ||||
-rw-r--r-- | Source/charon/tests.c | 9 | ||||
-rw-r--r-- | Source/charon/tests/ike_sa_test.c | 67 | ||||
-rw-r--r-- | Source/charon/tests/ike_sa_test.h | 36 |
4 files changed, 113 insertions, 3 deletions
diff --git a/Source/charon/ike_sa.h b/Source/charon/ike_sa.h index f4fbd79a0..75f09a74c 100644 --- a/Source/charon/ike_sa.h +++ b/Source/charon/ike_sa.h @@ -70,8 +70,8 @@ struct ike_sa_s { * Creates an ike_sa_t-object with a specific ike_sa_id_t-object * * @param[in] ike_sa_id ike_sa_id_t-object to associate with new IKE_SA. - * The object is internal getting cloned - * and so has to be destroyed by the caller. + * The object is internal getting cloned + * and so has to be destroyed by the caller. * * @warning the Content of internal ike_sa_id_t-Object can change over time * e.g. when a IKE_SA_INIT has been finished diff --git a/Source/charon/tests.c b/Source/charon/tests.c index 23e9a44ad..67066a0ca 100644 --- a/Source/charon/tests.c +++ b/Source/charon/tests.c @@ -38,6 +38,7 @@ #include "tests/scheduler_test.h" #include "tests/receiver_test.h" #include "tests/ike_sa_id_test.h" +#include "tests/ike_sa_test.h" /* output for test messages */ @@ -104,6 +105,11 @@ test_t receiver_test = {test_receiver,"Receiver"}; test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"}; /** + * Test for ike_sa_t + */ +test_t ike_sa_test = {test_ike_sa,"IKE_SA"}; + +/** * Global job-queue */ job_queue_t *global_job_queue; @@ -140,6 +146,7 @@ socket_t *global_socket; &scheduler_test, &receiver_test, &ike_sa_id_test, + &ike_sa_test, NULL }; @@ -152,7 +159,7 @@ socket_t *global_socket; tester_t *tester = tester_create(test_output, FALSE); tester->perform_tests(tester,all_tests); -/* tester->perform_test(tester,&ike_sa_id_test); */ +/* tester->perform_test(tester,&ike_sa_test); */ tester->destroy(tester); diff --git a/Source/charon/tests/ike_sa_test.c b/Source/charon/tests/ike_sa_test.c new file mode 100644 index 000000000..894eafac9 --- /dev/null +++ b/Source/charon/tests/ike_sa_test.c @@ -0,0 +1,67 @@ +/** + * @file ike_sa_test.c + * + * @brief Tests to test the IKE_SA type ike_sa_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_test.h" +#include "../types.h" +#include "../tester.h" +#include "../message.h" +#include "../configuration.h" +#include "../ike_sa.h" + +void test_ike_sa(tester_t *tester) +{ + ike_sa_t *ike_sa; + ike_sa_id_t *ike_sa_id; + spi_t initiator, responder; + ike_sa_role_t role; + message_t *message; + configuration_t *configuration; + + + initiator.high = 0; + initiator.low = 0; + responder.high = 34334; + responder.low = 9655; + role = INITIATOR; + /* create a ike_sa_id object for the new IKE_SA */ + ike_sa_id = ike_sa_id_create(initiator, responder, role); + + /* empty message and configuration objects are created */ + message = message_create(); + configuration = configuration_create(); + + + /* test every ike_sa function */ + ike_sa = ike_sa_create(ike_sa_id); + + tester->assert_true(tester,(ike_sa != NULL), "ike_sa pointer check"); + + tester->assert_true(tester,(ike_sa->process_message(ike_sa,message) == SUCCESS), "process_message call check"); + + tester->assert_true(tester,(ike_sa->process_configuration(ike_sa,configuration) == SUCCESS), "process_configuration call check"); + + tester->assert_true(tester,(ike_sa->destroy(ike_sa) == SUCCESS), "destroy call check"); + + ike_sa_id->destroy(ike_sa_id); + message->destroy(message); + configuration->destroy(configuration); +} diff --git a/Source/charon/tests/ike_sa_test.h b/Source/charon/tests/ike_sa_test.h new file mode 100644 index 000000000..6bc02df2b --- /dev/null +++ b/Source/charon/tests/ike_sa_test.h @@ -0,0 +1,36 @@ +/** + * @file ike_sa_test.h + * + * @brief Tests to test the IKE_SA type ike_sa_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_TEST_H_ +#define IKE_SA_TEST_H_ + +#include "../tester.h" + +/** + * @brief Test function used to test the ike_sa_t functionality + * + * + * @param tester associated tester_t-object + */ +void test_ike_sa(tester_t *tester); + +#endif /*IKE_SA_TEST_H_*/ |