- renamed tests to testcases
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* @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 <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "../allocator.h"
|
||||
#include "event_queue_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../event_queue.h"
|
||||
|
||||
/**
|
||||
* Number of different times to insert per thread
|
||||
*/
|
||||
#define EVENT_QUEUE_TIMES 5
|
||||
/**
|
||||
* Number of entries per time per thread
|
||||
*/
|
||||
#define EVENT_QUEUE_ENTRY_PER_TIME 20
|
||||
|
||||
/**
|
||||
* Number of test-thread
|
||||
*/
|
||||
#define EVENT_QUEUE_INSERT_THREADS 15
|
||||
|
||||
/**
|
||||
* @brief Informations for the involved test-thread used in this test
|
||||
*
|
||||
*/
|
||||
typedef struct event_queue_test_s event_queue_test_t;
|
||||
|
||||
struct event_queue_test_s{
|
||||
tester_t *tester;
|
||||
event_queue_t *event_queue;
|
||||
|
||||
/**
|
||||
* number of different event times to be inserted in the event-queue by each thread
|
||||
*/
|
||||
int insert_times_count;
|
||||
|
||||
/**
|
||||
* number of event to insert at one time
|
||||
*/
|
||||
int entries_per_time;
|
||||
};
|
||||
|
||||
|
||||
static void event_queue_insert_thread(event_queue_test_t * testinfos)
|
||||
{
|
||||
timeval_t current_time;
|
||||
tester_t *tester = testinfos->tester;
|
||||
timeval_t time;
|
||||
job_t * job;
|
||||
int i,j;
|
||||
|
||||
gettimeofday(¤t_time,NULL);
|
||||
for (i = 0; i < testinfos->insert_times_count;i++)
|
||||
{
|
||||
for (j = 0; j < testinfos->entries_per_time;j++)
|
||||
{
|
||||
int *value = allocator_alloc_thing(int);
|
||||
*value = i;
|
||||
job = job_create(INCOMING_PACKET,value);
|
||||
time.tv_usec = 0;
|
||||
time.tv_sec = current_time.tv_sec + i;
|
||||
|
||||
tester->assert_true(tester,(testinfos->event_queue->add_absolute(testinfos->event_queue,job,time) == SUCCESS), "add call check");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_event_queue(tester_t *tester)
|
||||
{
|
||||
event_queue_t * event_queue = event_queue_create();
|
||||
event_queue_test_t testinfos;
|
||||
pthread_t threads[EVENT_QUEUE_INSERT_THREADS];
|
||||
int i,j, number_of_total_events;
|
||||
timeval_t current_time, start_time;
|
||||
|
||||
testinfos.tester = tester;
|
||||
testinfos.event_queue = event_queue;
|
||||
testinfos.insert_times_count = EVENT_QUEUE_TIMES;
|
||||
testinfos.entries_per_time = EVENT_QUEUE_ENTRY_PER_TIME;
|
||||
|
||||
number_of_total_events = EVENT_QUEUE_ENTRY_PER_TIME * EVENT_QUEUE_TIMES * EVENT_QUEUE_INSERT_THREADS;
|
||||
|
||||
gettimeofday(&start_time,NULL);
|
||||
|
||||
for (i = 0; i < EVENT_QUEUE_INSERT_THREADS; i++)
|
||||
{
|
||||
pthread_create( &threads[i], NULL,(void*(*)(void*)) &event_queue_insert_thread, (void*) &testinfos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* wait for all threads */
|
||||
for (i = 0; i < EVENT_QUEUE_INSERT_THREADS; i++)
|
||||
{
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
tester->assert_true(tester,(event_queue->get_count(event_queue) == number_of_total_events), "event count check");
|
||||
|
||||
for (i = 0; i < EVENT_QUEUE_TIMES;i++)
|
||||
{
|
||||
for (j = 0; j < (EVENT_QUEUE_ENTRY_PER_TIME * EVENT_QUEUE_INSERT_THREADS);j++)
|
||||
{
|
||||
job_t *job;
|
||||
tester->assert_true(tester,(event_queue->get(event_queue,&job) == SUCCESS), "get call check");
|
||||
gettimeofday(¤t_time,NULL);
|
||||
tester->assert_true(tester,((current_time.tv_sec - start_time.tv_sec) == i), "value of entry check");
|
||||
|
||||
allocator_free(job->assigned_data);
|
||||
tester->assert_true(tester,(job->destroy(job) == SUCCESS), "job destroy call check");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tester->assert_true(tester,(event_queue->destroy(event_queue) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @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);
|
||||
|
||||
#endif /*EVENT_QUEUE_TEST_H_*/
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @file generator.h
|
||||
*
|
||||
* @brief Tests to test the Generator class generator_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 <string.h>
|
||||
|
||||
#include "../globals.h"
|
||||
#include "../allocator.h"
|
||||
#include "../logger_manager.h"
|
||||
#include "generator_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../logger.h"
|
||||
#include "../encodings.h"
|
||||
#include "../generator.h"
|
||||
#include "../encodings/ike_header.h"
|
||||
|
||||
extern payload_info_t *payload_infos[];
|
||||
|
||||
/*
|
||||
* Described in Header
|
||||
*/
|
||||
void test_generator_with_unsupported_payload(tester_t *tester)
|
||||
{
|
||||
generator_t *generator;
|
||||
generator_context_t *generator_context;
|
||||
void * data_struct;
|
||||
|
||||
generator = generator_create(payload_infos);
|
||||
tester->assert_true(tester,(generator != NULL), "generator create check");
|
||||
|
||||
generator_context = generator->create_context(generator);
|
||||
|
||||
tester->assert_true(tester,(generator->generate_payload(generator,(payload_type_t) -1,data_struct,generator_context) == NOT_SUPPORTED),"generate_payload call check");
|
||||
|
||||
generator_context->destroy(generator_context);
|
||||
|
||||
tester->assert_true(tester,(generator->destroy(generator) == SUCCESS), "generator destroy call check");
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in Header
|
||||
*/
|
||||
void test_generator_with_header_payload(tester_t *tester)
|
||||
{
|
||||
generator_t *generator;
|
||||
generator_context_t *generator_context;
|
||||
ike_header_t header_data;
|
||||
chunk_t generated_data;
|
||||
status_t status;
|
||||
logger_t *logger;
|
||||
|
||||
global_logger_manager->get_logger(global_logger_manager,TESTER,&logger,"header payload");
|
||||
|
||||
header_data.initiator_spi = 1;
|
||||
header_data.responder_spi = 2;
|
||||
header_data.next_payload = 3;
|
||||
header_data.maj_version = 4;
|
||||
header_data.min_version = 5;
|
||||
header_data.exchange_type = 6;
|
||||
header_data.flags.initiator = TRUE;
|
||||
header_data.flags.version = FALSE;
|
||||
header_data.flags.response = TRUE;
|
||||
header_data.message_id = 7;
|
||||
header_data.length = 8;
|
||||
|
||||
generator = generator_create(payload_infos);
|
||||
tester->assert_true(tester,(generator != NULL), "generator create check");
|
||||
|
||||
generator_context = generator->create_context(generator);
|
||||
tester->assert_true(tester,(generator_context != NULL), "generator_context create check");
|
||||
|
||||
status = generator->generate_payload(generator,HEADER,&header_data,generator_context);
|
||||
tester->assert_true(tester,(status == SUCCESS),"generate_payload call check");
|
||||
|
||||
tester->assert_true(tester,(generator->write_to_chunk(generator,generator_context,&generated_data) == SUCCESS),"write_to_chunk call check");
|
||||
|
||||
u_int8_t expected_generation[] = {
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x02,
|
||||
0x03,0x45,0x06,0x28,
|
||||
0x00,0x00,0x00,0x07,
|
||||
0x00,0x00,0x00,0x08,
|
||||
};
|
||||
|
||||
|
||||
tester->assert_true(tester,(generated_data.len == sizeof(expected_generation)), "compare generated data length");
|
||||
logger->log_chunk(logger,RAW,"generated header",&generated_data);
|
||||
tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data 1");
|
||||
allocator_free_chunk(generated_data);
|
||||
generator_context->destroy(generator_context);
|
||||
|
||||
|
||||
header_data.initiator_spi = 0x22000054231234;
|
||||
header_data.responder_spi = 0x122398;
|
||||
header_data.next_payload = 0xF3;
|
||||
header_data.maj_version = 0x2;
|
||||
header_data.min_version = 0x0;
|
||||
header_data.exchange_type = 0x12;
|
||||
header_data.flags.initiator = TRUE;
|
||||
header_data.flags.version = TRUE;
|
||||
header_data.flags.response = TRUE;
|
||||
header_data.message_id = 0x33AFF3;
|
||||
header_data.length = 0xAA11F;
|
||||
|
||||
generator_context = generator->create_context(generator);
|
||||
|
||||
status = generator->generate_payload(generator,HEADER,&header_data,generator_context);
|
||||
tester->assert_true(tester,(status == SUCCESS),"generate_payload call check");
|
||||
|
||||
tester->assert_true(tester,(generator->write_to_chunk(generator,generator_context,&generated_data) == SUCCESS),"write_to_chunk call check");
|
||||
|
||||
u_int8_t expected_generation2[] = {
|
||||
0x00,0x22,0x00,0x00,
|
||||
0x54,0x23,0x12,0x34,
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x00,0x12,0x23,0x98,
|
||||
0xF3,0x20,0x12,0x38,
|
||||
0x00,0x33,0xAF,0xF3,
|
||||
0x00,0x0A,0xA1,0x1F,
|
||||
};
|
||||
|
||||
logger->log_chunk(logger,RAW,"generated header",&generated_data);
|
||||
|
||||
tester->assert_true(tester,(memcmp(expected_generation2,generated_data.ptr,sizeof(expected_generation2)) == 0), "compare generated data 2");
|
||||
allocator_free_chunk(generated_data);
|
||||
|
||||
generator_context->destroy(generator_context);
|
||||
global_logger_manager->destroy_logger(global_logger_manager,logger);
|
||||
tester->assert_true(tester,(generator->destroy(generator) == SUCCESS), "generator destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @file generator.h
|
||||
*
|
||||
* @brief Tests to test the Generator class generator_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 GENERATOR_TEST_H_
|
||||
#define GENERATOR_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the generator with unsupported payload
|
||||
*
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*/
|
||||
void test_generator_with_unsupported_payload(tester_t *tester);
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the generator with header payload
|
||||
*
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*/
|
||||
void test_generator_with_header_payload(tester_t *tester);
|
||||
|
||||
#endif /*GENERATOR_TEST_H_*/
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file ike_sa_id_test.c
|
||||
*
|
||||
* @brief Tests to test the IKE_SA Identifier class ike_sa_id_test_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 "ike_sa_id_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../ike_sa_id.h"
|
||||
|
||||
/*
|
||||
* described in Header-File
|
||||
*/
|
||||
void test_ike_sa_id(tester_t *tester)
|
||||
{
|
||||
ike_sa_id_t *ike_sa_id, *clone, *equal, *other1, *other2, *other3, *other4;
|
||||
spi_t initiator, initiator2, responder, responder2;
|
||||
ike_sa_role_t role;
|
||||
bool are_equal = FALSE;
|
||||
|
||||
initiator.high = 0;
|
||||
initiator.low = 0;
|
||||
|
||||
initiator2.high = 12345612;
|
||||
initiator2.low = 978675;
|
||||
|
||||
responder.high = 34334;
|
||||
responder.low = 9655;
|
||||
|
||||
responder2.high = 987863;
|
||||
responder2.low = 3827;
|
||||
|
||||
role = INITIATOR;
|
||||
|
||||
ike_sa_id = ike_sa_id_create(initiator, responder, role);
|
||||
equal = ike_sa_id_create(initiator, responder, role);
|
||||
other1 = ike_sa_id_create(initiator, responder2, role);
|
||||
other2 = ike_sa_id_create(initiator2, responder2, role);
|
||||
other3 = ike_sa_id_create(initiator2, responder, role);
|
||||
role = RESPONDER;
|
||||
other4 = ike_sa_id_create(initiator, responder, role);
|
||||
|
||||
/* check equality */
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,equal,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_true(tester,(are_equal == TRUE), "equal check");
|
||||
tester->assert_true(tester,(equal->equals(equal,ike_sa_id,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_true(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
/* check clone functionality and equality*/
|
||||
tester->assert_true(tester,(ike_sa_id->clone(ike_sa_id,&clone) == SUCCESS), "clone call check");
|
||||
tester->assert_false(tester,(clone == ike_sa_id), "clone pointer check");
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,clone,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_true(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
/* check for non equality */
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other1,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_false(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other2,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_false(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other3,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_false(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_false(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
tester->assert_true(tester,(other4->replace_values(other4,ike_sa_id) == SUCCESS), "replace values call check");
|
||||
tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,other4,&are_equal) == SUCCESS), "equal call check");
|
||||
tester->assert_true(tester,(are_equal == TRUE), "equal check");
|
||||
|
||||
|
||||
/* check destroy functionality */
|
||||
tester->assert_true(tester,(ike_sa_id->destroy(ike_sa_id) == SUCCESS), "destroy call check");
|
||||
tester->assert_true(tester,(equal->destroy(equal) == SUCCESS), "destroy call check");
|
||||
tester->assert_true(tester,(clone->destroy(clone) == SUCCESS), "destroy call check");
|
||||
tester->assert_true(tester,(other1->destroy(other1) == SUCCESS), "destroy call check");
|
||||
tester->assert_true(tester,(other2->destroy(other2) == SUCCESS), "destroy call check");
|
||||
tester->assert_true(tester,(other3->destroy(other3) == SUCCESS), "destroy call check");
|
||||
tester->assert_true(tester,(other4->destroy(other4) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file ike_sa_id_test.h
|
||||
*
|
||||
* @brief Tests to test the IKE_SA Identifier class ike_sa_id_test_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 IKE_SA_ID_TEST_H_
|
||||
#define IKE_SA_ID_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the ike_sa_id functionality
|
||||
*
|
||||
* Tests are performed using one thread to test the
|
||||
* features of the ike_sa_id_t.
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*/
|
||||
void test_ike_sa_id(tester_t *tester);
|
||||
|
||||
#endif /*IKE_SA_ID_TEST_H_*/
|
||||
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* @file ike_sa_manager_test.c
|
||||
*
|
||||
* @brief Tests to test the IKE_SA-Manager type ike_sa_manager_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 <string.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ike_sa_manager_test.h"
|
||||
#include "../types.h"
|
||||
#include "../tester.h"
|
||||
#include "../ike_sa_manager.h"
|
||||
|
||||
|
||||
static struct ike_sa_manager_test_struct_s {
|
||||
tester_t *tester;
|
||||
ike_sa_manager_t *isam;
|
||||
} td;
|
||||
|
||||
static void test1_thread(ike_sa_id_t *ike_sa_id)
|
||||
{
|
||||
ike_sa_t *ike_sa;
|
||||
status_t status;
|
||||
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
td.tester->assert_true(td.tester, (status == SUCCESS), "checkout of a blocked ike_sa");
|
||||
usleep(10000);
|
||||
status = td.isam->checkin(td.isam, ike_sa);
|
||||
td.tester->assert_true(td.tester, (status == SUCCESS), "checkin of a requested ike_sa");
|
||||
}
|
||||
|
||||
|
||||
static void test2_thread(ike_sa_id_t *ike_sa_id)
|
||||
{
|
||||
ike_sa_t *ike_sa;
|
||||
status_t status;
|
||||
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
td.tester->assert_true(td.tester, (status == NOT_FOUND), "IKE_SA already deleted");
|
||||
}
|
||||
|
||||
static void test3_thread(ike_sa_id_t *ike_sa_id)
|
||||
{
|
||||
ike_sa_t *ike_sa;
|
||||
status_t status;
|
||||
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
td.tester->assert_true(td.tester, (status == NOT_FOUND), "IKE_SA already deleted");
|
||||
|
||||
ike_sa_id->destroy(ike_sa_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void test_ike_sa_manager(tester_t *tester)
|
||||
{
|
||||
status_t status;
|
||||
spi_t initiator, responder;
|
||||
ike_sa_id_t *ike_sa_id, *sa_id;
|
||||
ike_sa_t *ike_sa;
|
||||
int thread_count = 200;
|
||||
int sa_count = 100;
|
||||
int i;
|
||||
pthread_t threads[thread_count];
|
||||
|
||||
td.tester = tester;
|
||||
td.isam = ike_sa_manager_create();
|
||||
tester->assert_true(tester, (td.isam != NULL), "ike_sa_manager creation");
|
||||
|
||||
|
||||
|
||||
|
||||
/* First Test:
|
||||
* we play initiator for IKE_SA_INIT first
|
||||
* create an IKE_SA,
|
||||
*
|
||||
*/
|
||||
memset(&initiator, 0, sizeof(initiator));
|
||||
memset(&responder, 0, sizeof(responder));
|
||||
|
||||
ike_sa_id = ike_sa_id_create(initiator, responder, INITIATOR);
|
||||
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA");
|
||||
/* for testing purposes, we manipulate the responder spi.
|
||||
* this is usually done be the response from the communication partner,
|
||||
* but we don't have one...
|
||||
*/
|
||||
responder.low = 123;
|
||||
|
||||
sa_id = ike_sa->get_id(ike_sa);
|
||||
sa_id->set_responder_spi(sa_id, responder);
|
||||
/* check in, so we should have a "completed" sa, specified by ike_sa_id */
|
||||
status = td.isam->checkin(td.isam, ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "checkin modified IKE_SA");
|
||||
|
||||
/* now we check it out and start some other threads */
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "checkout existing IKE_SA 1");
|
||||
|
||||
for (i = 0; i < thread_count; i++)
|
||||
{
|
||||
if (pthread_create(&threads[i], NULL, (void*(*)(void*))test1_thread, (void*)ike_sa_id))
|
||||
{
|
||||
/* failed, decrease list */
|
||||
thread_count--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
|
||||
status = td.isam->checkin(td.isam, ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "checkin IKE_SA");
|
||||
|
||||
|
||||
sleep(1);
|
||||
/* we now delete the IKE_SA, while it is requested by the threads.
|
||||
* this should block until the have done their work.*/
|
||||
status = td.isam->delete(td.isam, ike_sa_id);
|
||||
tester->assert_true(tester, (status == SUCCESS), "delete IKE_SA by id");
|
||||
|
||||
|
||||
for (i = 0; i < thread_count; i++)
|
||||
{
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
ike_sa_id->destroy(ike_sa_id);
|
||||
|
||||
|
||||
/* Second Test:
|
||||
* now we simulate our partner initiates an IKE_SA_INIT,
|
||||
* so we are the responder.
|
||||
*
|
||||
*/
|
||||
memset(&initiator, 0, sizeof(initiator));
|
||||
memset(&responder, 0, sizeof(responder));
|
||||
|
||||
initiator.low = 123;
|
||||
ike_sa_id = ike_sa_id_create(initiator, responder, RESPONDER);
|
||||
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 2");
|
||||
for (i = 0; i < thread_count; i++)
|
||||
{
|
||||
if (pthread_create(&threads[i], NULL, (void*(*)(void*))test2_thread, (void*)ike_sa_id))
|
||||
{
|
||||
/* failed, decrease list */
|
||||
thread_count--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
/* let them go acquiring */
|
||||
sleep(1);
|
||||
|
||||
/* this time, we delete the ike_sa while its checked out */
|
||||
td.isam->checkin_and_delete(td.isam, ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "delete IKE_SA by SA");
|
||||
|
||||
for (i = 0; i < thread_count; i++)
|
||||
{
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
ike_sa_id->destroy(ike_sa_id);
|
||||
|
||||
/* Third Test:
|
||||
* put in a lot of IKE_SAs, check it out, set a thread waiting
|
||||
* and destroy the manager...
|
||||
*/
|
||||
|
||||
memset(&initiator, 0, sizeof(initiator));
|
||||
memset(&responder, 0, sizeof(responder));
|
||||
|
||||
thread_count = sa_count;
|
||||
|
||||
for (i = 0; i < sa_count; i++)
|
||||
{
|
||||
initiator.low = i + 1;
|
||||
ike_sa_id = ike_sa_id_create(initiator, responder, RESPONDER);
|
||||
|
||||
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
|
||||
tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 3");
|
||||
|
||||
if (pthread_create(&threads[i], NULL, (void*(*)(void*))test3_thread, (void*)ike_sa_id))
|
||||
{
|
||||
/* failed, decrease list */
|
||||
thread_count--;
|
||||
}
|
||||
}
|
||||
|
||||
/* let them go acquiring */
|
||||
sleep(1);
|
||||
|
||||
status = td.isam->destroy(td.isam);
|
||||
tester->assert_true(tester, (status == SUCCESS), "ike_sa_manager destruction");
|
||||
|
||||
for (i = 0; i < thread_count; i++)
|
||||
{
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file ike_sa_manager_test.c
|
||||
*
|
||||
* @brief Tests to test the IKE_SA-Manager type ike_sa_manager_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 IKE_SA_MANAGER_TEST_H_
|
||||
#define IKE_SA_MANAGER_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the ike_sa_manager_t functionality
|
||||
*
|
||||
*
|
||||
* @param tester associated tester_t object
|
||||
*/
|
||||
void test_ike_sa_manager(tester_t *tester);
|
||||
|
||||
|
||||
|
||||
#endif /*IKE_SA_MANAGER_TEST_H_*/
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @file ike_sa_test.c
|
||||
*
|
||||
* @brief Tests to test the IKE_SA type ike_sa_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 "ike_sa_test.h"
|
||||
#include "../types.h"
|
||||
#include "../tester.h"
|
||||
#include "../message.h"
|
||||
#include "../configuration.h"
|
||||
#include "../ike_sa.h"
|
||||
|
||||
void test_ike_sa(tester_t *tester)
|
||||
{
|
||||
ike_sa_t *ike_sa;
|
||||
ike_sa_id_t *ike_sa_id;
|
||||
spi_t initiator, responder;
|
||||
ike_sa_role_t role;
|
||||
message_t *message;
|
||||
configuration_t *configuration;
|
||||
|
||||
|
||||
initiator.high = 0;
|
||||
initiator.low = 0;
|
||||
responder.high = 34334;
|
||||
responder.low = 9655;
|
||||
role = INITIATOR;
|
||||
/* create a ike_sa_id object for the new IKE_SA */
|
||||
ike_sa_id = ike_sa_id_create(initiator, responder, role);
|
||||
|
||||
/* empty message and configuration objects are created */
|
||||
message = message_create();
|
||||
configuration = configuration_create();
|
||||
|
||||
|
||||
/* test every ike_sa function */
|
||||
ike_sa = ike_sa_create(ike_sa_id);
|
||||
|
||||
tester->assert_true(tester,(ike_sa != NULL), "ike_sa pointer check");
|
||||
|
||||
tester->assert_true(tester,(ike_sa->process_message(ike_sa,message) == SUCCESS), "process_message call check");
|
||||
|
||||
tester->assert_true(tester,(ike_sa->process_configuration(ike_sa,configuration) == SUCCESS), "process_configuration call check");
|
||||
|
||||
tester->assert_true(tester,(ike_sa->destroy(ike_sa) == SUCCESS), "destroy call check");
|
||||
|
||||
ike_sa_id->destroy(ike_sa_id);
|
||||
message->destroy(message);
|
||||
configuration->destroy(configuration);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file ike_sa_test.h
|
||||
*
|
||||
* @brief Tests to test the IKE_SA type ike_sa_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 IKE_SA_TEST_H_
|
||||
#define IKE_SA_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the ike_sa_t functionality
|
||||
*
|
||||
*
|
||||
* @param tester associated tester_t object
|
||||
*/
|
||||
void test_ike_sa(tester_t *tester);
|
||||
|
||||
#endif /*IKE_SA_TEST_H_*/
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* @file job_queue_test.c
|
||||
*
|
||||
* @brief Tests to test the Job-Queue type job_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 <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../allocator.h"
|
||||
#include "job_queue_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../job_queue.h"
|
||||
|
||||
|
||||
typedef struct job_queue_test_s job_queue_test_t;
|
||||
|
||||
/**
|
||||
* @brief Informations for the involved test-thread used in this test
|
||||
*
|
||||
*/
|
||||
struct job_queue_test_s{
|
||||
tester_t *tester;
|
||||
job_queue_t *job_queue;
|
||||
/**
|
||||
* number of items to be inserted in the job-queue
|
||||
*/
|
||||
int insert_item_count;
|
||||
/**
|
||||
* number of items to be removed by each
|
||||
* receiver thread from the job-queue
|
||||
*/
|
||||
int remove_item_count;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief sender thread used in the the job_queue test function
|
||||
*
|
||||
* @param testinfo informations for the specific thread.
|
||||
*/
|
||||
static void test_job_queue_sender(job_queue_test_t * testinfo)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < testinfo->insert_item_count; i++)
|
||||
{
|
||||
int *value = allocator_alloc_thing(int);
|
||||
*value = i;
|
||||
job_t *job = job_create(INCOMING_PACKET,value);
|
||||
testinfo->job_queue->add(testinfo->job_queue,job);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief receiver thread used in the the job_queue test function
|
||||
*
|
||||
* @param testinfo informations for the specific thread.
|
||||
*/
|
||||
static void test_job_queue_receiver(job_queue_test_t * testinfo)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < testinfo->remove_item_count; i++)
|
||||
{
|
||||
job_t *job;
|
||||
testinfo->tester->assert_true(testinfo->tester,(testinfo->job_queue->get(testinfo->job_queue,&job) == SUCCESS), "get job call check");
|
||||
testinfo->tester->assert_true(testinfo->tester,(job->type == INCOMING_PACKET), "job type check");
|
||||
allocator_free(job->assigned_data);
|
||||
testinfo->tester->assert_true(testinfo->tester,(job->destroy(job) == SUCCESS), "job destroy call check");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* description is in header file
|
||||
*/
|
||||
void test_job_queue(tester_t *tester)
|
||||
{
|
||||
int desired_value, i;
|
||||
int sender_count = 10;
|
||||
int receiver_count = 2;
|
||||
pthread_t sender_threads[sender_count];
|
||||
pthread_t receiver_threads[receiver_count];
|
||||
job_queue_t *job_queue = job_queue_create();
|
||||
job_queue_test_t test_infos;
|
||||
|
||||
test_infos.tester = tester;
|
||||
test_infos.job_queue = job_queue;
|
||||
test_infos.insert_item_count = 10000;
|
||||
test_infos.remove_item_count = 50000;
|
||||
|
||||
|
||||
desired_value = test_infos.insert_item_count * sender_count -
|
||||
test_infos.remove_item_count * receiver_count;
|
||||
|
||||
for (i = 0; i < receiver_count;i++)
|
||||
{
|
||||
pthread_create( &receiver_threads[i], NULL,(void*(*)(void*)) &test_job_queue_receiver, (void*) &test_infos);
|
||||
}
|
||||
for (i = 0; i < sender_count;i++)
|
||||
{
|
||||
pthread_create( &sender_threads[i], NULL,(void*(*)(void*)) &test_job_queue_sender, (void*) &test_infos);
|
||||
}
|
||||
|
||||
|
||||
/* Wait for all threads */
|
||||
for (i = 0; i < sender_count;i++)
|
||||
{
|
||||
pthread_join(sender_threads[i], NULL);
|
||||
}
|
||||
for (i = 0; i < receiver_count;i++)
|
||||
{
|
||||
pthread_join(receiver_threads[i], NULL);
|
||||
}
|
||||
|
||||
/* the job-queue has to have disered_value count entries! */
|
||||
tester->assert_true(tester,(job_queue->get_count(job_queue) == desired_value), "get count value check");
|
||||
|
||||
tester->assert_true(tester,(job_queue->destroy(job_queue) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file job_queue_test.h
|
||||
*
|
||||
* @brief Tests to test the Job-Queue type job_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 JOB_QUEUE_TEST_H_
|
||||
#define JOB_QUEUE_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the job_queue functionality
|
||||
*
|
||||
* Tests are performed using different threads to test the multi-threaded
|
||||
* features of the job_queue_t.
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*/
|
||||
void test_job_queue(tester_t *tester);
|
||||
|
||||
#endif /*JOB_QUEUE_TEST_H_*/
|
||||
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* @file linked_list_test.c
|
||||
*
|
||||
* @brief Tests to test the Linked List type linked_list_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 <string.h>
|
||||
|
||||
#include "../tester.h"
|
||||
#include "../linked_list.h"
|
||||
|
||||
/*
|
||||
* Description in header-file
|
||||
*/
|
||||
void test_linked_list(tester_t *tester)
|
||||
{
|
||||
void *test_value = NULL;
|
||||
|
||||
linked_list_t *linked_list = linked_list_create();
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 0), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"one");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 1), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"two");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 2), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"three");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"four");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"five");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 5), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_first(linked_list,&test_value) == SUCCESS), "get_first call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"five") == 0), "get_first value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 5), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_last(linked_list,&test_value) == SUCCESS), "get_last call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "get_last value check");
|
||||
tester->assert_true(tester,( linked_list->get_count(linked_list) == 5), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->remove_first(linked_list,&test_value) == SUCCESS), "remove_first call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"five") == 0), "remove_first value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_first(linked_list,&test_value) == SUCCESS), "get_first call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"four") == 0), "get_first value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_last(linked_list,&test_value) == SUCCESS), "get_last call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "get_last value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->remove_last(linked_list,&test_value) == SUCCESS), "remove_last call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"one") == 0), "remove_last value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_last(linked_list,&test_value) == SUCCESS), "get_last call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"two") == 0), "get_last value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_first(linked_list,&test_value) == SUCCESS), "get_first call check");
|
||||
tester->assert_true(tester,(strcmp((char *) test_value,"four") == 0), "get_first value check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->destroy(linked_list) == SUCCESS), "destroy call check");
|
||||
}
|
||||
|
||||
/*
|
||||
* Description in header-file
|
||||
*/
|
||||
void test_linked_list_iterator(tester_t *tester)
|
||||
{
|
||||
void * value;
|
||||
|
||||
linked_list_t *linked_list = linked_list_create();
|
||||
linked_list->insert_first(linked_list,"one");
|
||||
linked_list->insert_first(linked_list,"two");
|
||||
linked_list->insert_first(linked_list,"three");
|
||||
linked_list->insert_first(linked_list,"four");
|
||||
linked_list->insert_first(linked_list,"five");
|
||||
|
||||
linked_list_iterator_t * iterator;
|
||||
linked_list_iterator_t * iterator2;
|
||||
|
||||
|
||||
tester->assert_true(tester,(linked_list->create_iterator(linked_list,&iterator,TRUE) == SUCCESS), "create_iterator for it 1 call check");
|
||||
|
||||
tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"five") == 0), "it 1 current value check");
|
||||
|
||||
tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"four") == 0), "it 1 current value check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->create_iterator(linked_list,&iterator2,FALSE) == SUCCESS), "create_iterator for it 2 call check");
|
||||
|
||||
tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
|
||||
iterator2->current(iterator2,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"one") == 0), "it 2 current value check");
|
||||
|
||||
tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "it 1 current value check");
|
||||
|
||||
tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
|
||||
iterator2->current(iterator2,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"two") == 0), "it 2 current value check");
|
||||
|
||||
tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"two") == 0), "it 1 current value check");
|
||||
|
||||
tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
|
||||
iterator2->current(iterator2,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "it 2 current value check");
|
||||
|
||||
tester->assert_true(tester,iterator->has_next(iterator), "it 1 has_next value check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"one") == 0), "it 1 current value check");
|
||||
|
||||
tester->assert_false(tester,iterator->has_next(iterator), "it 1 has_next value check");
|
||||
|
||||
tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
|
||||
tester->assert_true(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
|
||||
tester->assert_false(tester,iterator2->has_next(iterator2), "it 2 has_next value check");
|
||||
|
||||
tester->assert_true(tester,(iterator->destroy(iterator) == SUCCESS), "it 1 destroy call check");
|
||||
|
||||
tester->assert_true(tester,(iterator2->destroy(iterator2) == SUCCESS), "it 2 destroy call check");
|
||||
|
||||
linked_list->destroy(linked_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Description in header-file
|
||||
*/
|
||||
void test_linked_list_insert_and_remove(tester_t *tester)
|
||||
{
|
||||
void *value;
|
||||
linked_list_iterator_t * iterator;
|
||||
|
||||
linked_list_t *linked_list = linked_list_create();
|
||||
linked_list->insert_first(linked_list,"one");
|
||||
linked_list->insert_first(linked_list,"two");
|
||||
|
||||
linked_list->insert_first(linked_list,"three");
|
||||
linked_list->insert_first(linked_list,"four");
|
||||
linked_list->insert_first(linked_list,"five");
|
||||
|
||||
|
||||
|
||||
linked_list->create_iterator(linked_list,&iterator,TRUE);
|
||||
|
||||
iterator->has_next(iterator);
|
||||
iterator->has_next(iterator);
|
||||
iterator->has_next(iterator);
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "current value check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->insert_before(linked_list,iterator,"before_three") == SUCCESS), "insert_before call check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "current value check");
|
||||
|
||||
|
||||
tester->assert_true(tester,(linked_list->insert_after(linked_list,iterator,"after_three") == SUCCESS), "insert_after call check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"three") == 0), "current value check");
|
||||
|
||||
|
||||
tester->assert_true(tester,(linked_list->remove(linked_list,iterator) == SUCCESS), "remove call check");
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"before_three") == 0), "current value check");
|
||||
|
||||
iterator->reset(iterator);
|
||||
|
||||
iterator->has_next(iterator);
|
||||
iterator->has_next(iterator);
|
||||
iterator->has_next(iterator);
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"before_three") == 0), "current value check");
|
||||
iterator->has_next(iterator);
|
||||
iterator->current(iterator,&value);
|
||||
tester->assert_true(tester,(strcmp((char *) value,"after_three") == 0), "current value check");
|
||||
|
||||
iterator->destroy(iterator);
|
||||
|
||||
linked_list->destroy(linked_list);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file linked_list_test.h
|
||||
*
|
||||
* @brief Tests to test the Linked List type linked_list_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 LINKED_LIST_TEST_H_
|
||||
#define LINKED_LIST_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function for the type linked_list_t
|
||||
*
|
||||
* Performs different kinds of assertions to check the functionality
|
||||
* of the linked_list_t in a Single-Threaded environment.
|
||||
*
|
||||
* @warning To be usable in multi-threaded software
|
||||
* this list has to get protected with locks.
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_linked_list(tester_t *tester);
|
||||
|
||||
/**
|
||||
* @brief Test function for the type linked_list_t and its iterator
|
||||
*
|
||||
* Performs different kinds of assertions to check the functionality
|
||||
* of the linked_list_t and its iterator in a Single-Threaded environment.
|
||||
*
|
||||
* @warning To be usable in multi-threaded software
|
||||
* this list has to get protected with locks.
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_linked_list_iterator(tester_t *tester);
|
||||
|
||||
/**
|
||||
* @brief Test function for the type linked_list_t and its insert and remove
|
||||
* functions
|
||||
*
|
||||
* Performs different kinds of assertions to check the functionality
|
||||
* of the linked_list_t and its insert and remove functions
|
||||
*
|
||||
* @warning To be usable in multi-threaded software
|
||||
* this list has to get protected with locks.
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_linked_list_insert_and_remove(tester_t *tester);
|
||||
|
||||
#endif /*LINKED_LIST_TEST_H_*/
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file packet_test.c
|
||||
*
|
||||
* @brief Tests to test the class type packet_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 <string.h>
|
||||
#include "packet_test.h"
|
||||
#include "../allocator.h"
|
||||
#include "../packet.h"
|
||||
|
||||
|
||||
/*
|
||||
* Described in Header
|
||||
*/
|
||||
void test_packet(tester_t *tester)
|
||||
{
|
||||
packet_t *packet = packet_create(AF_INET);
|
||||
packet_t *packet2;
|
||||
char * string_to_copy = "aha, soso";
|
||||
|
||||
packet->data.ptr = allocator_alloc_thing(string_to_copy);
|
||||
packet->data.len = sizeof(string_to_copy);
|
||||
memcpy(packet->data.ptr,string_to_copy,packet->data.len);
|
||||
|
||||
tester->assert_true(tester,(packet != NULL),"NULL pointer check");
|
||||
|
||||
tester->assert_true(tester,(packet->clone(packet,&packet2) == SUCCESS),"clone call check");
|
||||
|
||||
tester->assert_false(tester,(packet->data.ptr == packet2->data.ptr),"value pointer check");
|
||||
|
||||
tester->assert_true(tester,(memcmp(packet->data.ptr,packet2->data.ptr,packet->data.len) == 0),"cloned value check");
|
||||
|
||||
tester->assert_true(tester,(packet->family == packet2->family),"cloned value check");
|
||||
tester->assert_true(tester,(packet->sockaddr_len == packet2->sockaddr_len),"cloned value check");
|
||||
tester->assert_true(tester,(memcmp(&(packet->source),&(packet2->source), sizeof(struct sockaddr)) == 0),"cloned value check");
|
||||
tester->assert_true(tester,(memcmp(&(packet->destination),&(packet2->destination), sizeof(struct sockaddr)) == 0),"cloned value check");
|
||||
|
||||
|
||||
packet2->destroy(packet2);
|
||||
packet->destroy(packet);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file packet_test.h
|
||||
*
|
||||
* @brief Tests to test the class type packet_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 PACKET_TEST_H_
|
||||
#define PACKET_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the packet_t functionality
|
||||
*
|
||||
*
|
||||
* @param tester associated tester_t object
|
||||
*/
|
||||
void test_packet(tester_t *tester);
|
||||
|
||||
#endif /*PACKET_TEST_H_*/
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @file parser_test.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 <string.h>
|
||||
|
||||
#include "../allocator.h"
|
||||
#include "parser_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../logger_manager.h"
|
||||
#include "../encodings.h"
|
||||
#include "../generator.h"
|
||||
#include "../parser.h"
|
||||
#include "../encodings/ike_header.h"
|
||||
|
||||
extern payload_info_t *payload_infos[];
|
||||
|
||||
extern logger_manager_t *global_logger_manager;
|
||||
|
||||
|
||||
/*
|
||||
* Described in Header
|
||||
*/
|
||||
void test_parser_with_header_payload(tester_t *tester)
|
||||
{
|
||||
parser_t *parser;
|
||||
parser_context_t *parser_context;
|
||||
ike_header_t *header_data;
|
||||
status_t status;
|
||||
chunk_t test_chunk;
|
||||
|
||||
logger_t *logger;
|
||||
|
||||
global_logger_manager->get_logger(global_logger_manager,TESTER,&logger,"header payload");
|
||||
|
||||
u_int8_t test_bytes[] = {
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x02,
|
||||
0x03,0x45,0x06,0x28,
|
||||
0x00,0x00,0x00,0x07,
|
||||
0x00,0x00,0x00,0x08,
|
||||
};
|
||||
test_chunk.ptr = test_bytes;
|
||||
test_chunk.len = sizeof(test_bytes);
|
||||
|
||||
|
||||
parser = parser_create(payload_infos);
|
||||
tester->assert_true(tester,(parser != NULL), "parser create check");
|
||||
|
||||
parser_context = parser->create_context(parser, test_chunk);
|
||||
tester->assert_true(tester,(parser_context != NULL), "parser_context create check");
|
||||
|
||||
status = parser->parse_payload(parser, HEADER, (void**)&header_data, parser_context);
|
||||
tester->assert_true(tester,(status == SUCCESS),"parse_payload call check");
|
||||
|
||||
tester->assert_true(tester,(header_data->initiator_spi == 1),"parsed initiator_spi value");
|
||||
tester->assert_true(tester,(header_data->responder_spi == 2),"parsed responder_spi value");
|
||||
tester->assert_true(tester,(header_data->next_payload == 3),"parsed next_payload value");
|
||||
tester->assert_true(tester,(header_data->maj_version == 4),"parsed maj_version value");
|
||||
tester->assert_true(tester,(header_data->min_version == 5),"parsed min_version value");
|
||||
tester->assert_true(tester,(header_data->exchange_type == 6),"parsed exchange_type value");
|
||||
tester->assert_true(tester,(header_data->flags.initiator == TRUE),"parsed flags.initiator value");
|
||||
tester->assert_true(tester,(header_data->flags.version == FALSE),"parsed flags.version value");
|
||||
tester->assert_true(tester,(header_data->flags.response == TRUE),"parsed flags.response value");
|
||||
tester->assert_true(tester,(header_data->message_id == 7),"parsed message_id value");
|
||||
tester->assert_true(tester,(header_data->length == 8),"parsed length value");
|
||||
|
||||
|
||||
parser_context->destroy(parser_context);
|
||||
tester->assert_true(tester,(parser->destroy(parser) == SUCCESS), "parser destroy call check");
|
||||
|
||||
logger->log_bytes(logger, RAW, "Header", (void*)header_data, sizeof(ike_header_t));
|
||||
|
||||
allocator_free(header_data);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file parser_test.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 PARSER_TEST_H_
|
||||
#define PARSER_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
|
||||
void test_parser_with_header_payload(tester_t *tester);
|
||||
|
||||
#endif /*PARSER_TEST_H_*/
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file receiver_test.c
|
||||
*
|
||||
* @brief Tests to test the Receiver (type receiver_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 <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../allocator.h"
|
||||
#include "sender_test.h"
|
||||
#include "../globals.h"
|
||||
#include "../receiver.h"
|
||||
#include "../packet.h"
|
||||
#include "../socket.h"
|
||||
#include "../send_queue.h"
|
||||
#include "../job_queue.h"
|
||||
|
||||
/**
|
||||
* Number of packets to send by sender-thread
|
||||
*/
|
||||
#define NUMBER_OF_PACKETS_TO_SEND 100
|
||||
|
||||
/**
|
||||
* Port to send the packets to
|
||||
*/
|
||||
#define PORT_TO_SEND 4600
|
||||
|
||||
/**
|
||||
* Destination IP Address
|
||||
*/
|
||||
#define DESTINATION_IP "127.0.0.1"
|
||||
|
||||
void test_receiver(tester_t *tester)
|
||||
{
|
||||
int i;
|
||||
receiver_t *receiver;
|
||||
packet_t *packet;
|
||||
job_t *job;
|
||||
packet_t *received_packet;
|
||||
receiver = receiver_create();
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
packet = packet_create(AF_INET);
|
||||
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
|
||||
packet->data.ptr = allocator_alloc_thing(int);
|
||||
packet->data.len = ( sizeof(int));
|
||||
*((int *) (packet->data.ptr)) = i;
|
||||
global_socket->send(global_socket,packet);
|
||||
packet->destroy(packet);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
global_job_queue->get(global_job_queue,&job);
|
||||
tester->assert_true(tester, (job->type == INCOMING_PACKET), "job type check");
|
||||
received_packet = (packet_t *) job->assigned_data;
|
||||
tester->assert_true(tester, (received_packet->data.len == (sizeof(int))), "received data length check");
|
||||
tester->assert_true(tester, (i == *((int *)(received_packet->data.ptr))), "received data value check");
|
||||
received_packet->destroy(received_packet);
|
||||
|
||||
job->destroy(job);
|
||||
}
|
||||
|
||||
tester->assert_true(tester, (receiver->destroy(receiver) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file receiver_test.h
|
||||
*
|
||||
* @brief Tests to test the Receiver (type receiver_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 RECEIVER_TEST_H_
|
||||
#define RECEIVER_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function for the type receiver_t
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_receiver(tester_t *tester);
|
||||
|
||||
#endif /*RECEIVER_TEST_H_*/
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file scheduler_test.c
|
||||
*
|
||||
* @brief Tests to test the Scheduler (type scheduler_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 <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "scheduler_test.h"
|
||||
#include "../globals.h"
|
||||
#include "../scheduler.h"
|
||||
#include "../event_queue.h"
|
||||
#include "../job_queue.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief implementation of a scheduler test
|
||||
*
|
||||
* This one uses relative time events, which are not that exact.
|
||||
* Test may fail on too slow machines.
|
||||
*/
|
||||
void test_scheduler(tester_t *tester)
|
||||
{
|
||||
int job_count = 5;
|
||||
job_t *jobs[job_count];
|
||||
int current;
|
||||
scheduler_t *scheduler = scheduler_create();
|
||||
|
||||
/* schedule 5 jobs */
|
||||
for (current = 0; current < job_count; current++)
|
||||
{
|
||||
jobs[current] = job_create(INCOMING_PACKET, (void*)current);
|
||||
global_event_queue->add_relative(global_event_queue, jobs[current], (current+1) * 500);
|
||||
}
|
||||
|
||||
|
||||
for (current = 0; current < job_count; current++)
|
||||
{
|
||||
jobs[current] = NULL;
|
||||
}
|
||||
|
||||
usleep(50 * 1000);
|
||||
|
||||
/* check if times are correct */
|
||||
for (current = 0; current < job_count; current++)
|
||||
{
|
||||
usleep(400 * 1000);
|
||||
|
||||
tester->assert_true(tester, (global_job_queue->get_count(global_job_queue) == current ), "job-queue size before event");
|
||||
tester->assert_true(tester, (global_event_queue->get_count(global_event_queue) == job_count - current), "event-queue size before event");
|
||||
usleep(100 * 1000);
|
||||
|
||||
tester->assert_true(tester, (global_job_queue->get_count(global_job_queue) == current + 1), "job-queue size after event");
|
||||
tester->assert_true(tester, (global_event_queue->get_count(global_event_queue) == job_count - current - 1), "event-queue size after event");
|
||||
}
|
||||
|
||||
/* check job order */
|
||||
for (current = 0; current < job_count; current++)
|
||||
{
|
||||
global_job_queue->get(global_job_queue, &(jobs[current]));
|
||||
tester->assert_true(tester, ((int)jobs[current]->assigned_data == current), "job order");
|
||||
jobs[current]->destroy(jobs[current]);
|
||||
}
|
||||
|
||||
/* destruction test */
|
||||
tester->assert_true(tester, (scheduler->destroy(scheduler) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file scheduler_test.h
|
||||
*
|
||||
* @brief Tests to test the scheduler (type scheduler_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 SCHEDULER_TEST_H_
|
||||
#define SCHEDULER_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function for the type scheduler_t
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_scheduler(tester_t *tester);
|
||||
|
||||
#endif /*SCHEDULER_TEST_H_*/
|
||||
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* @file send_queue_test.c
|
||||
*
|
||||
* @brief Tests to test the Send-Queue type send_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 <pthread.h>
|
||||
|
||||
#include "send_queue_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../send_queue.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Informations for the involved test-thread used in this test
|
||||
*
|
||||
*/
|
||||
typedef struct send_queue_test_s send_queue_test_t;
|
||||
|
||||
|
||||
struct send_queue_test_s{
|
||||
/**
|
||||
* Associated tester_t object
|
||||
*/
|
||||
tester_t *tester;
|
||||
|
||||
/**
|
||||
* Queue to test
|
||||
*/
|
||||
send_queue_t *send_queue;
|
||||
|
||||
/**
|
||||
* number of items to be inserted in the send-queue by each thread
|
||||
*/
|
||||
int insert_item_count;
|
||||
|
||||
/**
|
||||
* number of items to be removed by each
|
||||
* receiver thread from the send-queue
|
||||
*/
|
||||
int remove_item_count;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief sender thread used in the the send_queue test function
|
||||
*
|
||||
* @param testinfo informations for the specific thread.
|
||||
*/
|
||||
static void test_send_queue_sender(send_queue_test_t * testinfo)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < testinfo->insert_item_count; i++)
|
||||
{
|
||||
packet_t *packet = packet_create(AF_INET);
|
||||
testinfo->tester->assert_true(testinfo->tester,(packet != NULL), "create packet call check");
|
||||
testinfo->tester->assert_true(testinfo->tester,(testinfo->send_queue->add(testinfo->send_queue,packet) == SUCCESS), "add packet call check");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief receiver thread used in the the send_queue test function
|
||||
*
|
||||
* @param testinfo informations for the specific thread.
|
||||
*/
|
||||
static void test_send_queue_receiver(send_queue_test_t * testinfo)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < testinfo->remove_item_count; i++)
|
||||
{
|
||||
packet_t *packet;
|
||||
testinfo->tester->assert_true(testinfo->tester,(testinfo->send_queue->get(testinfo->send_queue,&packet) == SUCCESS), "get packet call check");
|
||||
|
||||
testinfo->tester->assert_true(testinfo->tester,( packet != NULL), "packet not NULL call check");
|
||||
|
||||
testinfo->tester->assert_true(testinfo->tester,( packet->destroy(packet) == SUCCESS), "packet destroy call check");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* description is in header file
|
||||
*/
|
||||
void test_send_queue(tester_t *tester)
|
||||
{
|
||||
int desired_value, i;
|
||||
int sender_count = 10;
|
||||
int receiver_count = 2;
|
||||
pthread_t sender_threads[sender_count];
|
||||
pthread_t receiver_threads[receiver_count];
|
||||
send_queue_t *send_queue = send_queue_create();
|
||||
send_queue_test_t test_infos;
|
||||
|
||||
test_infos.tester = tester;
|
||||
test_infos.send_queue = send_queue;
|
||||
test_infos.insert_item_count = 10000;
|
||||
test_infos.remove_item_count = 10000;
|
||||
|
||||
|
||||
desired_value = test_infos.insert_item_count * sender_count -
|
||||
test_infos.remove_item_count * receiver_count;
|
||||
|
||||
for (i = 0; i < receiver_count;i++)
|
||||
{
|
||||
pthread_create( &receiver_threads[i], NULL,(void*(*)(void*)) &test_send_queue_receiver, (void*) &test_infos);
|
||||
}
|
||||
|
||||
for (i = 0; i < sender_count;i++)
|
||||
{
|
||||
pthread_create( &sender_threads[i], NULL,(void*(*)(void*)) &test_send_queue_sender, (void*) &test_infos);
|
||||
}
|
||||
|
||||
|
||||
/* Wait for all threads */
|
||||
for (i = 0; i < sender_count;i++)
|
||||
{
|
||||
pthread_join(sender_threads[i], NULL);
|
||||
}
|
||||
for (i = 0; i < receiver_count;i++)
|
||||
{
|
||||
pthread_join(receiver_threads[i], NULL);
|
||||
}
|
||||
|
||||
|
||||
/* the send-queue has to have diserd_value count entries*/
|
||||
tester->assert_true(tester,(send_queue->get_count(send_queue) == desired_value), "count value check");
|
||||
tester->assert_true(tester,(send_queue->destroy(send_queue) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file send_queue_test.h
|
||||
*
|
||||
* @brief Tests to test the Send-Queue type send_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 SEND_QUEUE_TEST_H_
|
||||
#define SEND_QUEUE_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function used to test the send_queue functionality
|
||||
*
|
||||
* Tests are performed using different threads to test the multi-threaded
|
||||
* features of the send_queue_t.
|
||||
*
|
||||
* @param tester associated tester object
|
||||
*/
|
||||
void test_send_queue(tester_t *tester);
|
||||
|
||||
#endif /*SEND_QUEUE_TEST_H_*/
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file sender_test.h
|
||||
*
|
||||
* @brief Tests to test the Sender (type sender_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 <string.h>
|
||||
|
||||
#include "../allocator.h"
|
||||
#include "sender_test.h"
|
||||
#include "../globals.h"
|
||||
#include "../sender.h"
|
||||
#include "../packet.h"
|
||||
#include "../socket.h"
|
||||
#include "../send_queue.h"
|
||||
#include "../job_queue.h"
|
||||
|
||||
/**
|
||||
* Number of packets to send by sender-thread
|
||||
*/
|
||||
#define NUMBER_OF_PACKETS_TO_SEND 50
|
||||
|
||||
/**
|
||||
* Port to send the packets to
|
||||
*/
|
||||
#define PORT_TO_SEND 4600
|
||||
|
||||
/**
|
||||
* Destination IP Address
|
||||
*/
|
||||
#define DESTINATION_IP "127.0.0.1"
|
||||
|
||||
void test_sender(tester_t *tester)
|
||||
{
|
||||
int i;
|
||||
sender_t *sender;
|
||||
packet_t *packet;
|
||||
packet_t *received_packet;
|
||||
sender = sender_create();
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
packet = packet_create(AF_INET);
|
||||
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
|
||||
packet->data.ptr = allocator_alloc_thing(int);
|
||||
packet->data.len = ( sizeof(int));
|
||||
*((int *) (packet->data.ptr)) = i;
|
||||
global_send_queue->add(global_send_queue,packet);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUMBER_OF_PACKETS_TO_SEND; i++)
|
||||
{
|
||||
global_socket->receive(global_socket,&received_packet);
|
||||
tester->assert_true(tester, (received_packet->data.len == (sizeof(int))), "received data length check");
|
||||
tester->assert_true(tester, (i == *((int *)(received_packet->data.ptr))), "received data value check");
|
||||
received_packet->destroy(received_packet);
|
||||
}
|
||||
|
||||
tester->assert_true(tester, (sender->destroy(sender) == SUCCESS), "destroy call check");
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file sender_test.h
|
||||
*
|
||||
* @brief Tests to test the Sender (type sender_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 SENDER_TEST_H_
|
||||
#define SENDER_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function for the type sender_t
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_sender(tester_t *tester);
|
||||
|
||||
#endif /*SENDER_TEST_H_*/
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @file thread_pool_test.c
|
||||
*
|
||||
* @brief Tests to test the Socket (type socket_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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../allocator.h"
|
||||
#include "socket_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../socket.h"
|
||||
|
||||
/*
|
||||
* Description in header file
|
||||
*/
|
||||
void test_socket(tester_t *tester)
|
||||
{
|
||||
int packet_count = 5;
|
||||
int current;
|
||||
socket_t *skt = socket_create(4500);
|
||||
packet_t *pkt = packet_create(AF_INET);
|
||||
char *test_string = "Testing functionality of socket_t";
|
||||
|
||||
|
||||
pkt->data.ptr = allocator_alloc(strlen(test_string) + 1);
|
||||
memcpy(pkt->data.ptr,test_string,strlen(test_string) + 1);
|
||||
pkt->data.len = strlen(test_string) + 1;
|
||||
|
||||
/* send to previously bound socket */
|
||||
pkt->set_destination(pkt, "127.0.0.1", 4500);
|
||||
|
||||
/* send packet_count packets */
|
||||
for (current = 0; current < packet_count; current++)
|
||||
{
|
||||
if (skt->send(skt, pkt) == FAILED)
|
||||
{
|
||||
tester->assert_true(tester, 0, "packet send");
|
||||
}
|
||||
}
|
||||
pkt->destroy(pkt);
|
||||
|
||||
/* receive packet_count packets */
|
||||
for (current = 0; current < packet_count; current++)
|
||||
{
|
||||
skt->receive(skt, &pkt);
|
||||
tester->assert_false(tester, strcmp(test_string, pkt->data.ptr), "packet exchange");
|
||||
pkt->destroy(pkt);
|
||||
}
|
||||
|
||||
tester->assert_true(tester, (skt->destroy(skt) == SUCCESS), "socket destroy call check");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @file socket_test.h
|
||||
*
|
||||
* @brief Tests to test the Socket (type socket_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 SOCKET_TEST_H_
|
||||
#define SOCKET_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function for the type socket_t
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_socket(tester_t *tester);
|
||||
|
||||
|
||||
#endif /*SOCKET_TEST_H_*/
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file thread_pool_test.c
|
||||
*
|
||||
* @brief Tests to test the Thread-Pool type thread_pool_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 <stdlib.h>
|
||||
|
||||
#include "thread_pool_test.h"
|
||||
#include "../tester.h"
|
||||
#include "../thread_pool.h"
|
||||
|
||||
/*
|
||||
* Description in header file
|
||||
*/
|
||||
void test_thread_pool(tester_t *tester)
|
||||
{
|
||||
size_t desired_pool_size = 10;
|
||||
size_t pool_size;
|
||||
|
||||
thread_pool_t *pool = thread_pool_create(desired_pool_size);
|
||||
pool_size = pool->get_pool_size(pool);
|
||||
tester->assert_true(tester, (desired_pool_size == pool_size), "thread creation");
|
||||
tester->assert_true(tester, (pool->destroy(pool) == SUCCESS), "threadpool destruction");
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file thread_pool_test.h
|
||||
*
|
||||
* @brief Tests to test the Thread-Pool type thread_pool_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 THREAD_POOL_TEST_H_
|
||||
#define THREAD_POOL_TEST_H_
|
||||
|
||||
#include "../tester.h"
|
||||
|
||||
/**
|
||||
* @brief Test function for the type thread_pool_t
|
||||
*
|
||||
* @param tester tester object
|
||||
*/
|
||||
void test_thread_pool(tester_t *tester);
|
||||
|
||||
#endif /*THREAD_POOL_TEST_H_*/
|
||||
Reference in New Issue
Block a user