aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Source/charon/tests')
-rw-r--r--Source/charon/tests/event_queue_test.c67
-rw-r--r--Source/charon/tests/event_queue_test.h42
-rw-r--r--Source/charon/tests/job_queue_test.h2
-rw-r--r--Source/charon/tests/linked_list_test.h2
-rw-r--r--Source/charon/tests/tests.h2
5 files changed, 115 insertions, 0 deletions
diff --git a/Source/charon/tests/event_queue_test.c b/Source/charon/tests/event_queue_test.c
new file mode 100644
index 000000000..380bbaaf1
--- /dev/null
+++ b/Source/charon/tests/event_queue_test.c
@@ -0,0 +1,67 @@
+/**
+ * @file event_queue_test.h
+ *
+ * @brief Tests to test the Event-Queue type event_queue_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 "../tester.h"
+#include "../event_queue.h"
+
+void test_event_queue(tester_t *tester)
+{
+ event_queue_t * event_queue = event_queue_create();
+ timeval_t current_time;
+ timeval_t time1, time2, time3;
+ job_t * current_job;
+ int count;
+ job_t * job1 = job_create(INCOMING_PACKET,"incoming packet");
+ job_t * job2 = job_create(RETRANSMIT_REQUEST,"retransmit request");
+ job_t * job3 = job_create(ESTABLISH_IKE_SA,"establish ike sa");
+
+ gettimeofday(&current_time,NULL);
+ time1.tv_usec = 0;
+ time1.tv_sec = current_time.tv_sec + 3;
+ time2.tv_usec = 0;
+ time2.tv_sec = current_time.tv_sec + 12;
+ time3.tv_usec = 0;
+ time3.tv_sec = current_time.tv_sec + 12;
+
+ tester->assert_true(tester,(event_queue->add(event_queue,job1,time1) == SUCCESS), "add call check");
+ tester->assert_true(tester,(event_queue->get_count(event_queue,&count) == SUCCESS), "get_count call check");
+ tester->assert_true(tester,(count == 1), "count value check");
+
+ tester->assert_true(tester,(event_queue->add(event_queue,job2,time2) == SUCCESS), "add call check");
+ tester->assert_true(tester,(event_queue->get_count(event_queue,&count) == SUCCESS), "get_count call check");
+ tester->assert_true(tester,(count == 2), "count value check");
+
+ tester->assert_true(tester,(event_queue->add(event_queue,job3,time3) == SUCCESS), "add call check");
+ tester->assert_true(tester,(event_queue->get_count(event_queue,&count) == SUCCESS), "get_count call check");
+ tester->assert_true(tester,(count == 3), "count value check");
+
+ tester->assert_true(tester,(event_queue->get(event_queue,&current_job) == SUCCESS), "get call check");
+ fprintf(stderr,"%s\n",(char *) current_job->assigned_data);
+ tester->assert_true(tester,(event_queue->get(event_queue,&current_job) == SUCCESS), "get call check");
+ fprintf(stderr,"%s\n",(char *) current_job->assigned_data);
+ tester->assert_true(tester,(event_queue->get(event_queue,&current_job) == SUCCESS), "get call check");
+ fprintf(stderr,"%s\n",(char *) current_job->assigned_data);
+
+ tester->assert_true(tester,(event_queue->destroy(event_queue) == SUCCESS), "destroy call check");
+}
diff --git a/Source/charon/tests/event_queue_test.h b/Source/charon/tests/event_queue_test.h
new file mode 100644
index 000000000..ae1c1996f
--- /dev/null
+++ b/Source/charon/tests/event_queue_test.h
@@ -0,0 +1,42 @@
+/**
+ * @file event_queue_test.h
+ *
+ * @brief Tests to test the Event-Queue type event_queue_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 EVENT_QUEUE_TEST_H_
+#define EVENT_QUEUE_TEST_H_
+
+#include "../tester.h"
+
+/**
+ * @brief Test function used to test the event_queue functionality
+ *
+ * Tests are performed using one thread
+ *
+ * @param tester associated tester object
+ */
+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.h b/Source/charon/tests/job_queue_test.h
index ba8fd02bb..80b4a7661 100644
--- a/Source/charon/tests/job_queue_test.h
+++ b/Source/charon/tests/job_queue_test.h
@@ -23,6 +23,8 @@
#ifndef JOB_QUEUE_TEST_H_
#define JOB_QUEUE_TEST_H_
+#include "../tester.h"
+
/**
* @brief Test function used to test the job_queue functionality
*
diff --git a/Source/charon/tests/linked_list_test.h b/Source/charon/tests/linked_list_test.h
index 4038e0917..ee1548a60 100644
--- a/Source/charon/tests/linked_list_test.h
+++ b/Source/charon/tests/linked_list_test.h
@@ -23,6 +23,8 @@
#ifndef LINKED_LIST_TEST_H_
#define LINKED_LIST_TEST_H_
+#include "../tester.h"
+
/**
* @brief Test function for the type linked_list_t
*
diff --git a/Source/charon/tests/tests.h b/Source/charon/tests/tests.h
index d3ac30982..91f4612c6 100644
--- a/Source/charon/tests/tests.h
+++ b/Source/charon/tests/tests.h
@@ -29,6 +29,7 @@
#include "linked_list_test.h"
#include "thread_pool_test.h"
#include "job_queue_test.h"
+#include "event_queue_test.h"
/**
@@ -40,6 +41,7 @@ test_t *tests[] ={
&linked_list_insert_and_remove_test,
&thread_pool_test,
&job_queue_test1,
+ &event_queue_test,
NULL
};