]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test: make unittest 1308 into a libtest
authorDaniel Stenberg <daniel@haxx.se>
Tue, 1 Apr 2025 07:18:33 +0000 (09:18 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 2 Apr 2025 12:01:27 +0000 (14:01 +0200)
Test 1308 was wrongly marked a unit test when in reality it is a
libtest.

Closes #16891

tests/data/test1308
tests/libtest/CMakeLists.txt
tests/libtest/Makefile.am
tests/libtest/Makefile.inc
tests/libtest/lib1301.c
tests/libtest/lib1308.c [moved from tests/unit/unit1308.c with 95% similarity]
tests/unit/Makefile.inc

index d05e3bdfb17378594981476e457fb1a9cdecd3e2..a106e1a0a24132837d518f6f2b9de9a6df5611f9 100644 (file)
@@ -1,7 +1,6 @@
 <testcase>
 <info>
 <keywords>
-unittest
 curl_formadd
 curl_formget
 FORM
@@ -12,7 +11,6 @@ FORM
 # Client-side
 <client>
 <features>
-unittest
 http
 form-api
 </features>
@@ -20,8 +18,11 @@ form-api
 none
 </server>
 <name>
-formpost unit tests
+formpost tests
 </name>
+<tool>
+lib%TESTNUMBER
+</tool>
 <command>
 %LOGDIR/test-%TESTNUMBER
 </command>
index c0c428f0b20be1d3a0977a680300246110f90a0d..9a50afe8acab01462087a8513d6a7955a11a3fcf 100644 (file)
@@ -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)
index 924fba156418b64fa7eff5dbff4a4a806ecd7124..d3d7860afaa7dd497b78155d654ef7448c8997e2 100644 (file)
@@ -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
index 9a866306fa9b789b66749a83a883b67bd8edb130..7b7b2078b2ff49fad6893c83e84068debf6173eb 100644 (file)
@@ -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)
 
index 39ba7dc1fc3121e5fef5f0f00b81e8a41bb61383..0a6080e7110e1790af396dfa2a6bca4b2352c7a0 100644 (file)
  * 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)
 {
similarity index 95%
rename from tests/unit/unit1308.c
rename to tests/libtest/lib1308.c
index 4d29fb887bc78a43a69a88a28fc98400229ae2cc..b3b0c61214280c9502f5e4e5642a9465b630892b 100644 (file)
 
 #include <curl/curl.h>
 
-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;
+}
index 4b34d4dd22cea40ec0c69f72e40f099c0384916a..4a9369326eeb8bb6f947752ca98c15439a559e83 100644 (file)
@@ -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)