From 1d84d683bb44c305c13188b31d2117ff95a22da7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 1 Apr 2025 09:18:33 +0200 Subject: [PATCH] test: make unittest 1308 into a libtest Test 1308 was wrongly marked a unit test when in reality it is a libtest. Closes #16891 --- tests/data/test1308 | 7 ++++--- tests/libtest/CMakeLists.txt | 1 + tests/libtest/Makefile.am | 3 ++- tests/libtest/Makefile.inc | 4 ++++ tests/libtest/lib1301.c | 11 +---------- tests/{unit/unit1308.c => libtest/lib1308.c} | 19 +++++-------------- tests/unit/Makefile.inc | 4 +--- 7 files changed, 18 insertions(+), 31 deletions(-) rename tests/{unit/unit1308.c => libtest/lib1308.c} (95%) diff --git a/tests/data/test1308 b/tests/data/test1308 index d05e3bdfb1..a106e1a0a2 100644 --- a/tests/data/test1308 +++ b/tests/data/test1308 @@ -1,7 +1,6 @@ -unittest curl_formadd curl_formget FORM @@ -12,7 +11,6 @@ FORM # Client-side -unittest http form-api @@ -20,8 +18,11 @@ form-api none -formpost unit tests +formpost tests + +lib%TESTNUMBER + %LOGDIR/test-%TESTNUMBER diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt index c0c428f0b2..9a50afe8ac 100644 --- a/tests/libtest/CMakeLists.txt +++ b/tests/libtest/CMakeLists.txt @@ -79,6 +79,7 @@ foreach(_target IN LISTS LIBTESTPROGS) "${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h" "${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h" "${PROJECT_SOURCE_DIR}/tests/libtest" # to be able to build generated tests + "${PROJECT_SOURCE_DIR}/tests/unit" # for curlcheck.h ) set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}") if(NOT CURL_TEST_BUNDLES) diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 924fba1564..d3d7860afa 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -36,7 +36,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib \ -I$(top_srcdir)/src \ - -I$(top_srcdir)/tests/libtest + -I$(top_srcdir)/tests/libtest \ + -I$(top_srcdir)/tests/unit EXTRA_DIST = test307.pl test610.pl test613.pl test1013.pl test1022.pl \ CMakeLists.txt mk-lib1521.pl .checksrc diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 9a866306fa..7b7b2078b2 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -52,6 +52,7 @@ LIBTESTPROGS = libauthretry libntlmconnect libprereq \ lib696 \ lib1156 \ lib1301 \ + lib1308 \ lib1485 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \ @@ -351,6 +352,9 @@ lib696_CPPFLAGS = $(AM_CPPFLAGS) -DLIB696 lib1301_SOURCES = lib1301.c $(SUPPORTFILES) $(TESTUTIL) lib1301_LDADD = $(TESTUTIL_LIBS) +lib1308_SOURCES = lib1308.c $(SUPPORTFILES) +lib1308_LDADD = $(TESTUTIL_LIBS) + lib1485_SOURCES = lib1485.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1485_LDADD = $(TESTUTIL_LIBS) diff --git a/tests/libtest/lib1301.c b/tests/libtest/lib1301.c index 39ba7dc1fc..0a6080e711 100644 --- a/tests/libtest/lib1301.c +++ b/tests/libtest/lib1301.c @@ -21,16 +21,7 @@ * SPDX-License-Identifier: curl * ***************************************************************************/ -#include "test.h" - -#define fail_unless(expr, msg) \ - do { \ - if(!(expr)) { \ - fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \ - __FILE__, __LINE__, #expr, msg); \ - return TEST_ERR_FAILURE; \ - } \ - } while(0) +#include "curlcheck.h" CURLcode test(char *URL) { diff --git a/tests/unit/unit1308.c b/tests/libtest/lib1308.c similarity index 95% rename from tests/unit/unit1308.c rename to tests/libtest/lib1308.c index 4d29fb887b..b3b0c61214 100644 --- a/tests/unit/unit1308.c +++ b/tests/libtest/lib1308.c @@ -25,16 +25,6 @@ #include -static CURLcode unit_setup(void) -{ - return CURLE_OK; -} - -static void unit_stop(void) -{ - -} - static size_t print_httppost_callback(void *arg, const char *buf, size_t len) { fwrite(buf, len, 1, stdout); @@ -42,7 +32,8 @@ static size_t print_httppost_callback(void *arg, const char *buf, size_t len) return len; } -UNITTEST_START +CURLcode test(char *URL) +{ CURLFORMcode rc; int res; struct curl_httppost *post = NULL; @@ -90,7 +81,7 @@ UNITTEST_START CURL_IGNORE_DEPRECATION( rc = curl_formadd(&post, &last, CURLFORM_PTRNAME, "name of file field", - CURLFORM_FILE, arg, + CURLFORM_FILE, URL, CURLFORM_FILENAME, "custom named file", CURLFORM_END); ) @@ -105,5 +96,5 @@ UNITTEST_START CURL_IGNORE_DEPRECATION( curl_formfree(post); ) - -UNITTEST_STOP + return CURLE_OK; +} diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 4b34d4dd22..4a9369326e 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -32,7 +32,7 @@ UNITFILES = curlcheck.h $(FIRSTFILES) # These are all unit test programs UNITPROGS = unit1300 unit1302 unit1303 unit1304 unit1305 unit1307 \ - unit1308 unit1309 unit1323 \ + unit1309 unit1323 \ unit1330 unit1394 unit1395 unit1396 unit1397 unit1398 \ unit1399 \ unit1600 unit1601 unit1602 unit1603 unit1604 unit1605 unit1606 unit1607 \ @@ -56,8 +56,6 @@ unit1305_SOURCES = unit1305.c $(UNITFILES) unit1307_SOURCES = unit1307.c $(UNITFILES) -unit1308_SOURCES = unit1308.c $(UNITFILES) - unit1309_SOURCES = unit1309.c $(UNITFILES) unit1323_SOURCES = unit1323.c $(UNITFILES) -- 2.47.2