- implemented event_queue

- defined tests for the event_queue
This commit is contained in:
Jan Hutter
2005-11-04 13:21:25 +00:00
parent db5dc98603
commit ae758c7934
9 changed files with 584 additions and 1 deletions
+67
View File
@@ -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");
}
+42
View File
@@ -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_*/
+2
View File
@@ -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
*
+2
View File
@@ -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
*
+2
View File
@@ -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
};