tests: stop overriding system printf symbols

To make the source code match the functions called at runtime.
And to avoid the preprocessor trick that may introduces build issues.

Before this patch, libtests, tunits and units were calling a mixture
of curl and system printf calls, then transformed them all to curl
printf calls by including `curl_printf.h`.

Changes made:
- tests: stop including `curl_printf.h`.
- libtest: switch a couple of outlier system printf calls to curl
  printf.
- unit: use more curl printf to avoid casts and show whole values.
- unit: switch remaining calls to curl printf explicitly.
- tunit: switch to call curl printf explicitly.
- libtest, tunit, unit: ban system printf.
- unit1307, unit1607, unit1609, unit1652, unit1655, unit3214: bump
  types/masks to avoid casts.

After this patch:
- libtests, tunits, units: use exclusively curl printf.
  (as before, but explicitly, without relying on redefinitions.)
- servers: is unchanged (it can only use system printf).

Closes #18814
This commit is contained in:
Viktor Szakats 2025-10-02 16:01:15 +02:00
parent 45438c8d6f
commit 4deea9396b
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
26 changed files with 200 additions and 174 deletions

8
tests/libtest/.checksrc Normal file
View file

@ -0,0 +1,8 @@
banfunc aprintf
banfunc fprintf
banfunc msnprintf
banfunc mvsnprintf
banfunc printf
banfunc vaprintf
banfunc vfprintf
banfunc vprintf

View file

@ -41,7 +41,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
# Get BUNDLE, FIRST_C, FIRST_H, UTILS_C, UTILS_H, CURLX_C, TESTS_C variables
include Makefile.inc
EXTRA_DIST = CMakeLists.txt $(FIRST_C) $(FIRST_H) $(UTILS_C) $(UTILS_H) $(TESTS_C) \
EXTRA_DIST = CMakeLists.txt .checksrc $(FIRST_C) $(FIRST_H) $(UTILS_C) $(UTILS_H) $(TESTS_C) \
test307.pl test610.pl test613.pl test1013.pl test1022.pl mk-lib1521.pl
CFLAGS += @CURL_CFLAG_EXTRAS@

View file

@ -52,8 +52,6 @@ extern int unitfail; /* for unittests */
#include <sys/select.h>
#endif
#include "curl_printf.h"
/* GCC <4.6 does not support '#pragma GCC diagnostic push' and
does not support 'pragma GCC diagnostic' inside functions. */
#if (defined(__GNUC__) && \

View file

@ -58,14 +58,14 @@ static CURLcode test_lib1549(const char *URL)
/* a linked list of cookies in cookie file format */
struct curl_slist *each = cookies;
while(each) {
printf("%s\n", each->data);
curl_mprintf("%s\n", each->data);
each = each->next;
num++;
}
/* we must free these cookies when we are done */
curl_slist_free_all(cookies);
}
fprintf(stderr, "%d cookies\n", num);
curl_mfprintf(stderr, "%d cookies\n", num);
}
test_cleanup: