diff options
author | Elliott Hughes <enh@google.com> | 2018-03-01 00:44:30 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-03-01 00:44:30 +0000 |
commit | 279fa5e2839348e5b1898acbd247d4e70857f8e1 (patch) | |
tree | ba15caf6905acc99ac3fbab158d7bf2fb0364a21 /tests/libtest | |
parent | b7c7f24e06c79611f4f58dfdeb13af661d50ea37 (diff) | |
parent | 95f668fdba032059552cc770824e1d07821ab64b (diff) | |
download | android_external_curl-279fa5e2839348e5b1898acbd247d4e70857f8e1.tar.gz android_external_curl-279fa5e2839348e5b1898acbd247d4e70857f8e1.tar.bz2 android_external_curl-279fa5e2839348e5b1898acbd247d4e70857f8e1.zip |
Merge "Update to 7.58.0 - January 24 2018." am: 0c6d81f80b
am: 95f668fdba
Change-Id: I56ce9e830e6b121cc97d68e2eabb3ca6d137f40f
Diffstat (limited to 'tests/libtest')
-rw-r--r-- | tests/libtest/Makefile.inc | 5 | ||||
-rw-r--r-- | tests/libtest/lib1502.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib1554.c | 12 | ||||
-rw-r--r-- | tests/libtest/lib518.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib537.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib540.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib557.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib582.c | 1 | ||||
-rw-r--r-- | tests/libtest/lib591.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib597.c | 2 | ||||
-rw-r--r-- | tests/libtest/lib654.c | 174 | ||||
-rw-r--r-- | tests/libtest/libntlmconnect.c | 2 |
12 files changed, 190 insertions, 18 deletions
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 9e1ba28..d8a55e2 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -20,7 +20,7 @@ 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 \ + lib643 lib644 lib645 lib650 lib651 lib652 lib653 lib654 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \ lib1520 lib1521 \ @@ -324,6 +324,9 @@ lib652_CPPFLAGS = $(AM_CPPFLAGS) lib653_SOURCES = lib653.c $(SUPPORTFILES) lib653_CPPFLAGS = $(AM_CPPFLAGS) +lib654_SOURCES = lib654.c $(SUPPORTFILES) +lib654_CPPFLAGS = $(AM_CPPFLAGS) + lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL) lib1500_LDADD = $(TESTUTIL_LIBS) lib1500_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/libtest/lib1502.c b/tests/libtest/lib1502.c index 188c120..6f253c7 100644 --- a/tests/libtest/lib1502.c +++ b/tests/libtest/lib1502.c @@ -29,9 +29,7 @@ #include "test.h" -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include "testutil.h" #include "warnless.h" diff --git a/tests/libtest/lib1554.c b/tests/libtest/lib1554.c index aa4aeb7..8842ae2 100644 --- a/tests/libtest/lib1554.c +++ b/tests/libtest/lib1554.c @@ -44,11 +44,19 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr) int test(char *URL) { CURL *curl; - CURLcode res; + CURLcode res = CURLE_OK; CURLSH *share; int i; + global_init(CURL_GLOBAL_ALL); + share = curl_share_init(); + if(!share) { + fprintf(stderr, "curl_share_init() failed\n"); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD; + } + curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock); curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock); @@ -77,5 +85,7 @@ int test(char *URL) } curl_share_cleanup(share); + curl_global_cleanup(); + return 0; } diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index e2dcb44..81c5a5f 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -27,9 +27,7 @@ #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include "warnless.h" #include "memdebug.h" diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index b5ee2ce..bdc2e62 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -27,9 +27,7 @@ #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include "warnless.h" #include "memdebug.h" diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index a13653c..ff8a9b0 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -30,9 +30,7 @@ #include "test.h" -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include "testutil.h" #include "warnless.h" diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 9a87fbd..22ab9ec 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -27,9 +27,7 @@ #include "test.h" -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #ifdef HAVE_LOCALE_H # include <locale.h> /* for setlocale() */ diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index f55e5de..2f9242a 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -284,6 +284,7 @@ int test(char *URL) easy_setopt(curl, CURLOPT_USERPWD, libtest_arg3); easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub"); easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key"); + easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c index f25cc4d..0a406ce 100644 --- a/tests/libtest/lib591.c +++ b/tests/libtest/lib591.c @@ -23,9 +23,7 @@ /* lib591 is used for test cases 591, 592, 593 and 594 */ -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include <fcntl.h> diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index c852974..d7f38c4 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -21,9 +21,7 @@ ***************************************************************************/ #include "test.h" -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include "testutil.h" #include "warnless.h" diff --git a/tests/libtest/lib654.c b/tests/libtest/lib654.c new file mode 100644 index 0000000..45051a9 --- /dev/null +++ b/tests/libtest/lib654.c @@ -0,0 +1,174 @@ +/*************************************************************************** + * _ _ ____ _ + * 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 char data[]= +#ifdef CURL_DOES_CONVERSIONS + /* ASCII representation with escape sequences for non-ASCII platforms */ + "\x74\x68\x69\x73\x20\x69\x73\x20\x77\x68\x61\x74\x20\x77\x65\x20\x70" + "\x6f\x73\x74\x20\x74\x6f\x20\x74\x68\x65\x20\x73\x69\x6c\x6c\x79\x20" + "\x77\x65\x62\x20\x73\x65\x72\x76\x65\x72\x0a"; +#else + "this is what we post to the silly web server\n"; +#endif + +struct WriteThis { + char *readptr; + curl_off_t sizeleft; + int freecount; +}; + +static void free_callback(void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *) userp; + + pooh->freecount++; +} + +static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp) +{ + struct WriteThis *pooh = (struct WriteThis *)userp; + int eof = !*pooh->readptr; + + if(size*nmemb < 1) + return 0; + + eof = pooh->sizeleft <= 0; + if(!eof) + pooh->sizeleft--; + + if(!eof) { + *ptr = *pooh->readptr; /* copy one single byte */ + pooh->readptr++; /* advance pointer */ + return 1; /* we return 1 byte at a time! */ + } + + return 0; /* no more data left to deliver */ +} + +int test(char *URL) +{ + CURL *easy = NULL; + CURL *easy2 = NULL; + curl_mime *mime = NULL; + curl_mimepart *part; + struct curl_slist *hdrs = NULL; + CURLcode result; + int res = TEST_ERR_FAILURE; + struct WriteThis pooh; + + /* + * Check proper copy/release of mime post data bound to a duplicated + * easy handle. + */ + + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + easy = curl_easy_init(); + + /* First set the URL that is about to receive our POST. */ + test_setopt(easy, CURLOPT_URL, URL); + + /* get verbose debug output please */ + test_setopt(easy, CURLOPT_VERBOSE, 1L); + + /* include headers in the output */ + test_setopt(easy, CURLOPT_HEADER, 1L); + + /* Prepare the callback structure. */ + pooh.readptr = data; + pooh.sizeleft = (curl_off_t) strlen(data); + pooh.freecount = 0; + + /* Build the mime tree. */ + mime = curl_mime_init(easy); + part = curl_mime_addpart(mime); + curl_mime_data(part, "hello", CURL_ZERO_TERMINATED); + curl_mime_name(part, "greeting"); + curl_mime_type(part, "application/X-Greeting"); + curl_mime_encoder(part, "base64"); + hdrs = curl_slist_append(hdrs, "X-Test-Number: 654"); + curl_mime_headers(part, hdrs, TRUE); + part = curl_mime_addpart(mime); + curl_mime_filedata(part, "log/file654.txt"); + part = curl_mime_addpart(mime); + curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, free_callback, + &pooh); + + /* Bind mime data to its easy handle. */ + test_setopt(easy, CURLOPT_MIMEPOST, mime); + + /* Duplicate the handle. */ + easy2 = curl_easy_duphandle(easy); + if(!easy2) { + fprintf(stderr, "curl_easy_duphandle() failed\n"); + res = TEST_ERR_FAILURE; + goto test_cleanup; + } + + /* Now free the mime structure: it should unbind it from the first + easy handle. */ + curl_mime_free(mime); + mime = NULL; /* Already cleaned up. */ + + /* Perform on the first handle: should not send any data. */ + result = curl_easy_perform(easy); + if(result) { + fprintf(stderr, "curl_easy_perform(original) failed\n"); + res = (int) result; + goto test_cleanup; + } + + /* Perform on the second handle: if the bound mime structure has not been + duplicated properly, it should cause a valgrind error. */ + result = curl_easy_perform(easy2); + if(result) { + fprintf(stderr, "curl_easy_perform(duplicated) failed\n"); + res = (int) result; + goto test_cleanup; + } + + /* Free the duplicated handle: it should call free_callback again. + If the mime copy was bad or not automatically released, valgrind + will signal it. */ + curl_easy_cleanup(easy2); + easy2 = NULL; /* Already cleaned up. */ + + if(pooh.freecount != 2) { + fprintf(stderr, "free_callback() called %d times instead of 2\n", + pooh.freecount); + res = TEST_ERR_FAILURE; + goto test_cleanup; + } + +test_cleanup: + curl_easy_cleanup(easy); + curl_easy_cleanup(easy2); + curl_mime_free(mime); + curl_global_cleanup(); + return res; +} diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 0d527a7..59f94b6 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -21,9 +21,7 @@ ***************************************************************************/ #include "test.h" -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif #include <assert.h> #include "testutil.h" |