aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-05-18 21:48:14 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-05-18 22:56:46 +0200
commit873d70a6d8863346f4b70001b5a3d6d161086171 (patch)
tree4eb3c07dde31602670946396fd0a78d6ab95c4f5 /tests/libtest
parent6dfa16c3c47b0226b9835a7246bbc08d872e3eab (diff)
tests: verify OPEN/CLOSESOCKETFUNCTION
Test 585 and 586 were added. Using a modified lib500.c
Diffstat (limited to 'tests/libtest')
-rw-r--r--tests/libtest/Makefile.inc5
-rw-r--r--tests/libtest/lib500.c35
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index a210cbfe3..06cda1e92 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -12,7 +12,7 @@ noinst_PROGRAMS = chkhostname \
lib579 lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 \
lib543 lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 \
lib556 lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 lib568 \
- lib569 lib570 lib571 lib572 lib573 lib582 lib583
+ lib569 lib570 lib571 lib572 lib573 lib582 lib583 lib585
chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c
chkhostname_LDADD = @CURL_NETWORK_LIBS@
@@ -160,3 +160,6 @@ lib579_SOURCES = lib579.c $(SUPPORTFILES)
lib582_SOURCES = lib582.c $(SUPPORTFILES) $(TESTUTIL)
lib583_SOURCES = lib583.c $(SUPPORTFILES)
+
+lib585_SOURCES = lib500.c $(SUPPORTFILES)
+lib585_CFLAGS = -DLIB585
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) {