aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/Makefile.am2
-rw-r--r--tests/data/test151280
-rw-r--r--tests/libtest/Makefile.inc6
-rw-r--r--tests/libtest/lib1512.c89
4 files changed, 175 insertions, 2 deletions
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index eaaf7eca2..0d5c29d88 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -113,7 +113,7 @@ test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
test1408 test1409 test1410 test1412 test1413 test1414 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
-test1508 test1509 test1510 test1511 \
+test1508 test1509 test1510 test1511 test1512 \
\
test1900 test1901 test1902 test1903 \
\
diff --git a/tests/data/test1512 b/tests/data/test1512
new file mode 100644
index 000000000..9d2134b2a
--- /dev/null
+++ b/tests/data/test1512
@@ -0,0 +1,80 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+GLOBAL DNS CACHE
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data1>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 47
+
+file contents should appear once for each file
+</data1>
+<data2>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 47
+
+file contents should appear once for each file
+</data2>
+<data3>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 47
+
+file contents should appear once for each file
+</data3>
+<data4>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 47
+
+file contents should appear once for each file
+</data4>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<tool>
+lib1512
+</tool>
+ <name>
+GLOBAL CACHE test over two easy performs
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/path/1512 %HOSTIP %HTTPPORT
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET /path/15120001 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+GET /path/15120002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+<strip>
+^Host:.*
+</strip>
+<stripfile>
+$_ = '' if (($_ !~ /left intact/) && ($_ !~ /Closing connection/))
+</stripfile>
+</verify>
+</testcase>
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 664e00063..cf6210591 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -21,7 +21,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \
lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
- lib1509 lib1510 lib1511 \
+ lib1509 lib1510 lib1511 lib1512 \
lib1900 \
lib2033
@@ -339,6 +339,10 @@ lib1511_SOURCES = lib1511.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1511_LDADD = $(TESTUTIL_LIBS)
lib1511_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1511
+lib1512_SOURCES = lib1512.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib1512_LDADD = $(TESTUTIL_LIBS)
+lib1512_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1512
+
lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1900_LDADD = $(TESTUTIL_LIBS)
lib1900_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/tests/libtest/lib1512.c b/tests/libtest/lib1512.c
new file mode 100644
index 000000000..93d5ea908
--- /dev/null
+++ b/tests/libtest/lib1512.c
@@ -0,0 +1,89 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2013, Linus Nielsen Feltzing <linus@haxx.se>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/*
+ * Use global DNS cache (while deprecated it should still work), populate it
+ * with CURLOPT_RESOLVE in the first request and then make sure a subsequent
+ * easy transfer finds and uses the populated stuff.
+ */
+
+#include "test.h"
+
+#include "memdebug.h"
+
+#define NUM_HANDLES 2
+
+int test(char *URL)
+{
+ CURLcode res;
+ CURL *curl[NUM_HANDLES] = {NULL, NULL};
+ char *port = libtest_arg3;
+ char *address = libtest_arg2;
+ char dnsentry[256];
+ struct curl_slist *slist = NULL;
+ int i;
+ char target_url[256];
+ (void)URL; /* URL is setup in the code */
+
+ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ fprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ sprintf(dnsentry, "server.example.curl:%s:%s", port, address);
+ printf("%s\n", dnsentry);
+ slist = curl_slist_append(slist, dnsentry);
+
+ /* get NUM_HANDLES easy handles */
+ for(i=0; i < NUM_HANDLES; i++) {
+ /* get an easy handle */
+ easy_init(curl[i]);
+ /* specify target */
+ sprintf(target_url, "http://server.example.curl:%s/path/1512%04i",
+ port, i + 1);
+ target_url[sizeof(target_url) - 1] = '\0';
+ easy_setopt(curl[i], CURLOPT_URL, target_url);
+ /* go verbose */
+ easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
+ /* include headers */
+ easy_setopt(curl[i], CURLOPT_HEADER, 1L);
+
+ easy_setopt(curl[i], CURLOPT_DNS_USE_GLOBAL_CACHE, 1L);
+ }
+
+ /* make the first one populate the GLOBAL cache */
+ easy_setopt(curl[0], CURLOPT_RESOLVE, slist);
+
+ /* run NUM_HANDLES transfers */
+ for(i=0; (i < NUM_HANDLES) && !res; i++)
+ res = curl_easy_perform(curl[i]);
+
+test_cleanup:
+
+ curl_easy_cleanup(curl[0]);
+ curl_easy_cleanup(curl[1]);
+ curl_slist_free_all(slist);
+ curl_global_cleanup();
+
+ return (int)res;
+}
+