mirror of
https://github.com/curl/curl.git
synced 2025-03-07 15:27:17 +08:00
Add support for single-block binaries that contain all libtests and unit tests respectively. Enable with: - autotools: `--enable-test-bundles` - cmake: `-DCURL_TEST_BUNDLES=ON` (They are compatible with `--enable-unity` and `-DCMAKE_UNITY_BUILD=ON` options, for further speed-up.) Makes libtests and unit tests build _fast_, needing little disk space even in static mode. Similar to CMake unity mode, but with a custom script, also supporting autotools builds. The price is having to deal with symbols/macros colliding between `lib*.c` and `unit*.c` sources. Maybe with naming conventions or other solutions this can be improved gradually and reduce the need for manual intervention by `mk-bundle.mk`. I've included a script that does the bulk of detecting name collisions. Also: - CI: enable test bundles. - CI: build tests in more jobs. - lib2305: fix FILE handle leak. - unit1661: fix memleak found by torture test by releasing the `bufref` structure in `unit_stop()` that was allocated in `unit_setup()`. ``` test 1661...[bufref unit tests] Leak detected: memory still allocated: 13 bytes allocated by /home/runner/work/curl/curl/tests/unit/unit1661.c:70 1661: torture FAILED: function number 1 in test. ``` Ref: https://github.com/curl/curl/actions/runs/10967279334/job/30456745290?pr=14772#step:8:41 Similar test suite builds with autotools default and cmake+bundle+unity: - GHA/Linux: 33s vs 7s https://github.com/curl/curl/actions/runs/10705668823/job/29681617374 - GHA/macOS 34s vs 2s https://github.com/curl/curl/actions/runs/10705668813/job/29681632885 - GHA/FreeBSD: 15m25 vs 6m21 (full workflow time, ~qemu) https://github.com/curl/curl/actions/runs/10705668811/job/29681607915 - GHA/Cygwin: 9m52 vs 32s https://github.com/curl/curl/actions/runs/10705668809/job/29681609965 - GHA/MSYS2: 3m52 vs 14s https://github.com/curl/curl/actions/runs/10705668808/job/29681624295 - GHA/mingw-w64: 5m45 vs 30s https://github.com/curl/curl/actions/runs/10705668808/job/29681628787 Autotools test suite builds compared between master -> `--enable-test-bundles`: - GHA/Linux: 33s -> 9s (run tests: 22m23 -> 20m44) https://github.com/curl/curl/actions/runs/10710030193/job/29695932185 https://github.com/curl/curl/actions/runs/10967831456/job/30458220344 - GHA/macOS: 25s -> 4s (run tests: 2m58 -> 2m24) https://github.com/curl/curl/actions/runs/10710030195/job/29695938444 https://github.com/curl/curl/actions/runs/10967831452/job/30458225762 - GHA/non-native (FreeBSD): 4m8 -> 3m12 (full workflow time, ~qemu) https://github.com/curl/curl/actions/runs/10710030198/job/29695928401 https://github.com/curl/curl/actions/runs/10967831458/job/30458212692 - GHA/Cygwin: 9m25 -> 1m9 (run tests: 9m19 -> 3m28) https://github.com/curl/curl/actions/runs/10710030212/job/29695928213 https://github.com/curl/curl/actions/runs/10967831453/job/30458213268 - GHA/MSYS2: 3m54 -> 32s (run tests: 6m3 -> 3m59) https://github.com/curl/curl/actions/runs/10710030190/job/29704850591 https://github.com/curl/curl/actions/runs/10967831449/job/30459280005 - GHA/mingw-w64: 5m42 -> 1m5 (run tests: 7m41 -> 5m36) https://github.com/curl/curl/actions/runs/10710030190/job/29704852058 https://github.com/curl/curl/actions/runs/10967831449/job/30459280862 - Azure MSYS2 mingw64 openssl: 38m55 -> 11m58 https://dev.azure.com/daniel0244/curl/_build/results?buildId=25546&view=logs&j=b58b8c59-0f61-52e9-0f9e-fad562a1e77f&t=0f9230a7-3b10-53ca-9938-700ece377c5e https://dev.azure.com/daniel0244/curl/_build/results?buildId=25547&view=logs&jobId=39473db1-3945-55d5-deb5-c218fad88dce&j=b58b8c59-0f61-52e9-0f9e-fad562a1e77f&t=0f9230a7-3b10-53ca-9938-700ece377c5e - Azure Ubuntu default: 2m15 -> 55s (all build) https://dev.azure.com/daniel0244/curl/_build/results?buildId=25546&view=logs&j=9d58b9ac-e1e6-53b6-f83a-1f9f1d912522&t=a6b38d83-e7cf-5a9b-c762-a178412717b7 https://dev.azure.com/daniel0244/curl/_build/results?buildId=25547&view=logs&jobId=39473db1-3945-55d5-deb5-c218fad88dce&j=9d58b9ac-e1e6-53b6-f83a-1f9f1d912522&t=a6b38d83-e7cf-5a9b-c762-a178412717b7 Cmake test suite builds compared between master -> `-DCURL_TEST_BUNDLES=ON` + unity: - GHA/Linux: 29s -> 7s (run tests: 4m50 -> 4m57, 20m43 -> 20m45) https://github.com/curl/curl/actions/runs/10710030193/job/29695941814 https://github.com/curl/curl/actions/runs/10705668823/job/29681622201 - GHA/Linux old: 44s -> 13s (bundle+no unity) (run tests: 5m5 -> 5m6) https://github.com/curl/curl/actions/runs/10718264094/job/29719794727 https://github.com/curl/curl/actions/runs/10718653175/job/29721009613 - GHA/macOS: 32s -> 2s (run tests: 2m43 -> 2m40) https://github.com/curl/curl/actions/runs/10710030195/job/29695931956 https://github.com/curl/curl/actions/runs/10705668813/job/29681638937 - GHA/non-native (*BSD): inconclusive (full workflow time, ~qemu) https://github.com/curl/curl/actions/runs/10710030198 https://github.com/curl/curl/actions/runs/10705668811 - GHA/Cygwin: 3m9 -> 32s https://github.com/curl/curl/actions/runs/10710030212/job/29695929075 https://github.com/curl/curl/actions/runs/10705668809/job/29681609965 - GHA/MSYS2: 2m24 -> 14s https://github.com/curl/curl/actions/runs/10710030190/job/29704850996 https://github.com/curl/curl/actions/runs/10705668808/job/29681624295 - GHA/mingw-w64: 3m56 -> 30s (run tests: 4m2 -> 3m52) https://github.com/curl/curl/actions/runs/10710030190/job/29704852219 https://github.com/curl/curl/actions/runs/10705668808/job/29681631393 - GHA/mingw-w64-old: 7m19 -> 1m44 (run tests: 3m30 -> 2m53) https://github.com/curl/curl/actions/runs/10710030190/job/29704849763 https://github.com/curl/curl/actions/runs/10705668808/job/29681622329 - GHA/MSVC: 3m22 -> 13s (run tests: 9m43 -> 4m22) https://github.com/curl/curl/actions/runs/10710030190/job/29704850411 https://github.com/curl/curl/actions/runs/10705668808/job/29681623313 - AppVeyor CI MSVC 2008: 4m3 -> 45s (full build) - AppVeyor CI MSVC 2010: 2m56 -> 1m8 (full build) - AppVeyor CI MSVC 2022: 10m19 -> 2m23 (full build) https://ci.appveyor.com/project/curlorg/curl/builds/50538455 https://ci.appveyor.com/project/curlorg/curl/builds/50536558 - AppVeyor CI total build time: 10m30 (master) -> 6m48 (unity) -> 4m5 (bundle) -> 3m24 (bundle+unity) -> 5m7 (bundle+unity+all jobs building tests) Closes #14772
523 lines
21 KiB
C
523 lines
21 KiB
C
#ifndef HEADER_CURL_TEST_H
|
|
#define HEADER_CURL_TEST_H
|
|
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) 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.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.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
|
|
/* Now include the curl_setup.h file from libcurl's private libdir (the source
|
|
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 */
|
|
|
|
#define CURL_NO_OLDIES
|
|
|
|
#include "curl_setup.h"
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
/* since so many tests use select(), we can just as well include it here */
|
|
#include <sys/select.h>
|
|
#elif defined(HAVE_UNISTD_H)
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include "curl_printf.h"
|
|
|
|
#ifdef _WIN32
|
|
#define sleep(sec) Sleep ((sec)*1000)
|
|
#endif
|
|
|
|
#define test_setopt(A,B,C) \
|
|
if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \
|
|
goto test_cleanup
|
|
|
|
#define test_multi_setopt(A,B,C) \
|
|
if((res = curl_multi_setopt((A), (B), (C))) != CURLE_OK) \
|
|
goto test_cleanup
|
|
|
|
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 */
|
|
|
|
/* argc and argv as passed in to the main() function */
|
|
extern int test_argc;
|
|
extern char **test_argv;
|
|
|
|
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);
|
|
|
|
extern void wait_ms(int ms); /* wait this many milliseconds */
|
|
|
|
#ifndef CURLTESTS_BUNDLED_TEST_H
|
|
extern CURLcode test(char *URL); /* the actual test function provided by each
|
|
individual libXXX.c file */
|
|
#endif
|
|
|
|
extern char *hexdump(const unsigned char *buffer, size_t len);
|
|
|
|
extern int unitfail;
|
|
|
|
/*
|
|
** 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.
|
|
*/
|
|
|
|
#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
|
|
|
|
/*
|
|
** 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
|
|
** counterpart that operates in the same way with the exception that no
|
|
** 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; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_easy_init(A) \
|
|
exe_easy_init((A), (__FILE__), (__LINE__))
|
|
|
|
#define chk_easy_init(A,Y,Z) do { \
|
|
exe_easy_init((A), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define easy_init(A) \
|
|
chk_easy_init((A), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#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)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_init(A) \
|
|
exe_multi_init((A), (__FILE__), (__LINE__))
|
|
|
|
#define chk_multi_init(A,Y,Z) do { \
|
|
exe_multi_init((A), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define multi_init(A) \
|
|
chk_multi_init((A), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#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)); \
|
|
res = ec; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_easy_setopt(A, B, C) \
|
|
exe_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
|
|
|
#define chk_easy_setopt(A, B, C, Y, Z) do { \
|
|
exe_easy_setopt((A), (B), (C), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define easy_setopt(A, B, C) \
|
|
chk_easy_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#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)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_setopt(A,B,C) \
|
|
exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
|
|
|
#define chk_multi_setopt(A,B,C,Y,Z) do { \
|
|
exe_multi_setopt((A), (B), (C), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define multi_setopt(A,B,C) \
|
|
chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define exe_multi_add_handle(A,B,Y,Z) do { \
|
|
CURLMcode ec; \
|
|
if((ec = curl_multi_add_handle((A), (B))) != CURLM_OK) { \
|
|
fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \
|
|
"with code %d (%s)\n", \
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_add_handle(A, B) \
|
|
exe_multi_add_handle((A), (B), (__FILE__), (__LINE__))
|
|
|
|
#define chk_multi_add_handle(A, B, Y, Z) do { \
|
|
exe_multi_add_handle((A), (B), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define multi_add_handle(A, B) \
|
|
chk_multi_add_handle((A), (B), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define exe_multi_remove_handle(A,B,Y,Z) do { \
|
|
CURLMcode ec; \
|
|
if((ec = curl_multi_remove_handle((A), (B))) != CURLM_OK) { \
|
|
fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \
|
|
"with code %d (%s)\n", \
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_remove_handle(A, B) \
|
|
exe_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
|
|
|
|
#define chk_multi_remove_handle(A, B, Y, Z) do { \
|
|
exe_multi_remove_handle((A), (B), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
|
|
#define multi_remove_handle(A, B) \
|
|
chk_multi_remove_handle((A), (B), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define exe_multi_perform(A,B,Y,Z) do { \
|
|
CURLMcode ec; \
|
|
if((ec = curl_multi_perform((A), (B))) != CURLM_OK) { \
|
|
fprintf(stderr, "%s:%d curl_multi_perform() failed, " \
|
|
"with code %d (%s)\n", \
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
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; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_perform(A, B) \
|
|
exe_multi_perform((A), (B), (__FILE__), (__LINE__))
|
|
|
|
#define chk_multi_perform(A, B, Y, Z) do { \
|
|
exe_multi_perform((A), (B), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define multi_perform(A,B) \
|
|
chk_multi_perform((A), (B), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#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)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
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; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_fdset(A, B, C, D, E) \
|
|
exe_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
|
|
|
#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; \
|
|
} while(0)
|
|
|
|
#define multi_fdset(A, B, C, D, E) \
|
|
chk_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define exe_multi_timeout(A,B,Y,Z) do { \
|
|
CURLMcode ec; \
|
|
if((ec = curl_multi_timeout((A), (B))) != CURLM_OK) { \
|
|
fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \
|
|
"with code %d (%s)\n", \
|
|
(Y), (Z), (int)ec, curl_multi_strerror(ec)); \
|
|
res = TEST_ERR_BAD_TIMEOUT; \
|
|
} \
|
|
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; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_multi_timeout(A, B) \
|
|
exe_multi_timeout((A), (B), (__FILE__), (__LINE__))
|
|
|
|
#define chk_multi_timeout(A, B, Y, Z) do { \
|
|
exe_multi_timeout((A), (B), (Y), (Z)); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define multi_timeout(A, B) \
|
|
chk_multi_timeout((A), (B), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#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)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
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; \
|
|
} \
|
|
} while(0)
|
|
|
|
#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; \
|
|
} while(0)
|
|
|
|
#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)); \
|
|
res = TEST_ERR_MULTI; \
|
|
} \
|
|
} while(0)
|
|
|
|
#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; \
|
|
} while(0)
|
|
|
|
#define multi_wakeup(A) \
|
|
chk_multi_wakeup((A), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define exe_select_test(A, B, C, D, E, Y, Z) do { \
|
|
int ec; \
|
|
if(select_wrapper((A), (B), (C), (D), (E)) == -1) { \
|
|
ec = SOCKERRNO; \
|
|
fprintf(stderr, "%s:%d select() failed, with " \
|
|
"errno %d (%s)\n", \
|
|
(Y), (Z), ec, strerror(ec)); \
|
|
res = TEST_ERR_SELECT; \
|
|
} \
|
|
} while(0)
|
|
|
|
#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; \
|
|
} while(0)
|
|
|
|
#define select_test(A, B, C, D, E) \
|
|
chk_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#define start_test_timing() do { \
|
|
tv_test_start = tutil_tvnow(); \
|
|
} while(0)
|
|
|
|
#define exe_test_timedout(Y,Z) do { \
|
|
long timediff = tutil_tvdiff(tutil_tvnow(), tv_test_start); \
|
|
if(timediff > (TEST_HANG_TIMEOUT)) { \
|
|
fprintf(stderr, "%s:%d ABORTING TEST, since it seems " \
|
|
"that it would have run forever (%ld ms > %ld ms)\n", \
|
|
(Y), (Z), timediff, (long) (TEST_HANG_TIMEOUT)); \
|
|
res = TEST_ERR_RUNS_FOREVER; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_test_timedout() \
|
|
exe_test_timedout((__FILE__), (__LINE__))
|
|
|
|
#define chk_test_timedout(Y, Z) do { \
|
|
exe_test_timedout(Y, Z); \
|
|
if(res) \
|
|
goto test_cleanup; \
|
|
} while(0)
|
|
|
|
#define abort_on_test_timeout() \
|
|
chk_test_timedout((__FILE__), (__LINE__))
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#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)); \
|
|
res = ec; \
|
|
} \
|
|
} while(0)
|
|
|
|
#define res_global_init(A) \
|
|
exe_global_init((A), (__FILE__), (__LINE__))
|
|
|
|
#define chk_global_init(A, Y, Z) do { \
|
|
exe_global_init((A), (Y), (Z)); \
|
|
if(res) \
|
|
return res; \
|
|
} while(0)
|
|
|
|
/* global_init() is different than other macros. In case of
|
|
failure it 'return's instead of going to 'test_cleanup'. */
|
|
|
|
#define global_init(A) \
|
|
chk_global_init((A), (__FILE__), (__LINE__))
|
|
|
|
#ifndef CURLTESTS_BUNDLED_TEST_H
|
|
#define NO_SUPPORT_BUILT_IN \
|
|
CURLcode test(char *URL) \
|
|
{ \
|
|
(void)URL; \
|
|
fprintf(stderr, "Missing support\n"); \
|
|
return (CURLcode)1; \
|
|
}
|
|
#endif
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
#endif /* HEADER_CURL_TEST_H */
|
|
|
|
#ifdef CURLTESTS_BUNDLED_TEST_H
|
|
extern CURLcode test(char *URL); /* the actual test function provided by each
|
|
individual libXXX.c file */
|
|
|
|
#undef NO_SUPPORT_BUILT_IN
|
|
#define NO_SUPPORT_BUILT_IN \
|
|
CURLcode test(char *URL) \
|
|
{ \
|
|
(void)URL; \
|
|
fprintf(stderr, "Missing support\n"); \
|
|
return (CURLcode)1; \
|
|
}
|
|
#endif
|