From 2f4fe0175b265735fe69f21513f137398743daa4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 9 Feb 2007 01:11:14 +0000 Subject: 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. --- tests/libtest/Makefile.am | 31 +++++++++++++++---------------- tests/libtest/lib502.c | 6 +++--- tests/libtest/lib503.c | 10 +++++----- tests/libtest/lib504.c | 10 +++++----- tests/libtest/lib507.c | 14 +++++++------- tests/libtest/lib509.c | 10 +++++----- tests/libtest/lib525.c | 10 +++++----- tests/libtest/lib526.c | 10 +++++----- tests/libtest/lib530.c | 10 +++++----- tests/libtest/lib533.c | 10 +++++----- tests/libtest/lib536.c | 6 +++--- 11 files changed, 63 insertions(+), 64 deletions(-) (limited to 'tests') diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 61d4cc32e..61f8f399b 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -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) diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index 207f65ed2..d995b45ec 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -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; diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index efa6723c1..bcf4f57be 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -12,7 +12,7 @@ #include -#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; diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 775468da0..499b9e985 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -12,7 +12,7 @@ #include -#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; diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 8de1a3550..d17526463 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -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; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 86e169d8d..8f2210f5f 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -27,7 +27,7 @@ #include #include -#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; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 24a329452..ce12b3b84 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -14,7 +14,7 @@ #include #include -#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; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 2dee9cf63..1cfa6d00e 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -33,7 +33,7 @@ #include #include -#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; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 987296c7a..96c27b951 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -13,7 +13,7 @@ #include #include -#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; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 24764bd3c..0cb227529 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -16,7 +16,7 @@ #include #include -#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; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index adad23a16..3f41b00db 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -14,7 +14,7 @@ #include #include -#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; -- cgit v1.2.3