2011-03-10 18:48:02 +08:00
|
|
|
/***************************************************************************
|
2006-10-25 17:20:44 +08:00
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2020-03-30 16:55:31 +08:00
|
|
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2011-03-10 18:48:02 +08:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
2011-03-10 18:48:02 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2006-10-25 17:20:44 +08:00
|
|
|
|
2019-12-16 15:52:16 +08:00
|
|
|
/* !checksrc! disable ASSIGNWITHINCONDITION 14 */
|
2016-12-19 15:31:59 +08:00
|
|
|
|
2013-01-07 02:06:49 +08:00
|
|
|
/* Now include the curl_setup.h file from libcurl's private libdir (the source
|
2013-01-04 09:50:28 +08:00
|
|
|
version, but that might include "curl_config.h" from the build dir so we
|
|
|
|
need both of them in the include path), so that we get good in-depth
|
|
|
|
knowledge about the system we're building this on */
|
2007-02-22 10:51:54 +08:00
|
|
|
|
2010-02-02 20:39:10 +08:00
|
|
|
#define CURL_NO_OLDIES
|
|
|
|
|
2013-01-07 02:06:49 +08:00
|
|
|
#include "curl_setup.h"
|
2003-03-12 16:54:11 +08:00
|
|
|
|
2008-07-15 13:46:49 +08:00
|
|
|
#include <curl/curl.h>
|
2003-04-15 21:32:26 +08:00
|
|
|
|
2004-03-03 18:09:16 +08:00
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
/* since so many tests use select(), we can just as well include it here */
|
|
|
|
#include <sys/select.h>
|
2020-03-30 21:52:43 +08:00
|
|
|
#elif defined(HAVE_UNISTD_H)
|
|
|
|
#include <unistd.h>
|
2004-03-03 18:09:16 +08:00
|
|
|
#endif
|
|
|
|
|
2009-05-01 20:39:40 +08:00
|
|
|
#ifdef TPF
|
2013-01-04 09:50:28 +08:00
|
|
|
# include "select.h"
|
2009-05-01 20:39:40 +08:00
|
|
|
#endif
|
|
|
|
|
2016-04-01 16:14:06 +08:00
|
|
|
#include "curl_printf.h"
|
2015-03-02 20:58:27 +08:00
|
|
|
|
2020-03-30 16:55:31 +08:00
|
|
|
#define test_setopt(A,B,C) \
|
|
|
|
if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \
|
|
|
|
goto test_cleanup
|
2010-02-06 02:07:19 +08:00
|
|
|
|
2020-03-30 16:55:31 +08:00
|
|
|
#define test_multi_setopt(A,B,C) \
|
|
|
|
if((res = curl_multi_setopt((A), (B), (C))) != CURLE_OK) \
|
|
|
|
goto test_cleanup
|
2011-03-08 07:19:49 +08:00
|
|
|
|
2007-10-03 00:05:28 +08:00
|
|
|
extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */
|
|
|
|
extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */
|
2006-09-11 03:01:04 +08:00
|
|
|
|
2007-07-16 04:59:43 +08:00
|
|
|
/* argc and argv as passed in to the main() function */
|
|
|
|
extern int test_argc;
|
|
|
|
extern char **test_argv;
|
|
|
|
|
2011-10-21 22:26:18 +08:00
|
|
|
extern struct timeval tv_test_start; /* for test timing */
|
|
|
|
|
|
|
|
extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
|
|
|
|
struct timeval *tv);
|
2008-09-19 00:21:09 +08:00
|
|
|
|
2014-05-09 22:48:11 +08:00
|
|
|
extern void wait_ms(int ms); /* wait this many milliseconds */
|
|
|
|
|
2008-09-19 00:21:09 +08:00
|
|
|
extern int test(char *URL); /* the actual test function provided by each
|
|
|
|
individual libXXX.c file */
|
2006-09-11 03:01:04 +08:00
|
|
|
|
2017-05-06 03:29:50 +08:00
|
|
|
extern char *hexdump(const unsigned char *buffer, size_t len);
|
2015-02-04 03:59:54 +08:00
|
|
|
|
2011-05-26 02:22:46 +08:00
|
|
|
#ifdef UNITTESTS
|
|
|
|
extern int unitfail;
|
|
|
|
#endif
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** TEST_ERR_* values must be greater than CURL_LAST CURLcode in order
|
|
|
|
** to avoid confusion with any CURLcode or CURLMcode. These TEST_ERR_*
|
|
|
|
** codes are returned to signal test specific situations and should
|
|
|
|
** not get mixed with CURLcode or CURLMcode values.
|
|
|
|
**
|
|
|
|
** For portability reasons TEST_ERR_* values should be less than 127.
|
|
|
|
*/
|
|
|
|
|
2020-09-07 16:52:48 +08:00
|
|
|
#define TEST_ERR_MAJOR_BAD (CURLcode) 126
|
|
|
|
#define TEST_ERR_RUNS_FOREVER (CURLcode) 125
|
|
|
|
#define TEST_ERR_EASY_INIT (CURLcode) 124
|
|
|
|
#define TEST_ERR_MULTI (CURLcode) 123
|
|
|
|
#define TEST_ERR_NUM_HANDLES (CURLcode) 122
|
|
|
|
#define TEST_ERR_SELECT (CURLcode) 121
|
|
|
|
#define TEST_ERR_SUCCESS (CURLcode) 120
|
|
|
|
#define TEST_ERR_FAILURE (CURLcode) 119
|
|
|
|
#define TEST_ERR_USAGE (CURLcode) 118
|
|
|
|
#define TEST_ERR_FOPEN (CURLcode) 117
|
|
|
|
#define TEST_ERR_FSTAT (CURLcode) 116
|
|
|
|
#define TEST_ERR_BAD_TIMEOUT (CURLcode) 115
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Macros for test source code readability/maintainability.
|
|
|
|
**
|
|
|
|
** All of the following macros require that an int data type 'res' variable
|
|
|
|
** exists in scope where macro is used, and that it has been initialized to
|
|
|
|
** zero before the macro is used.
|
|
|
|
**
|
|
|
|
** exe_* and chk_* macros are helper macros not intended to be used from
|
|
|
|
** outside of this header file. Arguments 'Y' and 'Z' of these represent
|
|
|
|
** source code file and line number, while Arguments 'A', 'B', etc, are
|
|
|
|
** the arguments used to actually call a libcurl function.
|
|
|
|
**
|
|
|
|
** All easy_* and multi_* macros call a libcurl function and evaluate if
|
|
|
|
** the function has succeeded or failed. When the function succeeds 'res'
|
|
|
|
** variable is not set nor cleared and program continues normal flow. On
|
|
|
|
** the other hand if function fails 'res' variable is set and a jump to
|
|
|
|
** label 'test_cleanup' is performed.
|
|
|
|
**
|
|
|
|
** Every easy_* and multi_* macros have a res_easy_* and res_multi_* macro
|
2016-09-04 05:12:22 +08:00
|
|
|
** counterpart that operates in the same way with the exception that no
|
2011-10-21 22:26:18 +08:00
|
|
|
** jump takes place in case of failure. res_easy_* and res_multi_* macros
|
|
|
|
** should be immediately followed by checking if 'res' variable has been
|
|
|
|
** set.
|
|
|
|
**
|
|
|
|
** 'res' variable when set will hold a CURLcode, CURLMcode, or any of the
|
|
|
|
** TEST_ERR_* values defined above. It is advisable to return this value
|
|
|
|
** as test result.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define exe_easy_init(A,Y,Z) do { \
|
|
|
|
if(((A) = curl_easy_init()) == NULL) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_easy_init() failed\n", (Y), (Z)); \
|
|
|
|
res = TEST_ERR_EASY_INIT; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define res_easy_init(A) \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_easy_init((A), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define chk_easy_init(A,Y,Z) do { \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_easy_init((A), (Y), (Z)); \
|
2011-10-21 22:26:18 +08:00
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define easy_init(A) \
|
2016-04-03 17:57:34 +08:00
|
|
|
chk_easy_init((A), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define exe_multi_init(A,Y,Z) do { \
|
|
|
|
if(((A) = curl_multi_init()) == NULL) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_init() failed\n", (Y), (Z)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2011-10-21 22:26:18 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define res_multi_init(A) \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_multi_init((A), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define chk_multi_init(A,Y,Z) do { \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_multi_init((A), (Y), (Z)); \
|
2011-10-21 22:26:18 +08:00
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define multi_init(A) \
|
2016-04-03 17:57:34 +08:00
|
|
|
chk_multi_init((A), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define exe_easy_setopt(A,B,C,Y,Z) do { \
|
|
|
|
CURLcode ec; \
|
|
|
|
if((ec = curl_easy_setopt((A), (B), (C))) != CURLE_OK) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_easy_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = ec; \
|
2016-04-03 17:57:34 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define res_easy_setopt(A, B, C) \
|
|
|
|
exe_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_easy_setopt(A, B, C, Y, Z) do { \
|
|
|
|
exe_easy_setopt((A), (B), (C), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define easy_setopt(A, B, C) \
|
|
|
|
chk_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define exe_multi_setopt(A, B, C, Y, Z) do { \
|
|
|
|
CURLMcode ec; \
|
|
|
|
if((ec = curl_multi_setopt((A), (B), (C))) != CURLM_OK) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2016-04-03 17:57:34 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define res_multi_setopt(A,B,C) \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_multi_setopt(A,B,C,Y,Z) do { \
|
|
|
|
exe_multi_setopt((A), (B), (C), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define multi_setopt(A,B,C) \
|
2016-04-03 17:57:34 +08:00
|
|
|
chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define exe_multi_add_handle(A,B,Y,Z) do { \
|
|
|
|
CURLMcode ec; \
|
2016-04-03 17:57:34 +08:00
|
|
|
if((ec = curl_multi_add_handle((A), (B))) != CURLM_OK) { \
|
2011-10-21 22:26:18 +08:00
|
|
|
fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2011-10-21 22:26:18 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define res_multi_add_handle(A, B) \
|
|
|
|
exe_multi_add_handle((A), (B), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_multi_add_handle(A, B, Y, Z) do { \
|
|
|
|
exe_multi_add_handle((A), (B), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define multi_add_handle(A, B) \
|
|
|
|
chk_multi_add_handle((A), (B), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2011-12-07 06:41:24 +08:00
|
|
|
#define exe_multi_remove_handle(A,B,Y,Z) do { \
|
|
|
|
CURLMcode ec; \
|
2016-04-03 17:57:34 +08:00
|
|
|
if((ec = curl_multi_remove_handle((A), (B))) != CURLM_OK) { \
|
2011-12-07 06:41:24 +08:00
|
|
|
fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2011-12-07 06:41:24 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-12-07 06:41:24 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define res_multi_remove_handle(A, B) \
|
|
|
|
exe_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
|
2011-12-07 06:41:24 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_multi_remove_handle(A, B, Y, Z) do { \
|
|
|
|
exe_multi_remove_handle((A), (B), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-12-07 06:41:24 +08:00
|
|
|
|
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define multi_remove_handle(A, B) \
|
|
|
|
chk_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
|
2011-12-07 06:41:24 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2011-10-21 22:26:18 +08:00
|
|
|
#define exe_multi_perform(A,B,Y,Z) do { \
|
|
|
|
CURLMcode ec; \
|
2016-04-03 17:57:34 +08:00
|
|
|
if((ec = curl_multi_perform((A), (B))) != CURLM_OK) { \
|
2011-10-21 22:26:18 +08:00
|
|
|
fprintf(stderr, "%s:%d curl_multi_perform() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2011-10-21 22:26:18 +08:00
|
|
|
} \
|
|
|
|
else if(*((B)) < 0) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_perform() succeeded, " \
|
|
|
|
"but returned invalid running_handles value (%d)\n", \
|
|
|
|
(Y), (Z), (int)*((B))); \
|
|
|
|
res = TEST_ERR_NUM_HANDLES; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define res_multi_perform(A, B) \
|
|
|
|
exe_multi_perform((A), (B), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_multi_perform(A, B, Y, Z) do { \
|
|
|
|
exe_multi_perform((A), (B), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define multi_perform(A,B) \
|
2016-04-03 17:57:34 +08:00
|
|
|
chk_multi_perform((A), (B), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define exe_multi_fdset(A, B, C, D, E, Y, Z) do { \
|
|
|
|
CURLMcode ec; \
|
|
|
|
if((ec = curl_multi_fdset((A), (B), (C), (D), (E))) != CURLM_OK) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2016-04-03 17:57:34 +08:00
|
|
|
} \
|
|
|
|
else if(*((E)) < -1) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \
|
|
|
|
"but returned invalid max_fd value (%d)\n", \
|
|
|
|
(Y), (Z), (int)*((E))); \
|
|
|
|
res = TEST_ERR_NUM_HANDLES; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define res_multi_fdset(A, B, C, D, E) \
|
|
|
|
exe_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_multi_fdset(A, B, C, D, E, Y, Z) do { \
|
|
|
|
exe_multi_fdset((A), (B), (C), (D), (E), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define multi_fdset(A, B, C, D, E) \
|
|
|
|
chk_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2011-10-27 00:46:32 +08:00
|
|
|
#define exe_multi_timeout(A,B,Y,Z) do { \
|
|
|
|
CURLMcode ec; \
|
2016-04-03 17:57:34 +08:00
|
|
|
if((ec = curl_multi_timeout((A), (B))) != CURLM_OK) { \
|
2011-10-27 00:46:32 +08:00
|
|
|
fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_BAD_TIMEOUT; \
|
2011-10-27 00:46:32 +08:00
|
|
|
} \
|
|
|
|
else if(*((B)) < -1L) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_timeout() succeeded, " \
|
|
|
|
"but returned invalid timeout value (%ld)\n", \
|
|
|
|
(Y), (Z), (long)*((B))); \
|
|
|
|
res = TEST_ERR_BAD_TIMEOUT; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define res_multi_timeout(A, B) \
|
|
|
|
exe_multi_timeout((A), (B), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_multi_timeout(A, B, Y, Z) do { \
|
|
|
|
exe_multi_timeout((A), (B), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define multi_timeout(A, B) \
|
|
|
|
chk_multi_timeout((A), (B), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2019-11-17 22:12:15 +08:00
|
|
|
#define exe_multi_poll(A,B,C,D,E,Y,Z) do { \
|
|
|
|
CURLMcode ec; \
|
|
|
|
if((ec = curl_multi_poll((A), (B), (C), (D), (E))) != CURLM_OK) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_poll() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2019-11-17 22:12:15 +08:00
|
|
|
} \
|
|
|
|
else if(*((E)) < 0) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_poll() succeeded, " \
|
|
|
|
"but returned invalid numfds value (%d)\n", \
|
|
|
|
(Y), (Z), (int)*((E))); \
|
|
|
|
res = TEST_ERR_NUM_HANDLES; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2019-11-17 22:12:15 +08:00
|
|
|
|
|
|
|
#define res_multi_poll(A, B, C, D, E) \
|
|
|
|
exe_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
|
|
|
|
|
|
|
#define chk_multi_poll(A, B, C, D, E, Y, Z) do { \
|
|
|
|
exe_multi_poll((A), (B), (C), (D), (E), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2019-11-17 22:12:15 +08:00
|
|
|
|
|
|
|
#define multi_poll(A, B, C, D, E) \
|
|
|
|
chk_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define exe_multi_wakeup(A,Y,Z) do { \
|
|
|
|
CURLMcode ec; \
|
|
|
|
if((ec = curl_multi_wakeup((A))) != CURLM_OK) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_multi_wakeup() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = TEST_ERR_MULTI; \
|
2019-11-17 22:12:15 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2019-11-17 22:12:15 +08:00
|
|
|
|
|
|
|
#define res_multi_wakeup(A) \
|
|
|
|
exe_multi_wakeup((A), (__FILE__), (__LINE__))
|
|
|
|
|
|
|
|
#define chk_multi_wakeup(A, Y, Z) do { \
|
|
|
|
exe_multi_wakeup((A), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2019-11-17 22:12:15 +08:00
|
|
|
|
|
|
|
#define multi_wakeup(A) \
|
|
|
|
chk_multi_wakeup((A), (__FILE__), (__LINE__))
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define exe_select_test(A, B, C, D, E, Y, Z) do { \
|
|
|
|
int ec; \
|
2016-04-04 04:51:47 +08:00
|
|
|
if(select_wrapper((A), (B), (C), (D), (E)) == -1) { \
|
2016-04-03 17:57:34 +08:00
|
|
|
ec = SOCKERRNO; \
|
|
|
|
fprintf(stderr, "%s:%d select() failed, with " \
|
|
|
|
"errno %d (%s)\n", \
|
|
|
|
(Y), (Z), ec, strerror(ec)); \
|
|
|
|
res = TEST_ERR_SELECT; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2016-04-03 17:57:34 +08:00
|
|
|
|
|
|
|
#define res_select_test(A, B, C, D, E) \
|
|
|
|
exe_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
|
|
|
|
|
|
|
#define chk_select_test(A, B, C, D, E, Y, Z) do { \
|
|
|
|
exe_select_test((A), (B), (C), (D), (E), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2016-04-03 17:57:34 +08:00
|
|
|
|
|
|
|
#define select_test(A, B, C, D, E) \
|
|
|
|
chk_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define start_test_timing() do { \
|
|
|
|
tv_test_start = tutil_tvnow(); \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define exe_test_timedout(Y,Z) do { \
|
|
|
|
if(tutil_tvdiff(tutil_tvnow(), tv_test_start) > TEST_HANG_TIMEOUT) { \
|
|
|
|
fprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
|
|
|
|
"that it would have run forever.\n", (Y), (Z)); \
|
|
|
|
res = TEST_ERR_RUNS_FOREVER; \
|
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define res_test_timedout() \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_test_timedout((__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_test_timedout(Y, Z) do { \
|
|
|
|
exe_test_timedout(Y, Z); \
|
|
|
|
if(res) \
|
|
|
|
goto test_cleanup; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define abort_on_test_timeout() \
|
2016-04-03 17:57:34 +08:00
|
|
|
chk_test_timedout((__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define exe_global_init(A,Y,Z) do { \
|
|
|
|
CURLcode ec; \
|
|
|
|
if((ec = curl_global_init((A))) != CURLE_OK) { \
|
|
|
|
fprintf(stderr, "%s:%d curl_global_init() failed, " \
|
|
|
|
"with code %d (%s)\n", \
|
|
|
|
(Y), (Z), (int)ec, curl_easy_strerror(ec)); \
|
2020-09-07 16:52:48 +08:00
|
|
|
res = ec; \
|
2011-10-21 22:26:18 +08:00
|
|
|
} \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
#define res_global_init(A) \
|
2016-04-03 17:57:34 +08:00
|
|
|
exe_global_init((A), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
2016-04-03 17:57:34 +08:00
|
|
|
#define chk_global_init(A, Y, Z) do { \
|
|
|
|
exe_global_init((A), (Y), (Z)); \
|
|
|
|
if(res) \
|
|
|
|
return res; \
|
2019-11-30 16:29:36 +08:00
|
|
|
} while(0)
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* global_init() is different than other macros. In case of
|
|
|
|
failure it 'return's instead of going to 'test_cleanup'. */
|
|
|
|
|
|
|
|
#define global_init(A) \
|
2016-04-03 17:57:34 +08:00
|
|
|
chk_global_init((A), (__FILE__), (__LINE__))
|
2011-10-21 22:26:18 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------- */
|