- memory allocation now works with allocator-functions...
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ static status_t destroy (private_configuration_t *this)
|
|||||||
*/
|
*/
|
||||||
configuration_t * configuration_create()
|
configuration_t * configuration_create()
|
||||||
{
|
{
|
||||||
private_configuration_t *this = allocator_alloc_thing(private_configuration_t, "private_configuration_t");
|
private_configuration_t *this = allocator_alloc_thing(private_configuration_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
@@ -85,7 +85,7 @@ static status_t event_destroy(event_t *event)
|
|||||||
*/
|
*/
|
||||||
static event_t *event_create(timeval_t time, job_t *job)
|
static event_t *event_create(timeval_t time, job_t *job)
|
||||||
{
|
{
|
||||||
event_t *this = allocator_alloc_thing(event_t, "event_t");
|
event_t *this = allocator_alloc_thing(event_t);
|
||||||
|
|
||||||
this->destroy = event_destroy;
|
this->destroy = event_destroy;
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ event_queue_t *event_queue_create()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private_event_queue_t *this = allocator_alloc_thing(private_event_queue_t, "private_event_queue_t");
|
private_event_queue_t *this = allocator_alloc_thing(private_event_queue_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
linked_list->destroy(linked_list);
|
linked_list->destroy(linked_list);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "generator.h"
|
#include "generator.h"
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ static status_t generate_u_int_type (private_generator_t *this,encoding_type_t i
|
|||||||
*/
|
*/
|
||||||
static status_t generate (private_generator_t *this,void * data_struct,encoding_rule_t *encoding_rules, size_t encoding_rules_count, chunk_t *data)
|
static status_t generate (private_generator_t *this,void * data_struct,encoding_rule_t *encoding_rules, size_t encoding_rules_count, chunk_t *data)
|
||||||
{
|
{
|
||||||
u_int8_t * buffer = allocator_alloc(GENERATOR_DATA_BUFFER_SIZE, "generator buffer");
|
u_int8_t * buffer = allocator_alloc(GENERATOR_DATA_BUFFER_SIZE);
|
||||||
u_int8_t * out_position = buffer;
|
u_int8_t * out_position = buffer;
|
||||||
u_int8_t * roof_position = buffer + GENERATOR_DATA_BUFFER_SIZE;
|
u_int8_t * roof_position = buffer + GENERATOR_DATA_BUFFER_SIZE;
|
||||||
size_t current_bit = 0;
|
size_t current_bit = 0;
|
||||||
@@ -188,7 +189,7 @@ generator_t * generator_create(payload_info_t ** payload_infos)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this = allocator_alloc_thing(private_generator_t,"private_generator_t");
|
this = allocator_alloc_thing(private_generator_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
#include "ike_sa.h"
|
#include "ike_sa.h"
|
||||||
@@ -145,7 +146,7 @@ static status_t destroy (private_ike_sa_t *this)
|
|||||||
*/
|
*/
|
||||||
ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
|
ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
|
||||||
{
|
{
|
||||||
private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t, "private_ike_sa_t");
|
private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "ike_sa_id.h"
|
#include "ike_sa_id.h"
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ static status_t destroy (private_ike_sa_id_t *this)
|
|||||||
*/
|
*/
|
||||||
ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_role_t role)
|
ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_role_t role)
|
||||||
{
|
{
|
||||||
private_ike_sa_id_t *this = allocator_alloc_thing(private_ike_sa_id_t, "private_ike_sa_id_t");
|
private_ike_sa_id_t *this = allocator_alloc_thing(private_ike_sa_id_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "ike_sa_manager.h"
|
#include "ike_sa_manager.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
#include "ike_sa_id.h"
|
#include "ike_sa_id.h"
|
||||||
@@ -78,7 +79,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
|
|||||||
*/
|
*/
|
||||||
ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id)
|
ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id)
|
||||||
{
|
{
|
||||||
ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t, "ike_sa_entry_t");
|
ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t);
|
||||||
|
|
||||||
this->destroy = ike_sa_entry_destroy;
|
this->destroy = ike_sa_entry_destroy;
|
||||||
this->waiting_threads = 0;
|
this->waiting_threads = 0;
|
||||||
@@ -512,7 +513,7 @@ static status_t destroy(private_ike_sa_manager_t *this)
|
|||||||
|
|
||||||
ike_sa_manager_t *ike_sa_manager_create()
|
ike_sa_manager_t *ike_sa_manager_create()
|
||||||
{
|
{
|
||||||
private_ike_sa_manager_t *this = allocator_alloc_thing(private_ike_sa_manager_t, "private_ike_sa_manager_t");
|
private_ike_sa_manager_t *this = allocator_alloc_thing(private_ike_sa_manager_t);
|
||||||
|
|
||||||
/* assign public functions */
|
/* assign public functions */
|
||||||
this->public.destroy = (status_t(*)(ike_sa_manager_t*))destroy;
|
this->public.destroy = (status_t(*)(ike_sa_manager_t*))destroy;
|
||||||
|
|||||||
+2
-1
@@ -25,6 +25,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "job.h"
|
#include "job.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +42,7 @@ static status_t job_destroy(job_t *job)
|
|||||||
*/
|
*/
|
||||||
job_t *job_create(job_type_t type, void *assigned_data)
|
job_t *job_create(job_type_t type, void *assigned_data)
|
||||||
{
|
{
|
||||||
job_t *this = allocator_alloc_thing(job_t, "job_t");
|
job_t *this = allocator_alloc_thing(job_t);
|
||||||
|
|
||||||
this->destroy = job_destroy;
|
this->destroy = job_destroy;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "job_queue.h"
|
#include "job_queue.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ job_queue_t *job_queue_create()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private_job_queue_t *this = allocator_alloc_thing(private_job_queue_t, "private_job_queue_t");
|
private_job_queue_t *this = allocator_alloc_thing(private_job_queue_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
linked_list->destroy(linked_list);
|
linked_list->destroy(linked_list);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ static status_t linked_list_element_destroy(linked_list_element_t *this)
|
|||||||
|
|
||||||
linked_list_element_t *linked_list_element_create(void *value)
|
linked_list_element_t *linked_list_element_create(void *value)
|
||||||
{
|
{
|
||||||
linked_list_element_t *this = allocator_alloc_thing(linked_list_element_t, "linked_list_element_t");
|
linked_list_element_t *this = allocator_alloc_thing(linked_list_element_t);
|
||||||
|
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
@@ -252,7 +253,7 @@ static status_t get_count(private_linked_list_t *this, int *count)
|
|||||||
|
|
||||||
static status_t create_iterator (private_linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)
|
static status_t create_iterator (private_linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)
|
||||||
{
|
{
|
||||||
private_linked_list_iterator_t *this = allocator_alloc_thing(private_linked_list_iterator_t, "private_linked_list_iterator_t");
|
private_linked_list_iterator_t *this = allocator_alloc_thing(private_linked_list_iterator_t);
|
||||||
|
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
@@ -682,7 +683,7 @@ static status_t linked_list_destroy(private_linked_list_t *this)
|
|||||||
*/
|
*/
|
||||||
linked_list_t *linked_list_create()
|
linked_list_t *linked_list_create()
|
||||||
{
|
{
|
||||||
private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t, "private_linked_list_t");
|
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 = (status_t (*) (linked_list_t *linked_list, int *count)) get_count;
|
||||||
this->public.create_iterator = (status_t (*) (linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)) create_iterator;
|
this->public.create_iterator = (status_t (*) (linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)) create_iterator;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ static status_t destroy (private_message_t *this)
|
|||||||
*/
|
*/
|
||||||
message_t * message_create()
|
message_t * message_create()
|
||||||
{
|
{
|
||||||
private_message_t *this = allocator_alloc_thing(private_message_t, "private_message_t");
|
private_message_t *this = allocator_alloc_thing(private_message_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ status_t set_source(packet_t *this, char *address, u_int16_t port)
|
|||||||
|
|
||||||
packet_t *packet_create(int family)
|
packet_t *packet_create(int family)
|
||||||
{
|
{
|
||||||
packet_t *this = allocator_alloc_thing(packet_t, "packet_t");
|
packet_t *this = allocator_alloc_thing(packet_t);
|
||||||
|
|
||||||
this->destroy = destroy;
|
this->destroy = destroy;
|
||||||
this->set_destination = set_destination;
|
this->set_destination = set_destination;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "receiver.h"
|
#include "receiver.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@@ -105,7 +106,7 @@ static status_t destroy(private_receiver_t *this)
|
|||||||
|
|
||||||
receiver_t * receiver_create()
|
receiver_t * receiver_create()
|
||||||
{
|
{
|
||||||
private_receiver_t *this = allocator_alloc_thing(private_receiver_t,"private_receiver_t");
|
private_receiver_t *this = allocator_alloc_thing(private_receiver_t);
|
||||||
|
|
||||||
this->public.destroy = (status_t(*)(receiver_t*)) destroy;
|
this->public.destroy = (status_t(*)(receiver_t*)) destroy;
|
||||||
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))receiver_thread_function, this) != 0)
|
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))receiver_thread_function, this) != 0)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "job_queue.h"
|
#include "job_queue.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
@@ -85,7 +86,7 @@ static status_t destroy(private_scheduler_t *this)
|
|||||||
|
|
||||||
scheduler_t * scheduler_create()
|
scheduler_t * scheduler_create()
|
||||||
{
|
{
|
||||||
private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t,"private_scheduler_t");
|
private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t);
|
||||||
|
|
||||||
this->public.destroy = (status_t(*)(scheduler_t*)) destroy;
|
this->public.destroy = (status_t(*)(scheduler_t*)) destroy;
|
||||||
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))scheduler_thread_function, this) != 0)
|
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))scheduler_thread_function, this) != 0)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "send_queue.h"
|
#include "send_queue.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ send_queue_t *send_queue_create()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private_send_queue_t *this = allocator_alloc_thing(private_send_queue_t, "private_send_queue_t");
|
private_send_queue_t *this = allocator_alloc_thing(private_send_queue_t);
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
{
|
{
|
||||||
linked_list->destroy(linked_list);
|
linked_list->destroy(linked_list);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "sender.h"
|
#include "sender.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@@ -101,7 +102,7 @@ static status_t destroy(private_sender_t *this)
|
|||||||
|
|
||||||
sender_t * sender_create()
|
sender_t * sender_create()
|
||||||
{
|
{
|
||||||
private_sender_t *this = allocator_alloc_thing(private_sender_t,"private_sender_t");
|
private_sender_t *this = allocator_alloc_thing(private_sender_t);
|
||||||
|
|
||||||
this->public.destroy = (status_t(*)(sender_t*)) destroy;
|
this->public.destroy = (status_t(*)(sender_t*)) destroy;
|
||||||
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))sender_thread_function, this) != 0)
|
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))sender_thread_function, this) != 0)
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "socket.h"
|
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -34,6 +32,8 @@
|
|||||||
#include <pluto/constants.h>
|
#include <pluto/constants.h>
|
||||||
#include <pluto/defs.h>
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
|
#include "socket.h"
|
||||||
|
|
||||||
typedef struct private_socket_s private_socket_t;
|
typedef struct private_socket_s private_socket_t;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ status_t receiver(private_socket_t *this, packet_t **packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* fill in packet */
|
/* fill in packet */
|
||||||
pkt->data.ptr = allocator_alloc(pkt->data.len, "data in packet_t");
|
pkt->data.ptr = allocator_alloc(pkt->data.len);
|
||||||
memcpy(pkt->data.ptr, buffer, pkt->data.len);
|
memcpy(pkt->data.ptr, buffer, pkt->data.len);
|
||||||
|
|
||||||
/* return packet */
|
/* return packet */
|
||||||
@@ -124,7 +124,7 @@ status_t destroy(private_socket_t *this)
|
|||||||
|
|
||||||
socket_t *socket_create(u_int16_t port)
|
socket_t *socket_create(u_int16_t port)
|
||||||
{
|
{
|
||||||
private_socket_t *this = allocator_alloc_thing(private_socket_t, "private_socket_t");
|
private_socket_t *this = allocator_alloc_thing(private_socket_t);
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include "tester.h"
|
#include "tester.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
#include "thread_pool.h"
|
#include "thread_pool.h"
|
||||||
@@ -179,7 +180,7 @@ static status_t destroy(tester_t *tester)
|
|||||||
|
|
||||||
tester_t *tester_create(FILE *output, bool display_succeeded_asserts)
|
tester_t *tester_create(FILE *output, bool display_succeeded_asserts)
|
||||||
{
|
{
|
||||||
private_tester_t *this = allocator_alloc_thing(private_tester_t, "private_tester_t");
|
private_tester_t *this = allocator_alloc_thing(private_tester_t);
|
||||||
|
|
||||||
this->public.destroy = destroy;
|
this->public.destroy = destroy;
|
||||||
this->public.perform_tests = perform_tests;
|
this->public.perform_tests = perform_tests;
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ socket_t *global_socket;
|
|||||||
&job_queue_test1,
|
&job_queue_test1,
|
||||||
&event_queue_test,
|
&event_queue_test,
|
||||||
&send_queue_test,
|
&send_queue_test,
|
||||||
|
&scheduler_test,
|
||||||
&socket_test,
|
&socket_test,
|
||||||
&sender_test,
|
&sender_test,
|
||||||
&scheduler_test,
|
|
||||||
&receiver_test,
|
&receiver_test,
|
||||||
&ike_sa_id_test,
|
&ike_sa_id_test,
|
||||||
&ike_sa_test,
|
&ike_sa_test,
|
||||||
@@ -167,8 +167,8 @@ socket_t *global_socket;
|
|||||||
|
|
||||||
tester_t *tester = tester_create(test_output, FALSE);
|
tester_t *tester = tester_create(test_output, FALSE);
|
||||||
|
|
||||||
/* tester->perform_tests(tester,all_tests); */
|
tester->perform_tests(tester,all_tests);
|
||||||
tester->perform_test(tester,&thread_pool_test);
|
/* tester->perform_test(tester,&scheduler_test); */
|
||||||
|
|
||||||
tester->destroy(tester);
|
tester->destroy(tester);
|
||||||
|
|
||||||
@@ -180,8 +180,7 @@ socket_t *global_socket;
|
|||||||
global_socket->destroy(global_socket);
|
global_socket->destroy(global_socket);
|
||||||
|
|
||||||
#ifdef LEAK_DETECTIVE
|
#ifdef LEAK_DETECTIVE
|
||||||
/* Leaks are reported in log file */
|
/* Leaks are reported on stderr */
|
||||||
report_leaks();
|
|
||||||
report_memory_leaks();
|
report_memory_leaks();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "../allocator.h"
|
||||||
#include "event_queue_test.h"
|
#include "event_queue_test.h"
|
||||||
#include "../tester.h"
|
#include "../tester.h"
|
||||||
#include "../event_queue.h"
|
#include "../event_queue.h"
|
||||||
@@ -76,7 +77,7 @@ static void event_queue_insert_thread(event_queue_test_t * testinfos)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < testinfos->entries_per_time;j++)
|
for (j = 0; j < testinfos->entries_per_time;j++)
|
||||||
{
|
{
|
||||||
int *value = allocator_alloc_thing(int, "value");
|
int *value = allocator_alloc_thing(int);
|
||||||
*value = i;
|
*value = i;
|
||||||
job = job_create(INCOMING_PACKET,value);
|
job = job_create(INCOMING_PACKET,value);
|
||||||
time.tv_usec = 0;
|
time.tv_usec = 0;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../allocator.h"
|
||||||
#include "job_queue_test.h"
|
#include "job_queue_test.h"
|
||||||
#include "../tester.h"
|
#include "../tester.h"
|
||||||
#include "../job_queue.h"
|
#include "../job_queue.h"
|
||||||
@@ -63,7 +64,7 @@ static void test_job_queue_sender(job_queue_test_t * testinfo)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < testinfo->insert_item_count; i++)
|
for (i = 0; i < testinfo->insert_item_count; i++)
|
||||||
{
|
{
|
||||||
int *value = allocator_alloc_thing(int,"int in test_job_queue_sender");
|
int *value = allocator_alloc_thing(int);
|
||||||
*value = i;
|
*value = i;
|
||||||
job_t *job = job_create(INCOMING_PACKET,value);
|
job_t *job = job_create(INCOMING_PACKET,value);
|
||||||
testinfo->job_queue->add(testinfo->job_queue,job);
|
testinfo->job_queue->add(testinfo->job_queue,job);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../allocator.h"
|
||||||
#include "sender_test.h"
|
#include "sender_test.h"
|
||||||
#include "../globals.h"
|
#include "../globals.h"
|
||||||
#include "../receiver.h"
|
#include "../receiver.h"
|
||||||
@@ -59,7 +60,7 @@ void test_receiver(tester_t *tester)
|
|||||||
{
|
{
|
||||||
packet = packet_create(AF_INET);
|
packet = packet_create(AF_INET);
|
||||||
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
|
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
|
||||||
packet->data.ptr = allocator_alloc_thing(int, "packet data");
|
packet->data.ptr = allocator_alloc_thing(int);
|
||||||
packet->data.len = ( sizeof(int));
|
packet->data.len = ( sizeof(int));
|
||||||
*((int *) (packet->data.ptr)) = i;
|
*((int *) (packet->data.ptr)) = i;
|
||||||
global_socket->send(global_socket,packet);
|
global_socket->send(global_socket,packet);
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ void test_scheduler(tester_t *tester)
|
|||||||
usleep(100 * 1000);
|
usleep(100 * 1000);
|
||||||
global_event_queue->get_count(global_event_queue, &event_queue_size);
|
global_event_queue->get_count(global_event_queue, &event_queue_size);
|
||||||
global_job_queue->get_count(global_job_queue, &job_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, (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, (event_queue_size == job_count - current - 1), "event-queue size after event");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../allocator.h"
|
||||||
#include "sender_test.h"
|
#include "sender_test.h"
|
||||||
#include "../globals.h"
|
#include "../globals.h"
|
||||||
#include "../sender.h"
|
#include "../sender.h"
|
||||||
@@ -57,7 +58,7 @@ void test_sender(tester_t *tester)
|
|||||||
{
|
{
|
||||||
packet = packet_create(AF_INET);
|
packet = packet_create(AF_INET);
|
||||||
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
|
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
|
||||||
packet->data.ptr = allocator_alloc_thing(int, "packet data");
|
packet->data.ptr = allocator_alloc_thing(int);
|
||||||
packet->data.len = ( sizeof(int));
|
packet->data.len = ( sizeof(int));
|
||||||
*((int *) (packet->data.ptr)) = i;
|
*((int *) (packet->data.ptr)) = i;
|
||||||
global_send_queue->add(global_send_queue,packet);
|
global_send_queue->add(global_send_queue,packet);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../allocator.h"
|
||||||
#include "socket_test.h"
|
#include "socket_test.h"
|
||||||
#include "../tester.h"
|
#include "../tester.h"
|
||||||
#include "../socket.h"
|
#include "../socket.h"
|
||||||
@@ -39,7 +40,7 @@ void test_socket(tester_t *tester)
|
|||||||
char *test_string = "Testing functionality of socket_t";
|
char *test_string = "Testing functionality of socket_t";
|
||||||
|
|
||||||
|
|
||||||
pkt->data.ptr = allocator_alloc(strlen(test_string) + 1,"test_string");
|
pkt->data.ptr = allocator_alloc(strlen(test_string) + 1);
|
||||||
memcpy(pkt->data.ptr,test_string,strlen(test_string) + 1);
|
memcpy(pkt->data.ptr,test_string,strlen(test_string) + 1);
|
||||||
pkt->data.len = strlen(test_string) + 1;
|
pkt->data.len = strlen(test_string) + 1;
|
||||||
|
|
||||||
|
|||||||
@@ -37,5 +37,5 @@ void test_thread_pool(tester_t *tester)
|
|||||||
thread_pool_t *pool = thread_pool_create(desired_pool_size);
|
thread_pool_t *pool = thread_pool_create(desired_pool_size);
|
||||||
pool->get_pool_size(pool, &pool_size);
|
pool->get_pool_size(pool, &pool_size);
|
||||||
tester->assert_true(tester, (desired_pool_size == pool_size), "thread creation");
|
tester->assert_true(tester, (desired_pool_size == pool_size), "thread creation");
|
||||||
//tester->assert_true(tester, (pool->destroy(pool) == SUCCESS), "threadpool destruction");
|
tester->assert_true(tester, (pool->destroy(pool) == SUCCESS), "threadpool destruction");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user