From 92f3b3895eed05d12aeae75e9ee174698550378a Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 27 Oct 2008 20:01:58 +0000 Subject: test #558 tests internal hash create/destroy test #559 tests internal hash create/add/destroy --- tests/libtest/lib558.c | 69 +++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 32 deletions(-) (limited to 'tests/libtest/lib558.c') diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index f51243d21..f1095d45e 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -26,6 +26,7 @@ #include "memory.h" #include "memdebug.h" +/* This source file is used for test # 558 and 559 */ /* * This hacky test bypasses the library external API, @@ -38,7 +39,7 @@ #if !defined(CURL_HIDDEN_SYMBOLS) - +#ifdef LIB559 static Curl_addrinfo *fake_ai(void) { Curl_addrinfo *ai; @@ -72,16 +73,13 @@ static Curl_addrinfo *fake_ai(void) return ai; } +#endif /* LIB559 */ int test(char *URL) { CURL *easyh; struct curl_hash *hp; - char *data_key; - struct Curl_dns_entry *data_node; - struct Curl_dns_entry *nodep; - size_t key_len; if(!strcmp(URL, "check")) { /* test harness script verifying if this test can run */ @@ -104,34 +102,41 @@ int test(char *URL) fprintf(stdout, "hash creation OK\n"); /**/ - - data_key = aprintf("%s:%d", "dummy", 0); - if(!data_key) { - fprintf(stdout, "data key creation failed\n"); - return TEST_ERR_MAJOR_BAD; - } - key_len = strlen(data_key); - - data_node = calloc(1, sizeof(struct Curl_dns_entry)); - if(!data_node) { - fprintf(stdout, "data node creation failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - data_node->addr = fake_ai(); - if(!data_node->addr) { - fprintf(stdout, "actual data creation failed\n"); - return TEST_ERR_MAJOR_BAD; +#ifdef LIB559 + { + char *data_key; + struct Curl_dns_entry *data_node; + struct Curl_dns_entry *nodep; + size_t key_len; + + data_key = aprintf("%s:%d", "dummy", 0); + if(!data_key) { + fprintf(stdout, "data key creation failed\n"); + return TEST_ERR_MAJOR_BAD; + } + key_len = strlen(data_key); + + data_node = calloc(1, sizeof(struct Curl_dns_entry)); + if(!data_node) { + fprintf(stdout, "data node creation failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + data_node->addr = fake_ai(); + if(!data_node->addr) { + fprintf(stdout, "actual data creation failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); + if(!nodep) { + fprintf(stdout, "insertion into hash failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + free(data_key); } - - nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node); - if(!nodep) { - fprintf(stdout, "insertion into hash failed\n"); - return TEST_ERR_MAJOR_BAD; - } - - free(data_key); - +#endif /* LIB559 */ /**/ fprintf(stdout, "destroying hash...\n"); -- cgit v1.2.3