- memory leaks fixed
authorJan Hutter <jhutter@hsr.ch>
Thu, 24 Nov 2005 07:55:29 +0000 (07:55 -0000)
committerJan Hutter <jhutter@hsr.ch>
Thu, 24 Nov 2005 07:55:29 +0000 (07:55 -0000)
- failed tests fixed

Source/charon/testcases/generator_test.c
Source/charon/testcases/hasher_md5_test.c
Source/charon/testcases/hasher_sha1_test.c
Source/charon/testcases/hmac_test.c
Source/charon/testcases/parser_test.c
Source/charon/testcases/testcases.c

index 01090f7..0d32ba1 100644 (file)
@@ -70,10 +70,10 @@ void test_generator_with_header_payload(tester_t *tester)
        tester->assert_true(tester,(generator->write_to_chunk(generator,&generated_data) == SUCCESS),"write_to_chunk call check");
 
        u_int8_t expected_generation[] = {
+               0x01,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,
-               0x00,0x00,0x00,0x01,
+               0x02,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,
-               0x00,0x00,0x00,0x02,
                0x03,0x20,0x06,0x28,
                0x00,0x00,0x00,0x07,
                0x00,0x00,0x00,0x1C,
@@ -104,14 +104,15 @@ void test_generator_with_header_payload(tester_t *tester)
        tester->assert_true(tester,(generator->write_to_chunk(generator,&generated_data) == SUCCESS),"write_to_chunk call check");
 
        u_int8_t expected_generation2[] = {
-               0x00,0x22,0x00,0x00,
-               0x54,0x23,0x12,0x34,
+               0x34,0x12,0x23,0x54,
+               0x00,0x00,0x22,0x00,
+               0x98,0x23,0x12,0x00,
                0x00,0x00,0x00,0x00,
-               0x00,0x12,0x23,0x98,
                0xF3,0x20,0x12,0x28,
                0x00,0x33,0xAF,0xF3,
                0x00,0x00,0x00,0x1C,
        };
+
        
        logger->log_bytes(logger,RAW,"expected header",expected_generation2,sizeof(expected_generation2));
        
@@ -175,7 +176,7 @@ void test_generator_with_transform_attribute(tester_t *tester)
        logger->log_chunk(logger,RAW,"generated attribute",&generated_data);    
 
        u_int8_t expected_generation2[] = {
-               0x80,0x00,0x88,0x16,
+               0x80,0x00,0x16,0x88,
        };
        tester->assert_true(tester,(memcmp(expected_generation2,generated_data.ptr,sizeof(expected_generation2)) == 0), "compare generated data");
 
@@ -574,10 +575,10 @@ void test_generator_with_sa_payload(tester_t *tester)
 
        u_int8_t expected_generation[] = {
                /* sa payload header */
-               0x00,0x22,0x00,0x00,
-               0x54,0x23,0x12,0x34,
+               0x34,0x12,0x23,0x54,
+               0x00,0x00,0x22,0x00,
+               0x98,0x23,0x12,0x00,
                0x00,0x00,0x00,0x00,
-               0x00,0x12,0x23,0x98,
                0x21,0x20,0x12,0x28,
                0x00,0x33,0xAF,0xF3,
                0x00,0x00,0x00,0x60,
@@ -763,7 +764,7 @@ void test_generator_with_nonce_payload(tester_t *tester)
        nonce_payload = nonce_payload_create();
        
        
-       nonce.ptr = allocator_clone_bytes("1234567890123456", strlen("1234567890123456"));
+       nonce.ptr = "1234567890123456";
        nonce.len = strlen("1234567890123456");
 
        nonce_payload->set_nonce(nonce_payload,nonce);
@@ -788,7 +789,8 @@ void test_generator_with_nonce_payload(tester_t *tester)
        
        tester->assert_true(tester,(memcmp(expected_generation,generated_data.ptr,sizeof(expected_generation)) == 0), "compare generated data");
 
-       allocator_free_chunk(generated_data);   
+       allocator_free_chunk(generated_data);
+       
        
        tester->assert_true(tester,(nonce_payload->destroy(nonce_payload) == SUCCESS), "notify_payload destroy call check");
        tester->assert_true(tester,(generator->destroy(generator) == SUCCESS), "generator destroy call check");
index f1402ad..a3fede7 100644 (file)
@@ -90,4 +90,5 @@ void test_hasher_md5(tester_t *tester)
        tester->assert_true(tester, hash_chunk.len == 16, "hash len");
        tester->assert_false(tester, memcmp(hash_chunk.ptr, hash_abcd, hash_chunk.len), "hash for abcd...");
        allocator_free(hash_chunk.ptr);
+       tester->assert_true(tester, (hasher->destroy(hasher) == SUCCESS), "destroy call test");
 }
index 7f46678..79b9a1d 100644 (file)
@@ -100,4 +100,7 @@ void test_hasher_sha1(tester_t *tester)
                } 
        }
        tester->assert_false(tester, memcmp(hash_buffer, hash_aaa, 20), "hash for aaa...");
+       
+
+       tester->assert_true(tester, (hasher->destroy(hasher) == SUCCESS), "destroy call test");
 }
index 8bb75d5..30f6df3 100644 (file)
@@ -216,6 +216,7 @@ void test_hmac_sha1(tester_t *tester)
        
        tester->assert_true(tester, digest[3].len == 20, "chunk len append mode");
        tester->assert_false(tester, memcmp(digest[3].ptr, reference[3].ptr, 20), "hmac value append mode");
+       allocator_free(digest[3].ptr);
 }
 
 /* 
@@ -404,4 +405,5 @@ void test_hmac_md5(tester_t *tester)
        
        tester->assert_true(tester, digest[3].len == 16, "chunk len append mode");
        tester->assert_false(tester, memcmp(digest[3].ptr, reference[3].ptr, 16), "hmac value append mode");
+       allocator_free(digest[3].ptr);
 }
index 85705a1..5ef5e5b 100644 (file)
@@ -49,10 +49,10 @@ void test_parser_with_header_payload(tester_t *tester)
        chunk_t header_chunk;
        
        u_int8_t header_bytes[] = {
+               0x01,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,
-               0x00,0x00,0x00,0x01,
+               0x02,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,
-               0x00,0x00,0x00,0x02,
                0x03,0x45,0x06,0x28,
                0x00,0x00,0x00,0x07,
                0x00,0x00,0x00,0x1C,
@@ -219,7 +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);
-       
+       allocator_free_chunk(result);
 }
 
 /*
index 9574632..937f2f0 100644 (file)
@@ -294,13 +294,17 @@ logger_manager_t *global_logger_manager;
 
 
        tester->perform_tests(tester,all_tests);
-       //tester->perform_test(tester,&hmac_test2); 
+//     tester->perform_test(tester,&hasher_sha1_test); 
 
 
        
        tester->destroy(tester);
 
 
+       /* Destroy objects*/
+       global_configuration_manager->destroy(global_configuration_manager);
+       global_ike_sa_manager->destroy(global_ike_sa_manager);
+       
        /* Destroy all queues */
        global_job_queue->destroy(global_job_queue);
        global_event_queue->destroy(global_event_queue);