- linked_list, event_queue, send_queue and job_queue returns now
count directly
This commit is contained in:
parent
ed7634e696
commit
1061c878a9
16 changed files with 95 additions and 132 deletions
|
@ -143,7 +143,7 @@
|
|||
*
|
||||
* @see #allocator_s.report_memory_leaks for description
|
||||
*/
|
||||
#define report_memory_leaks(void) global_allocator->report_memory_leaks(global_allocator);
|
||||
#define report_memory_leaks(void) (global_allocator->report_memory_leaks(global_allocator))
|
||||
#else
|
||||
#define allocator_alloc(bytes) (malloc(bytes))
|
||||
#define allocator_realloc(old,bytes) (realloc(old,bytes))
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* @file encodings.c
|
||||
*
|
||||
* @brief Type definitions for parser and generator
|
||||
* Also, Payload types are defined here.
|
||||
* @brief Type definitions for parser and generator,
|
||||
* also payload types are defined here.
|
||||
*
|
||||
* Header is parsed like a payload and gets its one payload_id
|
||||
* from PRIVATE USE space. Also the substructures get their own
|
||||
* payload_id from PRIVATE_USE space
|
||||
*
|
||||
* from PRIVATE USE space. Also the substructures
|
||||
* of specific payload types get their own payload_id
|
||||
* from PRIVATE_USE space. See RFC for mor informations.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -32,9 +32,10 @@
|
|||
extern payload_info_t ike_header_info;
|
||||
|
||||
/**
|
||||
* Contains all payload informations supported by parser and generator
|
||||
* List containing all payload informations
|
||||
* supported by parser and generator.
|
||||
*
|
||||
* @warning This list must be NULL terminated
|
||||
* @warning This list must be NULL terminated.
|
||||
*/
|
||||
payload_info_t *payload_infos[] = {
|
||||
&ike_header_info,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* @file encodings.h
|
||||
*
|
||||
* @brief Type definitions for parser and generator
|
||||
* Also, Payload types are defined here.
|
||||
* @brief Type definitions for parser and generator,
|
||||
* also payload types are defined here.
|
||||
*
|
||||
* Header is parsed like a payload and gets its one payload_id
|
||||
* from PRIVATE USE space. Also the substructures get their own
|
||||
* payload_id from PRIVATE_USE space
|
||||
*
|
||||
* from PRIVATE USE space. Also the substructures
|
||||
* of specific payload types get their own payload_id
|
||||
* from PRIVATE_USE space. See RFC for mor informations.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
*
|
||||
* Each field of an IKEv2-Message (in header or payload)
|
||||
* which has to be parsed or generated differently has its own
|
||||
* enum value.
|
||||
* type defined here.
|
||||
*/
|
||||
typedef enum encoding_type_e encoding_type_t;
|
||||
|
||||
|
@ -176,9 +176,9 @@ enum encoding_type_e{
|
|||
* a location in the data struct where the current field is stored to
|
||||
* or read from.
|
||||
*
|
||||
* For examples see directory encodings/
|
||||
* For examples see directory encodings/.
|
||||
*
|
||||
* This rules are used by parser and generator
|
||||
* This rules are used by parser and generator.
|
||||
*/
|
||||
typedef struct encoding_rule_s encoding_rule_t;
|
||||
|
||||
|
@ -189,6 +189,12 @@ struct encoding_rule_s{
|
|||
encoding_type_t type;
|
||||
/**
|
||||
* Offset in the data struct
|
||||
*
|
||||
* When parsing, data are written to this offset of the
|
||||
* data struct.
|
||||
*
|
||||
* When generating, data are read from this offset in the
|
||||
* data struct.
|
||||
*/
|
||||
u_int32_t offset;
|
||||
};
|
||||
|
@ -199,7 +205,7 @@ struct encoding_rule_s{
|
|||
*
|
||||
*
|
||||
* Header and substructures are also defined as
|
||||
* payload types with values of PRIVATE USE space
|
||||
* payload types with values from PRIVATE USE space.
|
||||
*/
|
||||
typedef enum payload_type_e payload_type_t;
|
||||
|
||||
|
@ -271,6 +277,9 @@ enum payload_type_e{
|
|||
|
||||
/**
|
||||
* Header has value 140 of PRIVATE USE space
|
||||
*
|
||||
* This payload type is not send over wire and just
|
||||
* used internally to handle IKEv2-Header like a payload.
|
||||
*/
|
||||
HEADER = 140
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @file event_queue.c
|
||||
*
|
||||
* @brief Event-Queue based on linked_list_t
|
||||
* @brief Event-Queue based on class linked_list_t
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -149,12 +149,13 @@ static long time_difference(struct timeval *end_time, struct timeval *start_time
|
|||
/**
|
||||
* @brief implements function get_count of event_queue_t
|
||||
*/
|
||||
static status_t get_count (private_event_queue_t *this, int *count)
|
||||
static int get_count (private_event_queue_t *this)
|
||||
{
|
||||
int count;
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
status_t status = this->list->get_count(this->list,count);
|
||||
count = this->list->get_count(this->list);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
return status;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,15 +166,13 @@ static status_t get(private_event_queue_t *this, job_t **job)
|
|||
timespec_t timeout;
|
||||
timeval_t current_time;
|
||||
event_t * next_event;
|
||||
int count;
|
||||
int oldstate;
|
||||
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
|
||||
while (1)
|
||||
{
|
||||
this->list->get_count(this->list,&count);
|
||||
while(count == 0)
|
||||
while(this->list->get_count(this->list) == 0)
|
||||
{
|
||||
/* add mutex unlock handler for cancellation, enable cancellation */
|
||||
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
|
||||
|
@ -184,8 +183,6 @@ static status_t get(private_event_queue_t *this, job_t **job)
|
|||
/* reset cancellation, remove mutex-unlock handler (without executing) */
|
||||
pthread_setcancelstate(oldstate, NULL);
|
||||
pthread_cleanup_pop(0);
|
||||
|
||||
this->list->get_count(this->list,&count);
|
||||
}
|
||||
|
||||
this->list->get_first(this->list,(void **) &next_event);
|
||||
|
@ -226,7 +223,6 @@ static status_t add_absolute(private_event_queue_t *this, job_t *job, timeval_t
|
|||
event_t *event = event_create(time,job);
|
||||
event_t *current_event;
|
||||
status_t status;
|
||||
int count;
|
||||
|
||||
if (event == NULL)
|
||||
{
|
||||
|
@ -237,8 +233,7 @@ static status_t add_absolute(private_event_queue_t *this, job_t *job, timeval_t
|
|||
/* while just used to break out */
|
||||
while(1)
|
||||
{
|
||||
this->list->get_count(this->list,&count);
|
||||
if (count == 0)
|
||||
if (this->list->get_count(this->list) == 0)
|
||||
{
|
||||
status = this->list->insert_first(this->list,event);
|
||||
break;
|
||||
|
@ -324,9 +319,7 @@ static status_t add_relative(event_queue_t *this, job_t *job, u_int32_t ms)
|
|||
*/
|
||||
static status_t event_queue_destroy(private_event_queue_t *this)
|
||||
{
|
||||
int count;
|
||||
this->list->get_count(this->list,&count);
|
||||
while (count > 0)
|
||||
while (this->list->get_count(this->list) > 0)
|
||||
{
|
||||
event_t *event;
|
||||
|
||||
|
@ -337,7 +330,6 @@ static status_t event_queue_destroy(private_event_queue_t *this)
|
|||
}
|
||||
event->job->destroy(event->job);
|
||||
event->destroy(event);
|
||||
this->list->get_count(this->list,&count);
|
||||
}
|
||||
this->list->destroy(this->list);
|
||||
|
||||
|
@ -368,7 +360,7 @@ event_queue_t *event_queue_create()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
this->public.get_count = (status_t (*) (event_queue_t *event_queue, int *count)) get_count;
|
||||
this->public.get_count = (int (*) (event_queue_t *event_queue)) get_count;
|
||||
this->public.get = (status_t (*) (event_queue_t *event_queue, job_t **job)) get;
|
||||
this->public.add_absolute = (status_t (*) (event_queue_t *event_queue, job_t *job, timeval_t time)) add_absolute;
|
||||
this->public.add_relative = (status_t (*) (event_queue_t *event_queue, job_t *job, u_int32_t ms)) add_relative;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @file event_queue.h
|
||||
*
|
||||
* @brief Event-Queue based on linked_list_t
|
||||
* @brief Event-Queue based on class linked_list_t
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -29,32 +29,33 @@
|
|||
#include "job.h"
|
||||
|
||||
/**
|
||||
* @brief Event-Queue
|
||||
* @brief Event-Queue used to store timed events.
|
||||
*
|
||||
* Although the event-queue is based on a linked_list_t
|
||||
* all access functions are thread-save implemented
|
||||
* all access functions are thread-save implemented.
|
||||
*/
|
||||
typedef struct event_queue_s event_queue_t;
|
||||
|
||||
struct event_queue_s {
|
||||
|
||||
/**
|
||||
* @brief returns number of events in queue
|
||||
* @brief Returns number of events in queue.
|
||||
*
|
||||
* @param event_queue calling object
|
||||
* @param[out] count integer pointer to store the event count in
|
||||
* @returns SUCCESS if succeeded, FAILED otherwise
|
||||
* @return number of events in queue
|
||||
*/
|
||||
status_t (*get_count) (event_queue_t *event_queue, int *count);
|
||||
int (*get_count) (event_queue_t *event_queue);
|
||||
|
||||
/**
|
||||
* @brief get the next job from the event-queue
|
||||
*
|
||||
* If no event is pending, this function blocks until a job can be returned.
|
||||
*
|
||||
* @param event_queue calling object
|
||||
* @param[out] job pointer to a job pointer where to job is returned to
|
||||
* @returns SUCCESS if succeeded, FAILED otherwise
|
||||
* @param event_queue calling object
|
||||
* @param[out] job pointer to a job pointer where to job is returned to
|
||||
* @return - SUCCESS if succeeded
|
||||
* - FAILED otherwisesa
|
||||
*/
|
||||
status_t (*get) (event_queue_t *event_queue, job_t **job);
|
||||
|
||||
|
|
|
@ -60,12 +60,13 @@ struct private_job_queue_s {
|
|||
/**
|
||||
* @brief implements function get_count of job_queue_t
|
||||
*/
|
||||
static status_t get_count(private_job_queue_t *this, int *count)
|
||||
static int get_count(private_job_queue_t *this)
|
||||
{
|
||||
int count;
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
this->list->get_count(this->list,count);
|
||||
count = this->list->get_count(this->list);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
return SUCCESS;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,12 +74,10 @@ static status_t get_count(private_job_queue_t *this, int *count)
|
|||
*/
|
||||
static status_t get(private_job_queue_t *this, job_t **job)
|
||||
{
|
||||
int count;
|
||||
int oldstate;
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
/* go to wait while no jobs available */
|
||||
this->list->get_count(this->list,&count);
|
||||
while(count == 0)
|
||||
while(this->list->get_count(this->list) == 0)
|
||||
{
|
||||
/* add mutex unlock handler for cancellation, enable cancellation */
|
||||
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
|
||||
|
@ -89,7 +88,6 @@ static status_t get(private_job_queue_t *this, job_t **job)
|
|||
/* reset cancellation, remove mutex-unlock handler (without executing) */
|
||||
pthread_setcancelstate(oldstate, NULL);
|
||||
pthread_cleanup_pop(0);
|
||||
this->list->get_count(this->list,&count);
|
||||
}
|
||||
this->list->remove_first(this->list,(void **) job);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
@ -114,10 +112,7 @@ static status_t add(private_job_queue_t *this, job_t *job)
|
|||
*/
|
||||
static status_t job_queue_destroy (private_job_queue_t *this)
|
||||
{
|
||||
int count;
|
||||
this->list->get_count(this->list,&count);
|
||||
|
||||
while (count > 0)
|
||||
while (this->list->get_count(this->list) > 0)
|
||||
{
|
||||
job_t *job;
|
||||
if (this->list->remove_first(this->list,(void *) &job) != SUCCESS)
|
||||
|
@ -126,7 +121,6 @@ static status_t job_queue_destroy (private_job_queue_t *this)
|
|||
break;
|
||||
}
|
||||
job->destroy(job);
|
||||
this->list->get_count(this->list,&count);
|
||||
}
|
||||
this->list->destroy(this->list);
|
||||
|
||||
|
@ -157,7 +151,7 @@ job_queue_t *job_queue_create()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
this->public.get_count = (status_t(*)(job_queue_t*, int*))get_count;
|
||||
this->public.get_count = (int(*)(job_queue_t*))get_count;
|
||||
this->public.get = (status_t(*)(job_queue_t*, job_t**))get;
|
||||
this->public.add = (status_t(*)(job_queue_t*, job_t*))add;
|
||||
this->public.destroy = (status_t(*)(job_queue_t*))job_queue_destroy;
|
||||
|
|
|
@ -40,10 +40,9 @@ struct job_queue_s {
|
|||
* @brief returns number of jobs in queue
|
||||
*
|
||||
* @param job_queue_t calling object
|
||||
* @param[out] count integer pointer to store the job count in
|
||||
* @returns SUCCESS if succeeded, FAILED otherwise
|
||||
* @returns number of items in queue
|
||||
*/
|
||||
status_t (*get_count) (job_queue_t *job_queue, int *count);
|
||||
int (*get_count) (job_queue_t *job_queue);
|
||||
|
||||
/**
|
||||
* @brief get the next job from the queue
|
||||
|
|
|
@ -240,14 +240,9 @@ static status_t iterator_destroy(private_linked_list_iterator_t *this)
|
|||
/**
|
||||
* @brief implements function get_count of linked_list_t
|
||||
*/
|
||||
static status_t get_count(private_linked_list_t *this, int *count)
|
||||
static int get_count(private_linked_list_t *this)
|
||||
{
|
||||
if (this == NULL)
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
*count = this->count;
|
||||
return SUCCESS;
|
||||
return this->count;
|
||||
}
|
||||
|
||||
|
||||
|
@ -685,7 +680,7 @@ linked_list_t *linked_list_create()
|
|||
{
|
||||
private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t);
|
||||
|
||||
this->public.get_count = (status_t (*) (linked_list_t *linked_list, int *count)) get_count;
|
||||
this->public.get_count = (int (*) (linked_list_t *linked_list)) get_count;
|
||||
this->public.create_iterator = (status_t (*) (linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)) create_iterator;
|
||||
this->public.get_first = (status_t (*) (linked_list_t *linked_list, void **item)) get_first;
|
||||
this->public.get_last = (status_t (*) (linked_list_t *linked_list, void **item)) get_last;
|
||||
|
|
|
@ -92,10 +92,9 @@ struct linked_list_s {
|
|||
* @brief gets the count of items in the list
|
||||
*
|
||||
* @param linked_list calling object
|
||||
* @param[in] count place where the count is written
|
||||
* @return SUCCESS if succeeded, FAILED otherwise
|
||||
* @return number of items in list
|
||||
*/
|
||||
status_t (*get_count) (linked_list_t *linked_list, int *count);
|
||||
int (*get_count) (linked_list_t *linked_list);
|
||||
|
||||
/**
|
||||
* @brief creates a iterator for the given list
|
||||
|
|
|
@ -60,12 +60,13 @@ struct private_send_queue_s {
|
|||
/**
|
||||
* @brief implements function get_count of send_queue_t
|
||||
*/
|
||||
static status_t get_count(private_send_queue_t *this, int *count)
|
||||
static int get_count(private_send_queue_t *this)
|
||||
{
|
||||
int count;
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
this->list->get_count(this->list,count);
|
||||
count = this->list->get_count(this->list);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
return SUCCESS;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,12 +74,11 @@ static status_t get_count(private_send_queue_t *this, int *count)
|
|||
*/
|
||||
static status_t get(private_send_queue_t *this, packet_t **packet)
|
||||
{
|
||||
int count;
|
||||
int oldstate;
|
||||
pthread_mutex_lock(&(this->mutex));
|
||||
/* go to wait while no packets available */
|
||||
this->list->get_count(this->list,&count);
|
||||
while(count == 0)
|
||||
|
||||
while(this->list->get_count(this->list) == 0)
|
||||
{
|
||||
/* add mutex unlock handler for cancellation, enable cancellation */
|
||||
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
|
||||
|
@ -88,7 +88,6 @@ static status_t get(private_send_queue_t *this, packet_t **packet)
|
|||
/* reset cancellation, remove mutex-unlock handler (without executing) */
|
||||
pthread_setcancelstate(oldstate, NULL);
|
||||
pthread_cleanup_pop(0);
|
||||
this->list->get_count(this->list,&count);
|
||||
}
|
||||
this->list->remove_first(this->list,(void **) packet);
|
||||
pthread_mutex_unlock(&(this->mutex));
|
||||
|
@ -113,11 +112,9 @@ static status_t add(private_send_queue_t *this, packet_t *packet)
|
|||
*/
|
||||
static status_t destroy (private_send_queue_t *this)
|
||||
{
|
||||
int count;
|
||||
this->list->get_count(this->list,&count);
|
||||
|
||||
/* destroy all packets in list before destroying list */
|
||||
while (count > 0)
|
||||
while (this->list->get_count(this->list) > 0)
|
||||
{
|
||||
packet_t *packet;
|
||||
if (this->list->remove_first(this->list,(void *) &packet) != SUCCESS)
|
||||
|
@ -126,7 +123,6 @@ static status_t destroy (private_send_queue_t *this)
|
|||
break;
|
||||
}
|
||||
packet->destroy(packet);
|
||||
this->list->get_count(this->list,&count);
|
||||
}
|
||||
this->list->destroy(this->list);
|
||||
|
||||
|
@ -157,7 +153,7 @@ send_queue_t *send_queue_create()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
this->public.get_count = (status_t(*)(send_queue_t*, int*)) get_count;
|
||||
this->public.get_count = (int(*)(send_queue_t*)) get_count;
|
||||
this->public.get = (status_t(*)(send_queue_t*, packet_t**)) get;
|
||||
this->public.add = (status_t(*)(send_queue_t*, packet_t*)) add;
|
||||
this->public.destroy = (status_t(*)(send_queue_t*)) destroy;
|
||||
|
|
|
@ -41,9 +41,9 @@ struct send_queue_s {
|
|||
*
|
||||
* @param send_queue_t calling object
|
||||
* @param[out] count integer pointer to store the count in
|
||||
* @returns SUCCESS if succeeded, FAILED otherwise
|
||||
* @returns number of items in queue
|
||||
*/
|
||||
status_t (*get_count) (send_queue_t *send_queue, int *count);
|
||||
int (*get_count) (send_queue_t *send_queue);
|
||||
|
||||
/**
|
||||
* @brief get the next packet from the queue
|
||||
|
|
|
@ -95,7 +95,6 @@ void test_event_queue(tester_t *tester)
|
|||
event_queue_test_t testinfos;
|
||||
pthread_t threads[EVENT_QUEUE_INSERT_THREADS];
|
||||
int i,j, number_of_total_events;
|
||||
int count;
|
||||
timeval_t current_time, start_time;
|
||||
|
||||
testinfos.tester = tester;
|
||||
|
@ -120,8 +119,7 @@ void test_event_queue(tester_t *tester)
|
|||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
tester->assert_true(tester,(event_queue->get_count(event_queue,&count) == SUCCESS), "get_count call check");
|
||||
tester->assert_true(tester,(count == number_of_total_events), "event count check");
|
||||
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++)
|
||||
{
|
||||
|
|
|
@ -94,7 +94,7 @@ static void test_job_queue_receiver(job_queue_test_t * testinfo)
|
|||
*/
|
||||
void test_job_queue(tester_t *tester)
|
||||
{
|
||||
int value, desired_value, i;
|
||||
int desired_value, i;
|
||||
int sender_count = 10;
|
||||
int receiver_count = 2;
|
||||
pthread_t sender_threads[sender_count];
|
||||
|
@ -132,8 +132,7 @@ void test_job_queue(tester_t *tester)
|
|||
}
|
||||
|
||||
/* 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->get_count(job_queue) == desired_value), "get count value check");
|
||||
|
||||
tester->assert_true(tester,(job_queue->destroy(job_queue) == SUCCESS), "destroy call check");
|
||||
}
|
||||
|
|
|
@ -31,71 +31,57 @@
|
|||
void test_linked_list(tester_t *tester)
|
||||
{
|
||||
void *test_value = NULL;
|
||||
int count;
|
||||
|
||||
linked_list_t *linked_list = linked_list_create();
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 0), "count check");
|
||||
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 0), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"one");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 1), "count check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 1), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"two");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 2), "count check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 2), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"three");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 3), "count check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 3), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"four");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 4), "count check");
|
||||
tester->assert_true(tester,(linked_list->get_count(linked_list) == 4), "count check");
|
||||
|
||||
linked_list->insert_first(linked_list,"five");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 5), "count check");
|
||||
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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 5), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 5), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 4), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 4), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 4), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 3), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 3), "count 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");
|
||||
linked_list->get_count(linked_list,&count);
|
||||
tester->assert_true(tester,(count == 3), "count 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");
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
void test_scheduler(tester_t *tester)
|
||||
{
|
||||
int job_count = 5;
|
||||
int job_queue_size;
|
||||
int event_queue_size;
|
||||
job_t *jobs[job_count];
|
||||
int current;
|
||||
scheduler_t *scheduler = scheduler_create();
|
||||
|
@ -64,16 +62,13 @@ void test_scheduler(tester_t *tester)
|
|||
for (current = 0; current < job_count; current++)
|
||||
{
|
||||
usleep(400 * 1000);
|
||||
global_event_queue->get_count(global_event_queue, &event_queue_size);
|
||||
global_job_queue->get_count(global_job_queue, &job_queue_size);
|
||||
tester->assert_true(tester, (job_queue_size == current ), "job-queue size before event");
|
||||
tester->assert_true(tester, (event_queue_size == job_count - current), "event-queue size before event");
|
||||
|
||||
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);
|
||||
global_event_queue->get_count(global_event_queue, &event_queue_size);
|
||||
global_job_queue->get_count(global_job_queue, &job_queue_size);
|
||||
|
||||
tester->assert_true(tester, (job_queue_size == current + 1), "job-queue size after event");
|
||||
tester->assert_true(tester, (event_queue_size == job_count - current - 1), "event-queue size after event");
|
||||
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 */
|
||||
|
|
|
@ -97,7 +97,7 @@ static void test_send_queue_receiver(send_queue_test_t * testinfo)
|
|||
*/
|
||||
void test_send_queue(tester_t *tester)
|
||||
{
|
||||
int value, desired_value, i;
|
||||
int desired_value, i;
|
||||
int sender_count = 10;
|
||||
int receiver_count = 2;
|
||||
pthread_t sender_threads[sender_count];
|
||||
|
@ -137,7 +137,6 @@ void test_send_queue(tester_t *tester)
|
|||
|
||||
|
||||
/* the send-queue has to have diserd_value count entries*/
|
||||
tester->assert_true(tester,(send_queue->get_count(send_queue,&value) == SUCCESS), "get count call check");
|
||||
tester->assert_true(tester,(value == desired_value), "count value check");
|
||||
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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue