- tests are now performed in its own main tests.c
-
This commit is contained in:
parent
8ccd0b01f9
commit
fd9cabd4e6
13 changed files with 128 additions and 103 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
113
Source/charon/tests.c
Normal file
113
Source/charon/tests.c
Normal file
|
@ -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;
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
|
||||
|
||||
#include "event_queue_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../event_queue.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_*/
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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_*/
|
||||
|
|
|
@ -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_*/
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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_*/
|
||||
|
|
|
@ -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_*/
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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_*/
|
||||
|
|
Loading…
Reference in a new issue