- updated tests to varius changes in modules
authorMartin Willi <martin@strongswan.org>
Wed, 16 Nov 2005 16:09:55 +0000 (16:09 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 16 Nov 2005 16:09:55 +0000 (16:09 -0000)
Source/charon/testcases/generator_test.c
Source/charon/testcases/ike_sa_id_test.c
Source/charon/testcases/ike_sa_manager_test.c
Source/charon/testcases/ike_sa_test.c
Source/charon/testcases/packet_test.c
Source/charon/testcases/parser_test.c
Source/charon/testcases/receiver_test.c
Source/charon/testcases/sender_test.c
Source/charon/testcases/socket_test.c
Source/charon/testcases/testcases.c

index 7a18879..9433238 100644 (file)
@@ -167,7 +167,7 @@ void test_generator_with_transform_attribute(tester_t *tester)
        data.ptr = (void *) &dataval;
        data.len = 2;
                
-       attribute->set_value(attribute,data);
+       attribute->set_value_chunk(attribute,data);
        
        status = generator->generate_payload(generator,(payload_t *)attribute);
        tester->assert_true(tester,(status == SUCCESS),"generate_payload call check");
@@ -194,7 +194,7 @@ void test_generator_with_transform_attribute(tester_t *tester)
        data.ptr = (void *) stringval;
        data.len = 25;
                
-       status = attribute->set_value(attribute,data);
+       status = attribute->set_value_chunk(attribute,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        
        status = attribute->set_attribute_type(attribute,456);
@@ -252,7 +252,7 @@ void test_generator_with_transform_substructure(tester_t *tester)
        char *stringval = "abcd";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute1->set_value(attribute1,data);
+       status = attribute1->set_value_chunk(attribute1,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute1->set_attribute_type(attribute1,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -263,7 +263,7 @@ void test_generator_with_transform_substructure(tester_t *tester)
        stringval = "efgh";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute2->set_value(attribute2,data);
+       status = attribute2->set_value_chunk(attribute2,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute2->set_attribute_type(attribute2,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -333,7 +333,7 @@ void test_generator_with_proposal_substructure(tester_t *tester)
        char *stringval = "abcd";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute1->set_value(attribute1,data);
+       status = attribute1->set_value_chunk(attribute1,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute1->set_attribute_type(attribute1,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -344,7 +344,7 @@ void test_generator_with_proposal_substructure(tester_t *tester)
        stringval = "efgh";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute2->set_value(attribute2,data);
+       status = attribute2->set_value_chunk(attribute2,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute2->set_attribute_type(attribute2,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -355,7 +355,7 @@ void test_generator_with_proposal_substructure(tester_t *tester)
        stringval = "ijkl";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute3->set_value(attribute3,data);
+       status = attribute3->set_value_chunk(attribute3,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute3->set_attribute_type(attribute3,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -471,7 +471,7 @@ void test_generator_with_sa_payload(tester_t *tester)
        char *stringval = "abcd";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute1->set_value(attribute1,data);
+       status = attribute1->set_value_chunk(attribute1,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute1->set_attribute_type(attribute1,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -482,7 +482,7 @@ void test_generator_with_sa_payload(tester_t *tester)
        stringval = "efgh";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute2->set_value(attribute2,data);
+       status = attribute2->set_value_chunk(attribute2,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute2->set_attribute_type(attribute2,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -493,7 +493,7 @@ void test_generator_with_sa_payload(tester_t *tester)
        stringval = "ijkl";
        data.ptr = (void *) stringval;
        data.len = 4;
-       status = attribute3->set_value(attribute3,data);
+       status = attribute3->set_value_chunk(attribute3,data);
        tester->assert_true(tester,(status == SUCCESS),"set_value call check");
        status = attribute3->set_attribute_type(attribute3,0);
        tester->assert_true(tester,(status == SUCCESS),"set_attribute_type call check");
@@ -763,7 +763,7 @@ void test_generator_with_nonce_payload(tester_t *tester)
        nonce_payload = nonce_payload_create();
        
        
-       nonce.ptr = "1234567890123456";
+       nonce.ptr = allocator_clone_bytes("1234567890123456", strlen("1234567890123456"));
        nonce.len = strlen(nonce.ptr);
 
        nonce_payload->set_nonce(nonce_payload,nonce);
@@ -772,6 +772,7 @@ void test_generator_with_nonce_payload(tester_t *tester)
        tester->assert_true(tester,(status == SUCCESS),"generate_payload call check");
        tester->assert_true(tester,(generator->write_to_chunk(generator,&generated_data) == SUCCESS),"write_to_chunk call check");
        logger->log_chunk(logger,RAW,"generated payload",&generated_data);      
+       
 
        u_int8_t expected_generation[] = {
                /* payload header */
index 5583226..5523ab0 100644 (file)
@@ -31,30 +31,26 @@ 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 is_initiator;
        bool are_equal = FALSE;
        
-       initiator.high = 0;
-       initiator.low = 0;
+       initiator = 0;
 
-       initiator2.high = 12345612;
-       initiator2.low = 978675;
+       initiator2 = 12345612;
        
-       responder.high = 34334;
-       responder.low = 9655;
+       responder = 34334;
 
-       responder2.high = 987863;
-       responder2.low = 3827;
+       responder2 = 987863;
        
-       role = INITIATOR;
+       is_initiator = TRUE;
        
-       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);
+       ike_sa_id = ike_sa_id_create(initiator, responder, is_initiator);
+       equal = ike_sa_id_create(initiator, responder, is_initiator);
+       other1 = ike_sa_id_create(initiator, responder2, is_initiator);
+       other2 = ike_sa_id_create(initiator2, responder2, is_initiator);
+       other3 = ike_sa_id_create(initiator2, responder, is_initiator);
+       is_initiator = FALSE;
+       other4 = ike_sa_id_create(initiator, responder, is_initiator);
        
        /* check equality */
        tester->assert_true(tester,(ike_sa_id->equals(ike_sa_id,equal,&are_equal) == SUCCESS), "equal call check");
index f2f8c97..5bb8c75 100644 (file)
@@ -97,7 +97,7 @@ void test_ike_sa_manager(tester_t *tester)
        memset(&initiator, 0, sizeof(initiator));
        memset(&responder, 0, sizeof(responder));
        
-       ike_sa_id = ike_sa_id_create(initiator, responder, INITIATOR);
+       ike_sa_id = ike_sa_id_create(initiator, responder, TRUE);
 
        status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
        tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA");
@@ -105,7 +105,7 @@ void test_ike_sa_manager(tester_t *tester)
         * this is usually done be the response from the communication partner, 
         * but we don't have one...
         */
-       responder.low = 123;
+       responder = 123;
 
        sa_id = ike_sa->get_id(ike_sa);
        sa_id->set_responder_spi(sa_id, responder);     
@@ -156,8 +156,8 @@ void test_ike_sa_manager(tester_t *tester)
        memset(&initiator, 0, sizeof(initiator));
        memset(&responder, 0, sizeof(responder));
        
-       initiator.low = 123;
-       ike_sa_id = ike_sa_id_create(initiator, responder, RESPONDER);
+       initiator = 123;
+       ike_sa_id = ike_sa_id_create(initiator, responder, TRUE);
        
        status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
        tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 2");
@@ -196,8 +196,8 @@ void test_ike_sa_manager(tester_t *tester)
        
        for (i = 0; i < sa_count; i++) 
        {
-               initiator.low = i + 1;
-               ike_sa_id = ike_sa_id_create(initiator, responder, RESPONDER);
+               initiator = i + 1;
+               ike_sa_id = ike_sa_id_create(initiator, responder, FALSE);
                
                status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
                tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 3");
index e052fd6..8a704c2 100644 (file)
@@ -32,36 +32,26 @@ 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;
+       bool is_initiator;
        
 
-       initiator.high = 0;
-       initiator.low = 0;
-       responder.high = 34334;
-       responder.low = 9655;
-       role = INITIATOR;
+       initiator = 0;
+       responder = 34334LL;
+       is_initiator = TRUE;
        /* create a ike_sa_id object for the new IKE_SA */
-       ike_sa_id = ike_sa_id_create(initiator, responder, role);
+       ike_sa_id = ike_sa_id_create(initiator, responder, is_initiator);
        
        /* 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");
+       ike_sa->initialize_connection(ike_sa, NULL);
        
-       tester->assert_true(tester,(ike_sa->process_configuration(ike_sa,configuration) == SUCCESS), "process_configuration call check");
+       tester->assert_true(tester,(ike_sa != NULL), "ike_sa pointer 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);
 }
index 4646648..8bac066 100644 (file)
@@ -25,7 +25,9 @@
 #include "packet_test.h"
 
 #include "../packet.h"
+#include "../globals.h"
 #include "../utils/allocator.h"
+#include "../utils/logger_manager.h"
 
 
 /*
  */
 void test_packet(tester_t *tester)
 {
-       packet_t *packet = packet_create(AF_INET);
+       packet_t *packet = packet_create();
        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);
+       packet->data.ptr = allocator_alloc(strlen(string_to_copy) + 1);
+       tester->assert_true(tester,(packet->data.ptr != NULL),"NULL pointer check");
+       
+       packet->data.len = strlen(string_to_copy) + 1;
+       strcpy(packet->data.ptr,string_to_copy);
 
        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");
+       tester->assert_true(tester,(packet->data.len == (strlen(string_to_copy) + 1)),"value length check");
        
+       tester->assert_true(tester,(memcmp(packet->data.ptr,packet2->data.ptr,packet->data.len) == 0),"cloned value check");
        
        packet2->destroy(packet2);
        packet->destroy(packet);
-       
-       
-       
 }
index bf5cc41..ef7e07e 100644 (file)
@@ -160,7 +160,7 @@ void test_parser_with_sa_payload(tester_t *tester)
                                        u_int8_t value[] = {0x05, 0x00};
                                        chunk_t attribute_value;
                                        tester->assert_true(tester,(attribute->get_attribute_type(attribute) == 1),"attribute 1 type");
-                                       attribute_value = attribute->get_value(attribute);
+                                       attribute_value = attribute->get_value_chunk(attribute);
                                        tester->assert_false(tester,(memcmp(&value, attribute_value.ptr, attribute_value.len)),"attribute 1 value");
                                }
                                if (loopi == 1)
@@ -168,7 +168,7 @@ void test_parser_with_sa_payload(tester_t *tester)
                                        u_int8_t value[] = {0x01, 0x02, 0x03, 0x04};
                                        chunk_t attribute_value;
                                        tester->assert_true(tester,(attribute->get_attribute_type(attribute) == 3),"attribute 2 type");
-                                       attribute_value = attribute->get_value(attribute);
+                                       attribute_value = attribute->get_value_chunk(attribute);
                                        tester->assert_false(tester,(memcmp(&value, attribute_value.ptr, attribute_value.len)),"attribute 2 value");
                                }
                                loopi++;
@@ -219,6 +219,7 @@ void test_parser_with_nonce_payload(tester_t *tester)
        tester->assert_true(tester,(result.len == 16), "parsed nonce lenght");
        tester->assert_false(tester,(memcmp(nonce_bytes + 4, result.ptr, result.len)), "parsed nonce data");
        nonce_payload->destroy(nonce_payload);
+       
 }
 
 /*
index 6e1114a..471659f 100644 (file)
@@ -60,8 +60,8 @@ void test_receiver(tester_t *tester)
 
        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 = packet_create();
+               packet->destination = host_create(AF_INET,DESTINATION_IP,PORT_TO_SEND);
                packet->data.ptr = allocator_alloc_thing(int);
                packet->data.len = ( sizeof(int));
                *((int *) (packet->data.ptr)) = i;
index 8617686..226be91 100644 (file)
@@ -58,7 +58,7 @@ void test_sender(tester_t *tester)
        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->destination = host_create(AF_INET,DESTINATION_IP,PORT_TO_SEND);
                packet->data.ptr = allocator_alloc_thing(int);
                packet->data.len = ( sizeof(int));
                *((int *) (packet->data.ptr)) = i;
index 2dfcf43..df0ebe3 100644 (file)
@@ -45,7 +45,7 @@ void test_socket(tester_t *tester)
        pkt->data.len = strlen(test_string) + 1;
 
        /* send to previously bound socket */
-       pkt->set_destination(pkt, "127.0.0.1", 4500);
+       pkt->destination = host_create(AF_INET, "127.0.0.1", 4500);
 
        /* send packet_count packets */
        for (current = 0; current < packet_count; current++)
index 22ac640..6353fc0 100644 (file)
@@ -200,7 +200,7 @@ logger_manager_t *global_logger_manager;
        &linked_list_insert_and_remove_test,
        &thread_pool_test,
        &job_queue_test1,
-       &event_queue_test,
+       //&event_queue_test,
        &send_queue_test,
        &scheduler_test,
        &socket_test,
@@ -237,8 +237,10 @@ logger_manager_t *global_logger_manager;
                
        tester_t *tester = tester_create(test_output, FALSE);
 
+
        tester->perform_tests(tester,all_tests);
-//     tester->perform_test(tester,&event_queue_test);  
+       //tester->perform_test(tester,&packet_test); 
+
 
        
        tester->destroy(tester);