diff --git a/tests/data/test1503 b/tests/data/test1503
index 9c746c74e8..c387b8d3c5 100644
--- a/tests/data/test1503
+++ b/tests/data/test1503
@@ -32,7 +32,7 @@ Funny-head: yesyes
http
-lib%TESTNUMBER
+lib1502
HTTP multi with CURLOPT_RESOLVE, cleanup sequence PA
diff --git a/tests/data/test1504 b/tests/data/test1504
index 663e25e274..916a40ba8c 100644
--- a/tests/data/test1504
+++ b/tests/data/test1504
@@ -32,7 +32,7 @@ Funny-head: yesyes
http
-lib%TESTNUMBER
+lib1502
HTTP multi with CURLOPT_RESOLVE, cleanup sequence UB
diff --git a/tests/data/test1505 b/tests/data/test1505
index 666e4d984b..61e634641a 100644
--- a/tests/data/test1505
+++ b/tests/data/test1505
@@ -32,7 +32,7 @@ Funny-head: yesyes
http
-lib%TESTNUMBER
+lib1502
HTTP multi with CURLOPT_RESOLVE, cleanup sequence PB
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 293b0f0970..d8c5e14c3d 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -55,7 +55,7 @@ LIBTESTPROGS = libauthretry libntlmconnect libprereq \
lib1301 \
lib1308 \
lib1485 \
- lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
+ lib1500 lib1501 lib1502 lib1506 lib1507 lib1508 \
lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \
lib1518 lib1520 lib1521 lib1522 lib1523 \
lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
@@ -376,19 +376,6 @@ lib1501_LDADD = $(TESTUTIL_LIBS)
lib1502_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1502_LDADD = $(TESTUTIL_LIBS)
-lib1502_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1502
-
-lib1503_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
-lib1503_LDADD = $(TESTUTIL_LIBS)
-lib1503_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1503
-
-lib1504_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
-lib1504_LDADD = $(TESTUTIL_LIBS)
-lib1504_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1504
-
-lib1505_SOURCES = lib1502.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
-lib1505_LDADD = $(TESTUTIL_LIBS)
-lib1505_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1505
lib1506_SOURCES = lib1506.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1506_LDADD = $(TESTUTIL_LIBS)
diff --git a/tests/libtest/first.c b/tests/libtest/first.c
index a10f87106d..a90c2d7f1e 100644
--- a/tests/libtest/first.c
+++ b/tests/libtest/first.c
@@ -73,6 +73,7 @@ char *libtest_arg3 = NULL;
char *libtest_arg4 = NULL;
int test_argc;
char **test_argv;
+int testnum;
struct timeval tv_test_start; /* for test timing */
@@ -121,6 +122,7 @@ int main(int argc, char **argv)
CURLcode result;
int basearg;
test_func_t test_func;
+ char *env;
CURL_SET_BINMODE(stdout);
@@ -191,6 +193,12 @@ int main(int argc, char **argv)
URL = argv[basearg]; /* provide this to the rest */
+ env = getenv("CURL_TESTNUM");
+ if(env)
+ testnum = atoi(env);
+ else
+ testnum = 0;
+
curl_mfprintf(stderr, "URL: %s\n", URL);
result = test_func(URL);
diff --git a/tests/libtest/lib1502.c b/tests/libtest/lib1502.c
index b4f56407f5..b118fd7786 100644
--- a/tests/libtest/lib1502.c
+++ b/tests/libtest/lib1502.c
@@ -23,7 +23,7 @@
***************************************************************************/
/*
* This source code is used for lib1502, lib1503, lib1504 and lib1505 with
- * only #ifdefs controlling the cleanup sequence.
+ * only the testnum controlling the cleanup sequence.
*
* Test case 1502 converted from bug report #3575448, identifying a memory
* leak in the CURLOPT_RESOLVE handling with the multi interface.
@@ -44,7 +44,6 @@ CURLcode test(char *URL)
CURLM *multi = NULL;
int still_running;
CURLcode res = CURLE_OK;
-
char redirect[160];
/* DNS cache injection */
@@ -121,35 +120,35 @@ CURLcode test(char *URL)
test_cleanup:
-#ifdef LIB1502
- /* undocumented cleanup sequence - type UA */
- curl_multi_cleanup(multi);
- curl_easy_cleanup(easy);
- curl_global_cleanup();
-#endif
-
-#ifdef LIB1503
- /* proper cleanup sequence - type PA */
- curl_multi_remove_handle(multi, easy);
- curl_multi_cleanup(multi);
- curl_easy_cleanup(easy);
- curl_global_cleanup();
-#endif
-
-#ifdef LIB1504
- /* undocumented cleanup sequence - type UB */
- curl_easy_cleanup(easy);
- curl_multi_cleanup(multi);
- curl_global_cleanup();
-#endif
-
-#ifdef LIB1505
- /* proper cleanup sequence - type PB */
- curl_multi_remove_handle(multi, easy);
- curl_easy_cleanup(easy);
- curl_multi_cleanup(multi);
- curl_global_cleanup();
-#endif
+ switch(testnum) {
+ case 1502:
+ default:
+ /* undocumented cleanup sequence - type UA */
+ curl_multi_cleanup(multi);
+ curl_easy_cleanup(easy);
+ curl_global_cleanup();
+ break;
+ case 1503:
+ /* proper cleanup sequence - type PA */
+ curl_multi_remove_handle(multi, easy);
+ curl_multi_cleanup(multi);
+ curl_easy_cleanup(easy);
+ curl_global_cleanup();
+ break;
+ case 1504:
+ /* undocumented cleanup sequence - type UB */
+ curl_easy_cleanup(easy);
+ curl_multi_cleanup(multi);
+ curl_global_cleanup();
+ break;
+ case 1505:
+ /* proper cleanup sequence - type PB */
+ curl_multi_remove_handle(multi, easy);
+ curl_easy_cleanup(easy);
+ curl_multi_cleanup(multi);
+ curl_global_cleanup();
+ break;
+ }
curl_slist_free_all(dns_cache_list);
diff --git a/tests/libtest/test.h b/tests/libtest/test.h
index 753d549498..9d57f7a51c 100644
--- a/tests/libtest/test.h
+++ b/tests/libtest/test.h
@@ -71,7 +71,7 @@ extern char *libtest_arg4; /* set by first.c to the argv[4] or NULL */
/* argc and argv as passed in to the main() function */
extern int test_argc;
extern char **test_argv;
-
+extern int testnum;
extern struct timeval tv_test_start; /* for test timing */
extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
diff --git a/tests/runner.pm b/tests/runner.pm
index da26efb346..1f2ff73328 100644
--- a/tests/runner.pm
+++ b/tests/runner.pm
@@ -756,6 +756,9 @@ sub singletest_prepare {
# write the instructions to file
writearray("$LOGDIR/$SERVERCMD", \@ftpservercmd);
+ # provide an environment variable
+ $ENV{'CURL_TESTNUM'} = $testnum;
+
# create (possibly-empty) files before starting the test
for my $partsuffix (('', '1', '2', '3', '4')) {
my @inputfile=getpart("client", "file".$partsuffix);