mirror of https://github.com/moparisthebest/curl
Some tests were using functions curlx_tvnow and curlx_tvdiff which are not
part of the official libcurl API http://curl.haxx.se/lxr/source/lib/README.curlx The documented way of using them would be to use timeval.c as a source code file. The above described method works very well when statically linking libcurl and apps, test programs, but has several drawbacks when you build a true shared libcurl (i.e. Name space clash at linkage stage as functions are defined more than once. Windows makefiles are not capable of handling this system of source-level sharing) So... Now testutil.h and testutil.c define and implement tutil_tvnow and tutil_tvdiff which replace curlx_tvnow and curlx_tvdiff for the libtest programs. Doing this we avoid the above described problems, and the code in the testsuite does not impose the need to keep those functions public in libcurl even when not part of the API.
This commit is contained in:
parent
9f62ff5df6
commit
2f4fe0175b
|
@ -37,9 +37,8 @@ LIBDIR = $(top_builddir)/lib
|
|||
|
||||
EXTRA_DIST = test307.pl
|
||||
|
||||
# *NOTICE* that some test cases use curlx_* functions that are not in the API
|
||||
# but must be provided by source
|
||||
TIMEVAL=$(top_srcdir)/lib/timeval.c
|
||||
# Source code file used only in some libcurl test programs
|
||||
TESTUTIL = testutil.c
|
||||
|
||||
# these files are used in every single test program below
|
||||
SUPPORTFILES = first.c test.h
|
||||
|
@ -60,13 +59,13 @@ lib500_DEPENDENCIES = $(DEPENDENCIES)
|
|||
lib501_SOURCES = lib501.c $(SUPPORTFILES)
|
||||
lib501_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib502_SOURCES = lib502.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib502_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib503_SOURCES = lib503.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib503_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib504_SOURCES = lib504.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib504_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib505_SOURCES = lib505.c $(SUPPORTFILES)
|
||||
|
@ -75,13 +74,13 @@ lib505_DEPENDENCIES = $(DEPENDENCIES)
|
|||
lib506_SOURCES = lib506.c $(SUPPORTFILES)
|
||||
lib506_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib507_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib508_SOURCES = lib508.c $(SUPPORTFILES)
|
||||
lib508_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib509_SOURCES = lib509.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib509_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib510_SOURCES = lib510.c $(SUPPORTFILES)
|
||||
|
@ -126,33 +125,33 @@ lib523_DEPENDENCIES = $(DEPENDENCIES)
|
|||
lib524_SOURCES = lib524.c $(SUPPORTFILES)
|
||||
lib524_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib525_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib525_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib526_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib526_CFLAGS = -DLIB526
|
||||
lib526_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib527_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib527_CFLAGS = -DLIB527
|
||||
lib527_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib529_SOURCES = lib525.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib529_CFLAGS = -DLIB529
|
||||
lib529_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib530_SOURCES = lib530.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib530_CFLAGS = -DLIB530
|
||||
lib530_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib532_SOURCES = lib526.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib532_CFLAGS = -DLIB532
|
||||
lib532_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib533_SOURCES = lib533.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib533_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TIMEVAL)
|
||||
lib536_SOURCES = lib536.c $(SUPPORTFILES) $(TESTUTIL)
|
||||
lib536_DEPENDENCIES = $(DEPENDENCIES)
|
||||
|
||||
lib537_SOURCES = lib537.c $(SUPPORTFILES)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "test.h"
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 30 * 1000
|
||||
|
||||
|
@ -57,11 +57,11 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (running) {
|
||||
res = (int)curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000
|
||||
|
@ -72,7 +72,7 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
while(!done) {
|
||||
fd_set rd, wr, exc;
|
||||
|
@ -82,17 +82,17 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = (int)curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000
|
||||
|
@ -74,7 +74,7 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
while (!done) {
|
||||
struct timeval interval;
|
||||
|
@ -82,13 +82,13 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
fprintf(stderr, "curl_multi_perform()\n");
|
||||
|
||||
|
@ -96,7 +96,7 @@ int test(char *URL)
|
|||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "test.h"
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000
|
||||
|
@ -58,11 +58,11 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
do {
|
||||
res = curl_multi_perform(multi, &still_running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
@ -70,7 +70,7 @@ int test(char *URL)
|
|||
} while (res == CURLM_CALL_MULTI_PERFORM);
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
while ((!ml_timedout) && (!mp_timedout) && (still_running)) {
|
||||
struct timeval timeout;
|
||||
|
@ -86,7 +86,7 @@ int test(char *URL)
|
|||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
|
@ -100,10 +100,10 @@ int test(char *URL)
|
|||
case 0:
|
||||
default:
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
do {
|
||||
res = curl_multi_perform(multi, &still_running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <openssl/bio.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000
|
||||
|
@ -248,7 +248,7 @@ int test(char *URL)
|
|||
fprintf(stderr, "Going to perform %s\n", (char *)p.accessinfoURL);
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
while (!done) {
|
||||
fd_set rd, wr, exc;
|
||||
|
@ -258,17 +258,17 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = curl_multi_perform(multi, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000
|
||||
|
@ -108,7 +108,7 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
while (!done) {
|
||||
fd_set rd, wr, exc;
|
||||
|
@ -118,17 +118,17 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = (int)curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 300 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 120 * 1000
|
||||
|
@ -98,7 +98,7 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
|
@ -110,17 +110,17 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = (int)curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000
|
||||
|
@ -84,7 +84,7 @@ int test(char *URL)
|
|||
curl_multi_setopt(m, CURLMOPT_PIPELINING, 1);
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
|
@ -96,17 +96,17 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = (int)curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000
|
||||
|
@ -66,7 +66,7 @@ int test(char *URL)
|
|||
}
|
||||
|
||||
ml_timedout = FALSE;
|
||||
ml_start = curlx_tvnow();
|
||||
ml_start = tutil_tvnow();
|
||||
|
||||
fprintf(stderr, "Start at URL 0\n");
|
||||
|
||||
|
@ -78,17 +78,17 @@ int test(char *URL)
|
|||
interval.tv_sec = 1;
|
||||
interval.tv_usec = 0;
|
||||
|
||||
if (curlx_tvdiff(curlx_tvnow(), ml_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), ml_start) >
|
||||
MAIN_LOOP_HANG_TIMEOUT) {
|
||||
ml_timedout = TRUE;
|
||||
break;
|
||||
}
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
while (res == CURLM_CALL_MULTI_PERFORM) {
|
||||
res = (int)curl_multi_perform(m, &running);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "timeval.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define MAIN_LOOP_HANG_TIMEOUT 30 * 1000
|
||||
#define MULTI_PERFORM_HANG_TIMEOUT 20 * 1000
|
||||
|
@ -30,11 +30,11 @@ static CURLMcode perform(CURLM * multi)
|
|||
char mp_timedout = FALSE;
|
||||
|
||||
mp_timedout = FALSE;
|
||||
mp_start = curlx_tvnow();
|
||||
mp_start = tutil_tvnow();
|
||||
|
||||
for (;;) {
|
||||
code = curl_multi_perform(multi, &handles);
|
||||
if (curlx_tvdiff(curlx_tvnow(), mp_start) >
|
||||
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
|
||||
MULTI_PERFORM_HANG_TIMEOUT) {
|
||||
mp_timedout = TRUE;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue