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
This commit is contained in:
Viktor Szakats 2026-04-27 10:49:45 +02:00
parent 4d89043fbc
commit e2f84e6ba9
No known key found for this signature in database

View file

@ -27,6 +27,10 @@
#include <locale.h> /* 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);