diff options
Diffstat (limited to 'tests/libtest')
-rw-r--r-- | tests/libtest/Makefile.am | 4 | ||||
-rw-r--r-- | tests/libtest/Makefile.inc | 15 | ||||
-rw-r--r-- | tests/libtest/lib1521.c | 40 | ||||
-rw-r--r-- | tests/libtest/lib1555.c | 77 | ||||
-rw-r--r-- | tests/libtest/lib1556.c | 78 | ||||
-rw-r--r-- | tests/libtest/lib517.c | 228 | ||||
-rw-r--r-- | tests/libtest/lib544.c | 11 | ||||
-rw-r--r-- | tests/libtest/lib555.c | 24 | ||||
-rw-r--r-- | tests/libtest/lib560.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib655.c | 112 | ||||
-rw-r--r-- | tests/libtest/mk-lib1521.pl | 3 |
11 files changed, 472 insertions, 122 deletions
diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index a4e85ef0..0b8ebe9a 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -49,6 +49,8 @@ test1022.pl Makefile.inc notexists.pl CMakeLists.txt mk-lib1521.pl CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@ +CFLAGS += @CURL_CFLAG_EXTRAS@ + # Prevent LIBS from being used for all link targets LIBS = $(BLANK_AT_MAKETIME) diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index d8a55e21..e7e8c486 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -20,14 +20,14 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib559 lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 lib570 \ lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \ lib583 lib585 lib586 lib587 lib589 lib590 lib591 lib597 lib598 lib599 \ - lib643 lib644 lib645 lib650 lib651 lib652 lib653 lib654 \ + lib643 lib644 lib645 lib650 lib651 lib652 lib653 lib654 lib655 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \ lib1520 lib1521 \ lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \ lib1534 lib1535 lib1536 lib1537 lib1538 \ lib1540 \ - lib1550 lib1551 lib1552 lib1553 lib1554 \ + lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 \ lib1900 \ lib2033 @@ -327,6 +327,9 @@ lib653_CPPFLAGS = $(AM_CPPFLAGS) lib654_SOURCES = lib654.c $(SUPPORTFILES) lib654_CPPFLAGS = $(AM_CPPFLAGS) +lib655_SOURCES = lib655.c $(SUPPORTFILES) +lib655_CPPFLAGS = $(AM_CPPFLAGS) + lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) lib1500_LDADD = $(TESTUTIL_LIBS) lib1500_CPPFLAGS = $(AM_CPPFLAGS) @@ -477,6 +480,14 @@ lib1553_CPPFLAGS = $(AM_CPPFLAGS) lib1554_SOURCES = lib1554.c $(SUPPORTFILES) lib1554_CPPFLAGS = $(AM_CPPFLAGS) +lib1555_SOURCES = lib1555.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1555_LDADD = $(TESTUTIL_LIBS) +lib1555_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1555 + +lib1556_SOURCES = lib1556.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) +lib1556_LDADD = $(TESTUTIL_LIBS) +lib1556_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1556 + lib1900_SOURCES = lib1900.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1900_LDADD = $(TESTUTIL_LIBS) lib1900_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/libtest/lib1521.c b/tests/libtest/lib1521.c index 2852b865..905e33b7 100644 --- a/tests/libtest/lib1521.c +++ b/tests/libtest/lib1521.c @@ -38,7 +38,7 @@ struct data { /* Unexpected error. CURLE_NOT_BUILT_IN - means disabled at build CURLE_UNKNOWN_OPTION - means no such option (anymore?) - CURLE_SSL_ENGINE_NOTFOUND - set unkown ssl engine + CURLE_SSL_ENGINE_NOTFOUND - set unknown ssl engine CURLE_UNSUPPORTED_PROTOCOL - set bad HTTP version CURLE_BAD_FUNCTION_ARGUMENT - unsupported value */ @@ -99,6 +99,7 @@ static curl_chunk_end_callback chunk_end_cb; static curl_fnmatch_callback fnmatch_cb; static curl_closesocket_callback closesocketcb; static curl_xferinfo_callback xferinfocb; +static curl_resolver_start_callback resolver_start_cb; int test(char *URL) { @@ -2352,6 +2353,40 @@ int test(char *URL) res = curl_easy_setopt(curl, CURLOPT_MIMEPOST, NULL); if(UNEX(res)) { err("MIMEPOST", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, OFF_NO); + if(UNEX(res)) { + err("TIMEVALUE_LARGE", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, OFF_HI); + if(UNEX(res)) { + err("TIMEVALUE_LARGE", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, OFF_LO); + if(UNEX(res)) { + err("TIMEVALUE_LARGE", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 0L); + if(UNEX(res)) { + err("HAPPY_EYEBALLS_TIMEOUT_MS", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 22L); + if(UNEX(res)) { + err("HAPPY_EYEBALLS_TIMEOUT_MS", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, LO); + if(UNEX(res)) { + err("HAPPY_EYEBALLS_TIMEOUT_MS", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, HI); + if(UNEX(res)) { + err("HAPPY_EYEBALLS_TIMEOUT_MS", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, + resolver_start_cb); + if(UNEX(res)) { + err("RESOLVER_START_FUNCTION", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, NULL); + if(UNEX(res)) { + err("RESOLVER_START_FUNCTION", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, &object); + if(UNEX(res)) { + err("RESOLVER_START_DATA", res, __LINE__); goto test_cleanup; } + res = curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, NULL); + if(UNEX(res)) { + err("RESOLVER_START_DATA", res, __LINE__); goto test_cleanup; } res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &charp); if(UNEX(res)) { geterr("EFFECTIVE_URL", res, __LINE__); goto test_cleanup; } @@ -2406,6 +2441,9 @@ int test(char *URL) res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &val); if(UNEX(res)) { geterr("FILETIME", res, __LINE__); goto test_cleanup; } + res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &oval); + if(UNEX(res)) { + geterr("FILETIME_T", res, __LINE__); goto test_cleanup; } res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &dval); if(UNEX(res)) { geterr("CONTENT_LENGTH_DOWNLOAD", res, __LINE__); goto test_cleanup; } diff --git a/tests/libtest/lib1555.c b/tests/libtest/lib1555.c new file mode 100644 index 00000000..e4f2255a --- /dev/null +++ b/tests/libtest/lib1555.c @@ -0,0 +1,77 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2015, 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * 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 https://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. + * + ***************************************************************************/ +/* + * Verify that some API functions are locked from being called inside callback + */ + +#include "test.h" + +#include "memdebug.h" + +static CURL *curl; + +static int progressCallback(void *arg, + double dltotal, + double dlnow, + double ultotal, + double ulnow) +{ + CURLcode res = 0; + (void)arg; + (void)dltotal; + (void)dlnow; + (void)ultotal; + (void)ulnow; + res = curl_easy_recv(curl, NULL, 0, NULL); + printf("curl_easy_recv returned %d\n", res); + res = curl_easy_send(curl, NULL, 0, NULL); + printf("curl_easy_send returned %d\n", res); + + return 1; +} + +int test(char *URL) +{ + int res = 0; + + global_init(CURL_GLOBAL_ALL); + + easy_init(curl); + + easy_setopt(curl, CURLOPT_URL, URL); + easy_setopt(curl, CURLOPT_TIMEOUT, (long)7); + easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); + easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback); + easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL); + easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0); + + res = curl_easy_perform(curl); + +test_cleanup: + + /* undocumented cleanup sequence - type UA */ + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} diff --git a/tests/libtest/lib1556.c b/tests/libtest/lib1556.c new file mode 100644 index 00000000..fa0e60e2 --- /dev/null +++ b/tests/libtest/lib1556.c @@ -0,0 +1,78 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * 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 https://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. + * + ***************************************************************************/ +#include "test.h" + +#include "testutil.h" +#include "warnless.h" +#include "memdebug.h" + +struct headerinfo { + size_t largest; +}; + +static size_t header(void *ptr, size_t size, size_t nmemb, void *stream) +{ + size_t headersize = size * nmemb; + struct headerinfo *info = (struct headerinfo *)stream; + (void)ptr; + + if(headersize > info->largest) + /* remember the longest header */ + info->largest = headersize; + + return nmemb * size; +} + +int test(char *URL) +{ + CURLcode code; + CURL *curl = NULL; + int res = 0; + struct headerinfo info = {0}; + + global_init(CURL_GLOBAL_ALL); + + easy_init(curl); + + easy_setopt(curl, CURLOPT_HEADERFUNCTION, header); + easy_setopt(curl, CURLOPT_HEADERDATA, &info); + easy_setopt(curl, CURLOPT_VERBOSE, 1L); + easy_setopt(curl, CURLOPT_URL, URL); + + code = curl_easy_perform(curl); + if(CURLE_OK != code) { + fprintf(stderr, "%s:%d curl_easy_perform() failed, " + "with code %d (%s)\n", + __FILE__, __LINE__, (int)code, curl_easy_strerror(code)); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + + printf("Max: %ld\n", (long)info.largest); + +test_cleanup: + + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return res; +} diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index af7b2aa7..e7451907 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,117 +23,141 @@ #include "memdebug.h" -static const char * const dates[]={ - "Sun, 06 Nov 1994 08:49:37 GMT", - "Sunday, 06-Nov-94 08:49:37 GMT", - "Sun Nov 6 08:49:37 1994", - "06 Nov 1994 08:49:37 GMT", - "06-Nov-94 08:49:37 GMT", - "Nov 6 08:49:37 1994", - "06 Nov 1994 08:49:37", - "06-Nov-94 08:49:37", - "1994 Nov 6 08:49:37", - "GMT 08:49:37 06-Nov-94 Sunday", - "94 6 Nov 08:49:37", - "1994 Nov 6", - "06-Nov-94", - "Sun Nov 6 94", - "1994.Nov.6", - "Sun/Nov/6/94/GMT", - "Sun, 06 Nov 1994 08:49:37 CET", - "06 Nov 1994 08:49:37 EST", - "Sun, 12 Sep 2004 15:05:58 -0700", - "Sat, 11 Sep 2004 21:32:11 +0200", - "20040912 15:05:58 -0700", - "20040911 +0200", - "Thu, 01-Jan-1970 00:59:59 GMT", - "Thu, 01-Jan-1970 01:00:00 GMT", -/* "2094 Nov 6", See ../data/test517 for details */ - "Sat, 15-Apr-17 21:01:22 GMT", - "Thu, 19-Apr-2007 16:00:00 GMT", - "Wed, 25 Apr 2007 21:02:13 GMT", - "Thu, 19/Apr\\2007 16:00:00 GMT", - "Fri, 1 Jan 2010 01:01:50 GMT", - "Wednesday, 1-Jan-2003 00:00:00 GMT", - ", 1-Jan-2003 00:00:00 GMT", - " 1-Jan-2003 00:00:00 GMT", - "1-Jan-2003 00:00:00 GMT", - "Wed,18-Apr-07 22:50:12 GMT", - "WillyWonka , 18-Apr-07 22:50:12 GMT", - "WillyWonka , 18-Apr-07 22:50:12", - "WillyWonka , 18-apr-07 22:50:12", - "Mon, 18-Apr-1977 22:50:13 GMT", - "Mon, 18-Apr-77 22:50:13 GMT", - "\"Sat, 15-Apr-17\\\"21:01:22\\\"GMT\"", - "Partyday, 18- April-07 22:50:12", - "Partyday, 18 - Apri-07 22:50:12", - "Wednes, 1-Januar-2003 00:00:00 GMT", - "Sat, 15-Apr-17 21:01:22", - "Sat, 15-Apr-17 21:01:22 GMT-2", - "Sat, 15-Apr-17 21:01:22 GMT BLAH", - "Sat, 15-Apr-17 21:01:22 GMT-0400", - "Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", - "Sat, 15-Apr-17 21:01:22 DST", - "Sat, 15-Apr-17 21:01:22 -0400", - "Sat, 15-Apr-17 21:01:22 (hello there)", - "Sat, 15-Apr-17 21:01:22 11:22:33", - "Sat, 15-Apr-17 ::00 21:01:22", - "Sat, 15-Apr-17 boink:z 21:01:22", - "Sat, 15-Apr-17 91:22:33 21:01:22", - "Thu Apr 18 22:50:12 2007 GMT", - "22:50:12 Thu Apr 18 2007 GMT", - "Thu 22:50:12 Apr 18 2007 GMT", - "Thu Apr 22:50:12 18 2007 GMT", - "Thu Apr 18 22:50:12 2007 GMT", - "Thu Apr 18 2007 22:50:12 GMT", - "Thu Apr 18 2007 GMT 22:50:12", - "Sat, 15-Apr-17 21:01:22 GMT", - "15-Sat, Apr-17 21:01:22 GMT", - "15-Sat, Apr 21:01:22 GMT 17", - "15-Sat, Apr 21:01:22 GMT 2017", - "15 Apr 21:01:22 2017", - "15 17 Apr 21:01:22", - "Apr 15 17 21:01:22", - "Apr 15 21:01:22 17", - "2017 April 15 21:01:22", - "15 April 2017 21:01:22", - "98 April 17 21:01:22", - "Thu, 012-Aug-2008 20:49:07 GMT", +struct dcheck { + const char *input; + time_t output; +}; + +static struct dcheck dates[] = { + {"Sun, 06 Nov 1994 08:49:37 GMT", 784111777 }, + {"Sunday, 06-Nov-94 08:49:37 GMT", 784111777 }, + {"Sun Nov 6 08:49:37 1994", 784111777 }, + {"06 Nov 1994 08:49:37 GMT", 784111777 }, + {"06-Nov-94 08:49:37 GMT", 784111777 }, + {"Nov 6 08:49:37 1994", 784111777 }, + {"06 Nov 1994 08:49:37", 784111777 }, + {"06-Nov-94 08:49:37", 784111777 }, + {"1994 Nov 6 08:49:37", 784111777 }, + {"GMT 08:49:37 06-Nov-94 Sunday", 784111777 }, + {"94 6 Nov 08:49:37", 784111777 }, + {"1994 Nov 6", 784080000 }, + {"06-Nov-94", 784080000 }, + {"Sun Nov 6 94", 784080000 }, + {"1994.Nov.6", 784080000 }, + {"Sun/Nov/6/94/GMT", 784080000 }, + {"Sun, 06 Nov 1994 08:49:37 CET", 784108177 }, + {"06 Nov 1994 08:49:37 EST", 784129777 }, + {"Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 }, + {"Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 }, + {"20040912 15:05:58 -0700", 1095026758 }, + {"20040911 +0200", 1094853600 }, + {"Thu, 01-Jan-1970 00:59:59 GMT", 3599 }, + {"Thu, 01-Jan-1970 01:00:00 GMT", 3600 }, + {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, + {"Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 }, + {"Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 }, + {"Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 }, + {"Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 }, + {"Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 }, + {", 1-Jan-2003 00:00:00 GMT", 1041379200 }, + {"1-Jan-2003 00:00:00 GMT", 1041379200 }, + {"1-Jan-2003 00:00:00 GMT", 1041379200 }, + {"Wed,18-Apr-07 22:50:12 GMT", 1176936612 }, + {"WillyWonka , 18-Apr-07 22:50:12 GMT", -1 }, + {"WillyWonka , 18-Apr-07 22:50:12", -1 }, + {"WillyWonka , 18-apr-07 22:50:12", -1 }, + {"Mon, 18-Apr-1977 22:50:13 GMT", 230251813 }, + {"Mon, 18-Apr-77 22:50:13 GMT", 230251813 }, + {"Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 }, + {"Partyday, 18- April-07 22:50:12", -1 }, + {"Partyday, 18 - Apri-07 22:50:12", -1 }, + {"Wednes, 1-Januar-2003 00:00:00 GMT", -1 }, + {"Sat, 15-Apr-17 21:01:22", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 }, + {"Sat, 15-Apr-17 21:01:22 DST", -1 }, + {"Sat, 15-Apr-17 21:01:22 -0400", 1492304482 }, + {"Sat, 15-Apr-17 21:01:22 (hello there)", -1 }, + {"Sat, 15-Apr-17 21:01:22 11:22:33", -1 }, + {"Sat, 15-Apr-17 ::00 21:01:22", -1 }, + {"Sat, 15-Apr-17 boink:z 21:01:22", -1 }, + {"Sat, 15-Apr-17 91:22:33 21:01:22", -1 }, + {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, + {"22:50:12 Thu Apr 18 2007 GMT", 1176936612 }, + {"Thu 22:50:12 Apr 18 2007 GMT", 1176936612 }, + {"Thu Apr 22:50:12 18 2007 GMT", 1176936612 }, + {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, + {"Thu Apr 18 2007 22:50:12 GMT", 1176936612 }, + {"Thu Apr 18 2007 GMT 22:50:12", 1176936612 }, + {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, + {"15-Sat, Apr-17 21:01:22 GMT", 1492290082 }, + {"15-Sat, Apr 21:01:22 GMT 17", 1492290082 }, + {"15-Sat, Apr 21:01:22 GMT 2017", 1492290082 }, + {"15 Apr 21:01:22 2017", 1492290082 }, + {"15 17 Apr 21:01:22", 1492290082 }, + {"Apr 15 17 21:01:22", 1492290082 }, + {"Apr 15 21:01:22 17", 1492290082 }, + {"2017 April 15 21:01:22", -1 }, + {"15 April 2017 21:01:22", -1 }, + {"98 April 17 21:01:22", -1 }, + {"Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 }, + {"Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 }, + {"Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 }, + {"IAintNoDateFool", -1 }, + {"Thu Apr 18 22:50 2007 GMT", 1176936600 }, + {"20110623 12:34:56", 1308832496 }, + {"20110632 12:34:56", -1 }, + {"20110623 56:34:56", -1 }, + {"20111323 12:34:56", -1 }, + {"20110623 12:34:79", -1 }, + {"Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 }, + {"20110623 12:3", 1308830580 }, + {"20110623 1:3", 1308790980 }, + {"20110623 1:30", 1308792600 }, + {"20110623 12:12:3", 1308831123 }, + {"20110623 01:12:3", 1308791523 }, + {"20110623 01:99:30", -1 }, + {"Thu, 01-Jan-1970 00:00:00 GMT", 0 }, + {"Thu, 31-Dec-1969 23:59:58 GMT", -2 }, + {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */ +#if SIZEOF_TIME_T > 4 + {"Sun, 06 Nov 2044 08:49:37 GMT", 2362034977 }, + {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 }, +#ifndef HAVE_TIME_T_UNSIGNED #if 0 - /* leaving out these strings since they differ between 32 and 64 bit - archs and the test suite has no good way to support two different outputs - like that */ - "Thu, 12-Aug-31841 20:49:07 GMT", - "Thu, 12-Aug-9999999999 20:49:07 GMT", + /* causes warning on MSVC */ + {"Sun, 06 Nov 1900 08:49:37 GMT", -2182259423 }, +#endif + {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 }, + {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 }, +#endif + {"Thu, 01-Jan-1499 00:00:00 GMT", -1 }, +#else + {"Sun, 06 Nov 2044 08:49:37 GMT", -1 }, +#endif +#ifndef HAVE_TIME_T_UNSIGNED + {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 }, #endif - "Thu, 999999999999-Aug-2007 20:49:07 GMT", - "Thu, 12-Aug-2007 20:61:99999999999 GMT", - "IAintNoDateFool", - "Thu Apr 18 22:50 2007 GMT", /* without seconds */ - "20110623 12:34:56", - "20110632 12:34:56", - "20110623 56:34:56", - "20111323 12:34:56", - "20110623 12:34:79", - "Wed, 31 Dec 2008 23:59:60 GMT", /* leap second */ - "20110623 12:3", - "20110623 1:3", - "20110623 1:30", - "20110623 12:12:3", - "20110623 01:12:3", - "20110623 01:99:30", - NULL + { NULL, 0 } }; int test(char *URL) { int i; + int error = 0; (void)URL; /* not used */ - for(i = 0; dates[i]; i++) { - printf("%d: %s => %ld\n", i, dates[i], (long)curl_getdate(dates[i], NULL)); + for(i = 0; dates[i].input; i++) { + time_t out = curl_getdate(dates[i].input, NULL); + if(out != dates[i].output) { + printf("WRONGLY %s => %ld (instead of %ld)\n", + dates[i].input, out, dates[i].output); + error++; + } } - return 0; + return error; } diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 1f832d2a..cb1aefc8 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,9 +26,12 @@ static char teststring[] = #ifdef CURL_DOES_CONVERSIONS /* ASCII representation with escape sequences for non-ASCII platforms */ - "\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61" - "\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d" - "\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a"; +{ '\x54', '\x68', '\x69', '\x73', '\x00', '\x20', '\x69', '\x73', '\x20', + '\x74', '\x65', '\x73', '\x74', '\x20', '\x62', '\x69', '\x6e', '\x61', + '\x72', '\x79', '\x20', '\x64', '\x61', '\x74', '\x61', '\x20', '\x77', + '\x69', '\x74', '\x68', '\x20', '\x61', '\x6e', '\x20', '\x65', '\x6d', + '\x62', '\x65', '\x64', '\x64', '\x65', '\x64', '\x20', '\x4e', '\x55', + '\x4c'}; #else { 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ', diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index fc71bb64..c887b56f 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,7 +35,15 @@ #define TEST_HANG_TIMEOUT 60 * 1000 -#define UPLOADTHIS "this is the blurb we want to upload\n" +static const char uploadthis[] = +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x74\x68\x69\x73\x20\x69\x73\x20\x74\x68\x65\x20\x62\x6c\x75\x72" + "\x62\x20\x77\x65\x20\x77\x61\x6e\x74\x20\x74\x6f\x20\x75\x70\x6c" + "\x6f\x61\x64\x0a"; +#else + "this is the blurb we want to upload\n"; +#endif static size_t readcallback(void *ptr, size_t size, @@ -51,10 +59,10 @@ static size_t readcallback(void *ptr, } (*counter)++; /* bump */ - if(size * nmemb > strlen(UPLOADTHIS)) { + if(size * nmemb > strlen(uploadthis)) { fprintf(stderr, "READ!\n"); - strcpy(ptr, UPLOADTHIS); - return strlen(UPLOADTHIS); + strcpy(ptr, uploadthis); + return strlen(uploadthis); } fprintf(stderr, "READ NOT FINE!\n"); return 0; @@ -98,13 +106,9 @@ int test(char *URL) easy_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); + easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(uploadthis)); easy_setopt(curl, CURLOPT_POST, 1L); -#ifdef CURL_DOES_CONVERSIONS - /* Convert the POST data to ASCII. */ - easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); -#endif easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); easy_setopt(curl, CURLOPT_PROXYAUTH, diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 0093ea11..16045e6d 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -31,7 +31,7 @@ * Simply download a HTTPS file! * * This test was added after the HTTPS-using-multi-interface with OpenSSL - * regression of 7.19.1 to hopefully prevent this embarassing mistake from + * regression of 7.19.1 to hopefully prevent this embarrassing mistake from * appearing again... Unfortunately the bug wasn't triggered by this test, * which presumably is because the connect to a local server is too * fast/different compared to the real/distant servers we saw the bug happen diff --git a/tests/libtest/lib655.c b/tests/libtest/lib655.c new file mode 100644 index 00000000..8777b99e --- /dev/null +++ b/tests/libtest/lib655.c @@ -0,0 +1,112 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * 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 https://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. + * + ***************************************************************************/ +#include "test.h" + +#include "memdebug.h" + +static const char *TEST_DATA_STRING = "Test data"; +static int cb_count = 0; + +static int +resolver_alloc_cb_fail(void *resolver_state, void *reserved, void *userdata) +{ + (void)resolver_state; + (void)reserved; + + cb_count++; + if(strcmp(userdata, TEST_DATA_STRING)) { + fprintf(stderr, "Invalid test data received"); + exit(1); + } + + return 1; +} + +static int +resolver_alloc_cb_pass(void *resolver_state, void *reserved, void *userdata) +{ + (void)resolver_state; + (void)reserved; + + cb_count++; + if(strcmp(userdata, TEST_DATA_STRING)) { + fprintf(stderr, "Invalid test data received"); + exit(1); + } + + return 0; +} + +int test(char *URL) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + curl = curl_easy_init(); + if(!curl) { + fprintf(stderr, "curl_easy_init() failed\n"); + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + + /* First set the URL that is about to receive our request. */ + test_setopt(curl, CURLOPT_URL, URL); + + test_setopt(curl, CURLOPT_RESOLVER_START_DATA, TEST_DATA_STRING); + test_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_alloc_cb_fail); + + /* this should fail */ + res = curl_easy_perform(curl); + if(res != CURLE_COULDNT_RESOLVE_HOST) { + fprintf(stderr, "curl_easy_perform should have returned " + "CURLE_COULDNT_RESOLVE_HOST but instead returned error %d\n", res); + if(res == CURLE_OK) + res = TEST_ERR_FAILURE; + goto test_cleanup; + } + + test_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_alloc_cb_pass); + + /* this should succeed */ + res = curl_easy_perform(curl); + if(res) { + fprintf(stderr, "curl_easy_perform failed.\n"); + goto test_cleanup; + } + + if(cb_count != 2) { + fprintf(stderr, "Unexpected number of callbacks: %d\n", cb_count); + res = TEST_ERR_FAILURE; + goto test_cleanup; + } + +test_cleanup: + /* always cleanup */ + curl_easy_cleanup(curl); + curl_global_cleanup(); + + return (int)res; +} diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index 6ded4722..9771cf57 100644 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -71,7 +71,7 @@ struct data { /* Unexpected error. CURLE_NOT_BUILT_IN - means disabled at build CURLE_UNKNOWN_OPTION - means no such option (anymore?) - CURLE_SSL_ENGINE_NOTFOUND - set unkown ssl engine + CURLE_SSL_ENGINE_NOTFOUND - set unknown ssl engine CURLE_UNSUPPORTED_PROTOCOL - set bad HTTP version CURLE_BAD_FUNCTION_ARGUMENT - unsupported value */ @@ -132,6 +132,7 @@ static curl_chunk_end_callback chunk_end_cb; static curl_fnmatch_callback fnmatch_cb; static curl_closesocket_callback closesocketcb; static curl_xferinfo_callback xferinfocb; +static curl_resolver_start_callback resolver_start_cb; int test(char *URL) { |