From e2f84e6ba9f1a6135d3bb33fd0b881a5d90cf606 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 27 Apr 2026 10:49:45 +0200 Subject: [PATCH] tunits: initialize global `tool_stderr` To avoid difficult to track down crashes when a tested function ends up outputing a message via `errorf()`, `warnf()` or siblings. Cherry-picked from #21449 Closes #21454 --- tests/libtest/first.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 08d9a9363b..e4e9dbd8c8 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -27,6 +27,10 @@ #include /* for setlocale() */ #endif +#if defined(UNITTESTS) && !defined(BUILDING_LIBCURL) +#include "tool_stderr.h" /* for tool_init_stderr() */ +#endif + int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv) { @@ -276,6 +280,10 @@ int main(int argc, const char **argv) testnum = (int)num; } +#if defined(UNITTESTS) && !defined(BUILDING_LIBCURL) + tool_init_stderr(); +#endif + result = entry_func(URL); curl_mfprintf(stderr, "Test ended with result %d\n", result);