1
/*****************************************************************************
3
* Project ___| | | | _ \| |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
8
* $Id: lib558.c,v 1.9 2008-11-07 12:22:43 yangtse Exp $
13
#ifdef HAVE_SYS_SOCKET_H
14
# include <sys/socket.h>
16
#ifdef HAVE_NETINET_IN_H
17
# include <netinet/in.h>
22
#ifdef HAVE_ARPA_INET_H
23
# include <arpa/inet.h>
26
#define ENABLE_CURLX_PRINTF
35
/* This source file is used for test # 558 and 559 */
38
* This hacky test bypasses the library external API,
39
* using internal only libcurl functions. So don't be
40
* surprised if we cannot run it when the library has
41
* been built with hidden symbols, exporting only the
42
* ones in the public API.
46
#if !defined(CURL_HIDDEN_SYMBOLS)
49
static Curl_addrinfo *fake_ai(void)
54
ss_size = sizeof (struct sockaddr_in);
56
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
59
if((ai->ai_canonname = strdup("dummy")) == NULL) {
64
if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
65
free(ai->ai_canonname);
70
ai->ai_family = AF_INET;
71
ai->ai_addrlen = ss_size;
81
struct curl_hash *hp = NULL;
84
if(!strcmp(URL, "check")) {
85
/* test harness script verifying if this test can run */
86
return 0; /* sure, run this! */
89
easyh = curl_easy_init();
91
fprintf(stdout, "easy handle init failed\n");
92
result = TEST_ERR_MAJOR_BAD;
95
fprintf(stdout, "easy handle init OK\n");
97
fprintf(stdout, "creating hash...\n");
98
hp = Curl_mk_dnscache();
100
fprintf(stdout, "hash creation failed\n");
101
result = TEST_ERR_MAJOR_BAD;
104
fprintf(stdout, "hash creation OK\n");
110
struct Curl_dns_entry *data_node;
111
struct Curl_dns_entry *nodep;
114
data_key = aprintf("%s:%d", "dummy", 0);
116
fprintf(stdout, "data key creation failed\n");
117
result = TEST_ERR_MAJOR_BAD;
120
key_len = strlen(data_key);
122
data_node = calloc(1, sizeof(struct Curl_dns_entry));
124
fprintf(stdout, "data node creation failed\n");
125
result = TEST_ERR_MAJOR_BAD;
130
data_node->addr = fake_ai();
131
if(!data_node->addr) {
132
fprintf(stdout, "actual data creation failed\n");
133
result = TEST_ERR_MAJOR_BAD;
139
nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node);
141
fprintf(stdout, "insertion into hash failed\n");
142
result = TEST_ERR_MAJOR_BAD;
143
Curl_freeaddrinfo(data_node->addr);
156
fprintf(stdout, "destroying hash...\n");
157
Curl_hash_destroy(hp);
158
fprintf(stdout, "hash destruction OK\n");
160
fprintf(stdout, "destroying easy handle...\n");
161
curl_easy_cleanup(easyh);
162
fprintf(stdout, "easy handle destruction OK\n");
164
curl_global_cleanup();
170
#else /* !defined(CURL_HIDDEN_SYMBOLS) */
176
fprintf(stdout, "libcurl built with hidden symbols");
177
return 1; /* skip test */
181
#endif /* !defined(CURL_HIDDEN_SYMBOLS) */