Loading tests/data/test558 +8 −23 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ lib558 </tool> <name> loop testing internal hash testing </name> <command> nothing Loading @@ -26,28 +26,13 @@ nothing # Verify data after the test has been "shot" <verify> <stdout mode="text"> malloc of root struct OK malloc of pointer table OK initializing table... table initialized OK filling pointer table... malloc of pointed element (idx 0) OK malloc of pointed element (idx 1) OK malloc of pointed element (idx 2) OK malloc of pointed element (idx 3) OK malloc of pointed element (idx 4) OK malloc of pointed element (idx 5) OK malloc of pointed element (idx 6) OK malloc of pointed element (idx 7) OK malloc of pointed element (idx 8) OK malloc of pointed element (idx 9) OK pointer table filling OK freeing pointers in table... freeing pointers in table OK freeing table... freeing table OK freeing root struct... freeing root struct OK easy handle init OK creating hash... hash creation OK destroying hash... hash destruction OK destroying easy handle... easy handle destruction OK </stdout> </verify> Loading tests/libtest/lib558.c +63 −92 Original line number Diff line number Diff line Loading @@ -8,120 +8,91 @@ * $Id$ */ #include "test.h" #include "memdebug.h" #define TABLE_SIZE 10 #ifdef HAVE_NETDB_H #include <netdb.h> #endif #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> #endif #define ENABLE_CURLX_PRINTF #include "curlx.h" struct element_st { int idx; int dummy; }; struct root_st { struct element_st **table; int size; }; #include "hash.h" #include "hostip.h" #include "memory.h" #include "memdebug.h" static struct root_st * new_root(void) int test(char *URL) { struct root_st *r; r = malloc(sizeof(struct root_st)); if(r != NULL) printf("malloc of root struct OK\n"); else { printf("malloc of root struct failed\n"); return NULL; } CURL *easyh; struct curl_hash *hp; char *data_key; struct Curl_dns_entry *data_node; struct Curl_dns_entry *nodep; size_t key_len; r->size = TABLE_SIZE; r->table = malloc(r->size * sizeof(struct element_st *)); if(r->table != NULL) printf("malloc of pointer table OK\n"); else { printf("malloc of pointer table failed\n"); free(r); return NULL; } (void)URL; /* not used */ return r; easyh = curl_easy_init(); if(!easyh) { printf("easy handle init failed\n"); return TEST_ERR_MAJOR_BAD; } printf("easy handle init OK\n"); static struct element_st * new_element(int idx) { struct element_st *e; e = malloc(sizeof(struct element_st)); if(e != NULL) printf("malloc of pointed element (idx %d) OK\n", idx); else { printf("malloc of pointed element (idx %d) failed\n", idx); return NULL; printf("creating hash...\n"); hp = Curl_mk_dnscache(); if(!hp) { printf("hash creation failed\n"); return TEST_ERR_MAJOR_BAD; } printf("hash creation OK\n"); e->idx = e->dummy = idx; /**/ return e; data_key = aprintf("%s:%d", "dummy", 0); if(!data_key) { printf("data key creation failed\n"); return TEST_ERR_MAJOR_BAD; } key_len = strlen(data_key); int test(char *URL) { struct root_st *root; int error; int i; (void)URL; /* not used */ root = new_root(); if(!root) data_node = calloc(1, sizeof(struct Curl_dns_entry)); if(!data_node) { printf("data node creation failed\n"); return TEST_ERR_MAJOR_BAD; printf("initializing table...\n"); for (i = 0; i < root->size; ++i) { root->table[i] = NULL; } printf("table initialized OK\n"); printf("filling pointer table...\n"); error = 0; for (i = 0; i < root->size; ++i) { root->table[i] = new_element(i); if(!root->table[i]) { error = 1; break; } } if(error) { printf("pointer table filling failed\n"); data_node->addr = Curl_ip2addr(INADDR_ANY, "dummy", 0); if(!data_node->addr) { printf("actual data creation failed\n"); return TEST_ERR_MAJOR_BAD; } else printf("pointer table filling OK\n"); printf("freeing pointers in table...\n"); for (i = 0; i < root->size; ++i) { if(root->table[i]) free(root->table[i]); nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); if(!nodep) { printf("insertion into hash failed\n"); return TEST_ERR_MAJOR_BAD; } printf("freeing pointers in table OK\n"); printf("freeing table...\n"); free(root->table); printf("freeing table OK\n"); free(data_key); /**/ printf("freeing root struct...\n"); free(root); printf("freeing root struct OK\n"); printf("destroying hash...\n"); Curl_hash_destroy(hp); printf("hash destruction OK\n"); printf("destroying easy handle...\n"); curl_easy_cleanup(easyh); printf("easy handle destruction OK\n"); curl_global_cleanup(); return 0; /* OK */ } Loading
tests/data/test558 +8 −23 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ lib558 </tool> <name> loop testing internal hash testing </name> <command> nothing Loading @@ -26,28 +26,13 @@ nothing # Verify data after the test has been "shot" <verify> <stdout mode="text"> malloc of root struct OK malloc of pointer table OK initializing table... table initialized OK filling pointer table... malloc of pointed element (idx 0) OK malloc of pointed element (idx 1) OK malloc of pointed element (idx 2) OK malloc of pointed element (idx 3) OK malloc of pointed element (idx 4) OK malloc of pointed element (idx 5) OK malloc of pointed element (idx 6) OK malloc of pointed element (idx 7) OK malloc of pointed element (idx 8) OK malloc of pointed element (idx 9) OK pointer table filling OK freeing pointers in table... freeing pointers in table OK freeing table... freeing table OK freeing root struct... freeing root struct OK easy handle init OK creating hash... hash creation OK destroying hash... hash destruction OK destroying easy handle... easy handle destruction OK </stdout> </verify> Loading
tests/libtest/lib558.c +63 −92 Original line number Diff line number Diff line Loading @@ -8,120 +8,91 @@ * $Id$ */ #include "test.h" #include "memdebug.h" #define TABLE_SIZE 10 #ifdef HAVE_NETDB_H #include <netdb.h> #endif #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> #endif #define ENABLE_CURLX_PRINTF #include "curlx.h" struct element_st { int idx; int dummy; }; struct root_st { struct element_st **table; int size; }; #include "hash.h" #include "hostip.h" #include "memory.h" #include "memdebug.h" static struct root_st * new_root(void) int test(char *URL) { struct root_st *r; r = malloc(sizeof(struct root_st)); if(r != NULL) printf("malloc of root struct OK\n"); else { printf("malloc of root struct failed\n"); return NULL; } CURL *easyh; struct curl_hash *hp; char *data_key; struct Curl_dns_entry *data_node; struct Curl_dns_entry *nodep; size_t key_len; r->size = TABLE_SIZE; r->table = malloc(r->size * sizeof(struct element_st *)); if(r->table != NULL) printf("malloc of pointer table OK\n"); else { printf("malloc of pointer table failed\n"); free(r); return NULL; } (void)URL; /* not used */ return r; easyh = curl_easy_init(); if(!easyh) { printf("easy handle init failed\n"); return TEST_ERR_MAJOR_BAD; } printf("easy handle init OK\n"); static struct element_st * new_element(int idx) { struct element_st *e; e = malloc(sizeof(struct element_st)); if(e != NULL) printf("malloc of pointed element (idx %d) OK\n", idx); else { printf("malloc of pointed element (idx %d) failed\n", idx); return NULL; printf("creating hash...\n"); hp = Curl_mk_dnscache(); if(!hp) { printf("hash creation failed\n"); return TEST_ERR_MAJOR_BAD; } printf("hash creation OK\n"); e->idx = e->dummy = idx; /**/ return e; data_key = aprintf("%s:%d", "dummy", 0); if(!data_key) { printf("data key creation failed\n"); return TEST_ERR_MAJOR_BAD; } key_len = strlen(data_key); int test(char *URL) { struct root_st *root; int error; int i; (void)URL; /* not used */ root = new_root(); if(!root) data_node = calloc(1, sizeof(struct Curl_dns_entry)); if(!data_node) { printf("data node creation failed\n"); return TEST_ERR_MAJOR_BAD; printf("initializing table...\n"); for (i = 0; i < root->size; ++i) { root->table[i] = NULL; } printf("table initialized OK\n"); printf("filling pointer table...\n"); error = 0; for (i = 0; i < root->size; ++i) { root->table[i] = new_element(i); if(!root->table[i]) { error = 1; break; } } if(error) { printf("pointer table filling failed\n"); data_node->addr = Curl_ip2addr(INADDR_ANY, "dummy", 0); if(!data_node->addr) { printf("actual data creation failed\n"); return TEST_ERR_MAJOR_BAD; } else printf("pointer table filling OK\n"); printf("freeing pointers in table...\n"); for (i = 0; i < root->size; ++i) { if(root->table[i]) free(root->table[i]); nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); if(!nodep) { printf("insertion into hash failed\n"); return TEST_ERR_MAJOR_BAD; } printf("freeing pointers in table OK\n"); printf("freeing table...\n"); free(root->table); printf("freeing table OK\n"); free(data_key); /**/ printf("freeing root struct...\n"); free(root); printf("freeing root struct OK\n"); printf("destroying hash...\n"); Curl_hash_destroy(hp); printf("hash destruction OK\n"); printf("destroying easy handle...\n"); curl_easy_cleanup(easyh); printf("easy handle destruction OK\n"); curl_global_cleanup(); return 0; /* OK */ }