aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib500.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libtest/lib500.c')
-rw-r--r--tests/libtest/lib500.c35
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) {