diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-05-18 21:48:14 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-05-18 22:56:46 +0200 |
commit | 873d70a6d8863346f4b70001b5a3d6d161086171 (patch) | |
tree | 4eb3c07dde31602670946396fd0a78d6ab95c4f5 /tests/libtest/lib500.c | |
parent | 6dfa16c3c47b0226b9835a7246bbc08d872e3eab (diff) | |
download | curl-873d70a6d8863346f4b70001b5a3d6d161086171.tar.gz |
tests: verify OPEN/CLOSESOCKETFUNCTION
Test 585 and 586 were added. Using a modified lib500.c
Diffstat (limited to 'tests/libtest/lib500.c')
-rw-r--r-- | tests/libtest/lib500.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index b88bfd8bc..166bb85ab 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -23,6 +23,39 @@ #include "memdebug.h" +#ifdef LIB585 + +int counter; + +static int opensocket(void *clientp, + curlsocktype purpose, + struct curl_sockaddr *addr) +{ + (void)clientp; + (void)purpose; + printf("[OPEN] counter: %d\n", ++counter); + return socket(addr->family, addr->socktype, addr->protocol); +} + +static int closesocket(void *clientp, curl_socket_t sock) +{ + (void)clientp; + printf("[CLOSE] counter: %d\n", counter--); + return sclose(sock); +} + +static void setupcallbacks(CURL *curl) +{ + curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); + curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket); + counter = 0; +} + +#else +#define setupcallbacks(x) +#endif + + int test(char *URL) { CURLcode res; @@ -43,6 +76,8 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_HEADER, 1L); + setupcallbacks(curl); + res = curl_easy_perform(curl); if(!res) { |