- tests are now performed in its own main tests.c
authorJan Hutter <jhutter@hsr.ch>
Mon, 7 Nov 2005 08:34:40 +0000 (08:34 -0000)
committerJan Hutter <jhutter@hsr.ch>
Mon, 7 Nov 2005 08:34:40 +0000 (08:34 -0000)
-

13 files changed:
Source/charon/daemon.c
Source/charon/packet.c
Source/charon/tests.c [new file with mode: 0644]
Source/charon/tests/event_queue_test.c
Source/charon/tests/event_queue_test.h
Source/charon/tests/job_queue_test.c
Source/charon/tests/job_queue_test.h
Source/charon/tests/linked_list_test.h
Source/charon/tests/socket_test.c
Source/charon/tests/socket_test.h
Source/charon/tests/tests.h [deleted file]
Source/charon/tests/thread_pool_test.c
Source/charon/tests/thread_pool_test.h

index bb970a9..fb50c8e 100644 (file)
  
 #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
index ac559ff..a34a169 100644 (file)
@@ -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 (file)
index 0000000..74dec6b
--- /dev/null
@@ -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;
+}
index 380bbaa..8750d93 100644 (file)
@@ -21,7 +21,7 @@
  */
  
  
-
+#include "event_queue_test.h"
 #include "../tester.h"
 #include "../event_queue.h"
 
index ae1c199..87367f1 100644 (file)
@@ -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_*/
index 7119aca..1fd3357 100644 (file)
  */
 
  
-//#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");
index 80b4a76..c6af6c2 100644 (file)
@@ -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_*/
index ee1548a..59aecdc 100644 (file)
@@ -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_*/
index ae32387..2308087 100644 (file)
@@ -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");
 }
-
index 3798fd1..f3ae837 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef SOCKET_TEST_H_
 #define SOCKET_TEST_H_
 
+#include "../tester.h"
+
 /**
  * @brief Test function for the type socket_t
  * 
  */
 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 (file)
index 91f4612..0000000
+++ /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_*/
index bdde190..1e8ac46 100644 (file)
@@ -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");
 }
-
index 42d6d06..9639fc0 100644 (file)
@@ -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_*/