diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-11-07 08:34:40 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-11-07 08:34:40 +0000 |
commit | fd9cabd4e68d85877a442ae2fff53c87e687f42b (patch) | |
tree | 4dd4a7e32780f84696466a7ed9da0ddaf9911a1b | |
parent | 8ccd0b01f9fc95eb75d92c4d6b5aad0c4baf3e88 (diff) | |
download | strongswan-fd9cabd4e68d85877a442ae2fff53c87e687f42b.tar.bz2 strongswan-fd9cabd4e68d85877a442ae2fff53c87e687f42b.tar.xz |
- tests are now performed in its own main tests.c
-
-rw-r--r-- | Source/charon/daemon.c | 12 | ||||
-rw-r--r-- | Source/charon/packet.c | 4 | ||||
-rw-r--r-- | Source/charon/tests.c | 113 | ||||
-rw-r--r-- | Source/charon/tests/event_queue_test.c | 2 | ||||
-rw-r--r-- | Source/charon/tests/event_queue_test.h | 5 | ||||
-rw-r--r-- | Source/charon/tests/job_queue_test.c | 5 | ||||
-rw-r--r-- | Source/charon/tests/job_queue_test.h | 5 | ||||
-rw-r--r-- | Source/charon/tests/linked_list_test.h | 16 | ||||
-rw-r--r-- | Source/charon/tests/socket_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/socket_test.h | 8 | ||||
-rw-r--r-- | Source/charon/tests/tests.h | 48 | ||||
-rw-r--r-- | Source/charon/tests/thread_pool_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/thread_pool_test.h | 7 |
13 files changed, 128 insertions, 103 deletions
diff --git a/Source/charon/daemon.c b/Source/charon/daemon.c index bb970a954..fb50c8e5b 100644 --- a/Source/charon/daemon.c +++ b/Source/charon/daemon.c @@ -27,29 +27,17 @@ #include "types.h" #include "tester.h" -#include "tests/tests.h" #include "job_queue.h" - -/* output for test messages */ -extern FILE * stderr; - job_queue_t *job_queue; int main() { - FILE * test_output = stderr; job_queue = job_queue_create(); - tester_t *tester = tester_create(test_output, TRUE); - - tester->test_all(tester,tests); - - tester->destroy(tester); - job_queue->destroy(job_queue); #ifdef LEAK_DETECTIVE diff --git a/Source/charon/packet.c b/Source/charon/packet.c index ac559ffb4..a34a16919 100644 --- a/Source/charon/packet.c +++ b/Source/charon/packet.c @@ -25,7 +25,7 @@ -status_t destroy(packet_t *this) +static status_t destroy(packet_t *this) { pfree(this->data.ptr); pfree(this); @@ -37,6 +37,8 @@ packet_t *packet_create() { packet_t *this = alloc_thing(packet_t, "packet_t"); + this->destroy = destroy; + this->data.len = 0; this->data.ptr = NULL; return this; diff --git a/Source/charon/tests.c b/Source/charon/tests.c new file mode 100644 index 000000000..74dec6bd5 --- /dev/null +++ b/Source/charon/tests.c @@ -0,0 +1,113 @@ +/** + * @file tests.c + * + * @brief Main for all tests + * + */ + +/* + * 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 <stdio.h> +# +#include "tester.h" +#include "job_queue.h" +#include "tests/linked_list_test.h" +#include "tests/thread_pool_test.h" +#include "tests/job_queue_test.h" +#include "tests/event_queue_test.h" +#include "tests/send_queue_test.h" +#include "tests/socket_test.h" + + +/* output for test messages */ +extern FILE * stderr; + + +/** + * Test for linked_list_t + */ +test_t linked_list_test = {test_linked_list,"Linked List"}; + +/** + * Test for linked_list_t with iterator + */ +test_t linked_list_iterator_test = {test_linked_list_iterator,"Linked List Iterator"}; + +/** + * Test for linked_list_t insert and remove + */ +test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"}; + +/** + * Test for event_queue_t + */ +test_t event_queue_test = {test_event_queue,"Event-Queue Test"}; + +/** + * Test 1 for job_queue_t + */ +test_t job_queue_test1 = {test_job_queue,"Job-Queue Test1"}; + +/** + * Test 1 for linked_list_t + */ +test_t send_queue_test = {test_send_queue,"Send-Queue Test"}; + +/** + * Test for socket_t + */ +test_t socket_test = {test_socket,"Socket"}; + +/** + * Test for thread_pool_t + */ +test_t thread_pool_test = {test_thread_pool,"Thread Pool"}; + +job_queue_t *job_queue; + + int main() +{ + FILE * test_output = stderr; + + test_t *all_tests[] ={ +/* &linked_list_test, + &linked_list_iterator_test, + &linked_list_insert_and_remove_test, + &thread_pool_test, + &job_queue_test1, + &event_queue_test,*/ + &send_queue_test, + NULL + }; + + job_queue = job_queue_create(); + + tester_t *tester = tester_create(test_output, TRUE); + + tester->test_all(tester,all_tests); + + tester->destroy(tester); + + job_queue->destroy(job_queue); + +#ifdef LEAK_DETECTIVE + /* Leaks are reported in log file */ + report_leaks(); +#endif + + return 0; +} diff --git a/Source/charon/tests/event_queue_test.c b/Source/charon/tests/event_queue_test.c index 380bbaaf1..8750d93f9 100644 --- a/Source/charon/tests/event_queue_test.c +++ b/Source/charon/tests/event_queue_test.c @@ -21,7 +21,7 @@ */ - +#include "event_queue_test.h" #include "../tester.h" #include "../event_queue.h" diff --git a/Source/charon/tests/event_queue_test.h b/Source/charon/tests/event_queue_test.h index ae1c1996f..87367f120 100644 --- a/Source/charon/tests/event_queue_test.h +++ b/Source/charon/tests/event_queue_test.h @@ -34,9 +34,4 @@ */ void test_event_queue(tester_t *tester); -/** - * Test for event_queue_t - */ -test_t event_queue_test = {test_event_queue,"Event-Queue Test"}; - #endif /*EVENT_QUEUE_TEST_H_*/ diff --git a/Source/charon/tests/job_queue_test.c b/Source/charon/tests/job_queue_test.c index 7119aca0d..1fd335750 100644 --- a/Source/charon/tests/job_queue_test.c +++ b/Source/charon/tests/job_queue_test.c @@ -21,13 +21,14 @@ */ -//#include <stdlib.h> +#include <stdlib.h> #include <freeswan.h> #include <pluto/constants.h> #include <pluto/defs.h> #include <pthread.h> #include <unistd.h> +#include "job_queue_test.h" #include "../tester.h" #include "../job_queue.h" @@ -130,7 +131,7 @@ void test_job_queue(tester_t *tester) } - /* the job-queue has to be empty now! */ + /* the job-queue has to have disered_value count entries! */ tester->assert_true(tester,(job_queue->get_count(job_queue,&value) == SUCCESS), "get count call check"); tester->assert_true(tester,(value == desired_value), "get count value check"); tester->assert_true(tester,(job_queue->destroy(job_queue) == SUCCESS), "destroy call check"); diff --git a/Source/charon/tests/job_queue_test.h b/Source/charon/tests/job_queue_test.h index 80b4a7661..c6af6c26b 100644 --- a/Source/charon/tests/job_queue_test.h +++ b/Source/charon/tests/job_queue_test.h @@ -35,9 +35,4 @@ */ void test_job_queue(tester_t *tester); -/** - * Test 1 for linked_list_t - */ -test_t job_queue_test1 = {test_job_queue,"Job-Queue Test1"}; - #endif /*JOB_QUEUE_TEST_H_*/ diff --git a/Source/charon/tests/linked_list_test.h b/Source/charon/tests/linked_list_test.h index ee1548a60..59aecdc55 100644 --- a/Source/charon/tests/linked_list_test.h +++ b/Source/charon/tests/linked_list_test.h @@ -65,20 +65,4 @@ void test_linked_list_iterator(tester_t *tester); */ void test_linked_list_insert_and_remove(tester_t *tester); -/** - * Test for linked_list_t - */ -test_t linked_list_test = {test_linked_list,"Linked List"}; - -/** - * Test for linked_list_t with iterator - */ -test_t linked_list_iterator_test = {test_linked_list_iterator,"Linked List Iterator"}; - -/** - * Test for linked_list_t insert and remove - */ -test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"}; - - #endif /*LINKED_LIST_TEST_H_*/ diff --git a/Source/charon/tests/socket_test.c b/Source/charon/tests/socket_test.c index ae323879f..230808782 100644 --- a/Source/charon/tests/socket_test.c +++ b/Source/charon/tests/socket_test.c @@ -22,6 +22,8 @@ #include <stdlib.h> #include <string.h> + +#include "socket_test.h" #include "../tester.h" #include "../socket.h" @@ -47,4 +49,3 @@ void test_socket(tester_t *tester) tester->assert_false(tester, strcmp(test_string, pkt->data.ptr), "packet exchange"); } - diff --git a/Source/charon/tests/socket_test.h b/Source/charon/tests/socket_test.h index 3798fd1cf..f3ae83714 100644 --- a/Source/charon/tests/socket_test.h +++ b/Source/charon/tests/socket_test.h @@ -23,6 +23,8 @@ #ifndef SOCKET_TEST_H_ #define SOCKET_TEST_H_ +#include "../tester.h" + /** * @brief Test function for the type socket_t * @@ -30,11 +32,5 @@ */ void test_socket(tester_t *tester); -/** - * Test for socket_t - */ -test_t socket_test = {test_socket,"Socket"}; - - #endif /*SOCKET_TEST_H_*/ diff --git a/Source/charon/tests/tests.h b/Source/charon/tests/tests.h deleted file mode 100644 index 91f4612c6..000000000 --- a/Source/charon/tests/tests.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file tests.h - * - * @brief Lists all the tests to be processed by the tester object - * - * New tests have to be added here! - * - */ - -/* - * 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 TESTS_H_ -#define TESTS_H_ - -#include "../tester.h" -#include "linked_list_test.h" -#include "thread_pool_test.h" -#include "job_queue_test.h" -#include "event_queue_test.h" - - -/** - * @brief these tests are getting performed by the tester - */ -test_t *tests[] ={ - &linked_list_test, - &linked_list_iterator_test, - &linked_list_insert_and_remove_test, - &thread_pool_test, - &job_queue_test1, - &event_queue_test, - NULL -}; - -#endif /*TESTS_H_*/ diff --git a/Source/charon/tests/thread_pool_test.c b/Source/charon/tests/thread_pool_test.c index bdde1900f..1e8ac4646 100644 --- a/Source/charon/tests/thread_pool_test.c +++ b/Source/charon/tests/thread_pool_test.c @@ -21,6 +21,8 @@ */ #include <stdlib.h> + +#include "thread_pool_test.h" #include "../tester.h" #include "../thread_pool.h" @@ -37,4 +39,3 @@ void test_thread_pool(tester_t *tester) tester->assert_true(tester, (desired_pool_size == pool_size), "thread creation"); tester->assert_true(tester, (pool->destroy(pool) == SUCCESS), "threadpool destruction"); } - diff --git a/Source/charon/tests/thread_pool_test.h b/Source/charon/tests/thread_pool_test.h index 42d6d0635..9639fc062 100644 --- a/Source/charon/tests/thread_pool_test.h +++ b/Source/charon/tests/thread_pool_test.h @@ -23,6 +23,8 @@ #ifndef THREAD_POOL_TEST_H_ #define THREAD_POOL_TEST_H_ +#include "../tester.h" + /** * @brief Test function for the type thread_pool_t * @@ -30,9 +32,4 @@ */ void test_thread_pool(tester_t *tester); -/** - * Test for thread_pool_t - */ -test_t thread_pool_test = {test_thread_pool,"Thread Pool"}; - #endif /*THREAD_POOL_TEST_H_*/ |