]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/http/clients: drop hack and use `curl_setup.h` again
authorViktor Szakats <commit@vsz.me>
Mon, 16 Jun 2025 14:04:22 +0000 (16:04 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 16 Jun 2025 20:25:57 +0000 (22:25 +0200)
Sync build properties with libtests.

This allows accessing macros from `curl_config.h`, for feature flags.
Smoothens out platform bumps, allowing to drop local replicas from
client sources. It enables using Windows wrappers, e.g. for `fopen()`.

Also fix client sources to use `curl_mfprintf()` where curl format
strings are used. (To avoid build failure with older mingw-w64, e.g.
6.4.0 in CI.)

Follow-up to 739c09c8a4111b3ee00b0004f5a3f67e00ba3aeb #17627

Closes #17642

tests/http/clients/CMakeLists.txt
tests/http/clients/Makefile.am
tests/http/clients/Makefile.inc
tests/http/clients/first.h
tests/http/clients/h2_pausing.c
tests/http/clients/h2_upgrade_extreme.c
tests/http/clients/tls_session_reuse.c

index c30f0d441ae2294387b8a3d07867f41057d89d52..f6c0fb137f8833388565c8e1069e70f8ddef15fd 100644 (file)
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
-# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, TESTFILES variables
+
+# Get BUNDLE, BUNDLE_SRC, CURLX_SRCS, FIRSTFILES, TESTFILES variables
 curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
 
+set(_bundle_extra "")
+if(LIB_SELECTED STREQUAL LIB_SHARED)
+  list(APPEND _bundle_extra ${CURLX_SRCS})  # Not exported from the libcurl shared build. Build a copy.
+endif()
+
 add_custom_command(
   OUTPUT "${BUNDLE_SRC}"
-  COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" --test ${TESTFILES}
+  COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl"
+    --include ${_bundle_extra} --test ${TESTFILES}
     ${CURL_MK_UNITY_OPTION} --srcdir "${CMAKE_CURRENT_SOURCE_DIR}" > "${BUNDLE_SRC}"
   DEPENDS
-    "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" ${FIRSTFILES} ${TESTFILES}
+    "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
+    ${FIRSTFILES} ${_bundle_extra} ${TESTFILES}
   VERBATIM)
 
 add_executable(http-clients EXCLUDE_FROM_ALL "${BUNDLE_SRC}")
 add_dependencies(testdeps http-clients)
 target_include_directories(http-clients PRIVATE
   "${PROJECT_BINARY_DIR}/lib"            # for "curl_config.h"
+  "${PROJECT_SOURCE_DIR}/lib"            # for "curl_setup.h"
+  "${PROJECT_SOURCE_DIR}/lib/curlx"      # for curlx
   "${CMAKE_CURRENT_SOURCE_DIR}"          # for "first.h"
 )
 target_link_libraries(http-clients ${LIB_SELECTED} ${CURL_LIBS})
index 45307140be249e30a678ec11d5e07a1a7f54ade4..a8427e32bc44c9f8f731797e7c9bad315505123b 100644 (file)
@@ -30,12 +30,15 @@ AUTOMAKE_OPTIONS = foreign nostdinc
 #
 # $(top_srcdir)/include is for libcurl's external include files
 # $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
+# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
 
 AM_CPPFLAGS = -I$(top_srcdir)/include        \
               -I$(top_builddir)/lib          \
+              -I$(top_srcdir)/lib            \
+              -I$(top_srcdir)/lib/curlx      \
               -I$(srcdir)
 
-# Get BUNDLE, BUNDLE_SRC, FIRSTFILES, TESTFILES variables
+# Get BUNDLE, BUNDLE_SRC, CURLX_SRCS, FIRSTFILES, TESTFILES variables
 include Makefile.inc
 
 EXTRA_DIST = CMakeLists.txt $(FIRSTFILES) $(TESTFILES)
@@ -56,8 +59,14 @@ endif
 
 AM_CPPFLAGS += -DCURL_NO_OLDIES
 
-$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(TESTFILES)
-       @PERL@ $(top_srcdir)/scripts/mk-unity.pl --test $(TESTFILES) > $(BUNDLE_SRC)
+bundle_extra =
+if USE_CPPFLAG_CURL_STATICLIB
+else
+# These are part of the libcurl static lib. Add them here when linking shared.
+bundle_extra += $(CURLX_SRCS)
+endif
+$(BUNDLE_SRC): $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRSTFILES) $(bundle_extra) $(TESTFILES)
+       @PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(bundle_extra) --test $(TESTFILES) > $(BUNDLE_SRC)
 
 noinst_PROGRAMS = $(BUNDLE)
 nodist_clients_SOURCES = $(BUNDLE_SRC)
index 748c481943eb08388a36c5556425fe2171cf243d..52c63390ebb3ab926df810410d5783817005228c 100644 (file)
@@ -29,6 +29,9 @@ BUNDLE_SRC = clients.c
 # Files referenced from the bundle source
 FIRSTFILES = first.c first.h
 
+CURLX_SRCS = \
+  ../../../lib/curlx/multibyte.c
+
 # All test clients
 TESTFILES = \
   h2_pausing.c \
index 1c74221c86f62ae184f37134d6dac65c2bcd10c9..eb11b83035f0b7d360c5acf016b2feb025121eef 100644 (file)
@@ -23,9 +23,7 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
-#ifdef HAVE_CONFIG_H
-#include "curl_config.h"  /* for CURL_DISABLE_WEBSOCKETS */
-#endif
+#include "curl_setup.h"
 
 typedef int (*entry_func_t)(int, char **);
 
@@ -40,10 +38,7 @@ struct entry_s {
 #include <stdlib.h>  /* for calloc(), free(), strtol() */
 #include <string.h>  /* for strchr(), strcmp() */
 
-#ifdef _WIN32
-#include <windows.h>  /* for Sleep() */
-#define strdup _strdup
-#else
+#ifndef _WIN32
 #include <sys/time.h>  /* for usleep() */
 #include <unistd.h>  /* for usleep() */
 #endif
@@ -52,12 +47,6 @@ struct entry_s {
 #include <cextdecs.h(PROCESS_DELAY_)>  /* for usleep() logic */
 #endif
 
-#if defined(_MSC_VER) && (_MSC_VER <= 1700)
-#pragma warning(disable:4127)  /* "conditional expression is constant" */
-#endif
-
-#define CURL_ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
-
 #define ERR()                                                             \
   do {                                                                    \
     fprintf(stderr, "something unexpected went wrong - bailing out!\n");  \
index 4efc0e88fa0121109c7aab6da3b78b6356c37d24..2fe0a7dc624b5919ee22e72fd82a671bce051c33 100644 (file)
@@ -55,8 +55,9 @@ static size_t cb(char *data, size_t size, size_t nmemb, void *clientp)
   (void)data;
   if(curl_easy_getinfo(handle->h, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
                        &totalsize) == CURLE_OK)
-    fprintf(stderr, "INFO: [%d] write, Content-Length %"CURL_FORMAT_CURL_OFF_T
-            "\n", (int)handle->idx, totalsize);
+    curl_mfprintf(stderr, "INFO: [%d] write, "
+                  "Content-Length %" CURL_FORMAT_CURL_OFF_T "\n",
+                  (int)handle->idx, totalsize);
 
   if(!handle->resumed) {
     ++handle->paused;
index 142aec2a619fcc0698084f72a5572c0770f32a24..4cf657f2f9beb922743ce06bf668f465aa0288b3 100644 (file)
@@ -118,19 +118,20 @@ static int test_h2_upgrade_extreme(int argc, char *argv[])
            * re-using a connection */
         }
         else if(msg->data.result) {
-          fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
-                  ": failed with %d\n", xfer_id, msg->data.result);
+          curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+                        ": failed with %d\n", xfer_id, msg->data.result);
           goto cleanup;
         }
         else if(status != 206) {
-          fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
-                  ": wrong http status %ld (expected 206)\n", xfer_id, status);
+          curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+                        ": wrong http status %ld (expected 206)\n", xfer_id,
+                        status);
           goto cleanup;
         }
         curl_multi_remove_handle(multi, msg->easy_handle);
         curl_easy_cleanup(msg->easy_handle);
-        fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
-                "(%d now running)\n", xfer_id, running_handles);
+        curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
+                      "(%d now running)\n", xfer_id, running_handles);
       }
     }
 
index 88c3aa11a2dce80bde74710fa0ccc93f4c24f361..b99fcb50ab0700c23181a992885eeb352fcbe9d4 100644 (file)
@@ -179,20 +179,21 @@ static int test_tls_session_reuse(int argc, char *argv[])
            * re-using a connection */
         }
         else if(msg->data.result) {
-          fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
-                  ": failed with %d\n", xfer_id, msg->data.result);
+          curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+                        ": failed with %d\n", xfer_id, msg->data.result);
           goto cleanup;
         }
         else if(status != 200) {
-          fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
-                  ": wrong http status %ld (expected 200)\n", xfer_id, status);
+          curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T
+                        ": wrong http status %ld (expected 200)\n", xfer_id,
+                        status);
           goto cleanup;
         }
         curl_multi_remove_handle(multi, msg->easy_handle);
         curl_easy_cleanup(msg->easy_handle);
         --ongoing;
-        fprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
-                "(%d now running)\n", xfer_id, running_handles);
+        curl_mfprintf(stderr, "transfer #%" CURL_FORMAT_CURL_OFF_T" retiring "
+                      "(%d now running)\n", xfer_id, running_handles);
       }
     }