From 4803bbd58e670d2e4f6ae03ff97807bdcaf91a0e Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 4 Aug 2026 01:14:18 -0500 Subject: [PATCH] wolfssl/test.h: convert err_sys() and err_sys_with_errno() to err_sys_func() / err_sys_with_errno_func() taking __FILE__ and __LINE__, with function-like macros preserving every existing call site; failure messages now carry file and line ("wolfSSL error, %s L %d: %s"). tests/suites.c: client_test / server_test failure reports go to stderr (printf -> fprintf(stderr, ...)). --- tests/suites.c | 4 ++-- wolfssl/test.h | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/suites.c b/tests/suites.c index 13ff4480ad..f63de1d288 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -841,7 +841,7 @@ static int execute_test_case(int svr_argc, char** svr_argv, /* verify results */ if ((cliArgs.return_code != 0 && cliTestShouldFail == 0) || (cliArgs.return_code == 0 && cliTestShouldFail != 0)) { - printf("client_test failed %d %s\n", cliArgs.return_code, + fprintf(stderr, "client_test failed %d %s\n", cliArgs.return_code, cliTestShouldFail ? "(should fail)" : ""); XEXIT(EXIT_FAILURE); } @@ -849,7 +849,7 @@ static int execute_test_case(int svr_argc, char** svr_argv, join_thread(serverThread); if ((svrArgs.return_code != 0 && svrTestShouldFail == 0) || (svrArgs.return_code == 0 && svrTestShouldFail != 0)) { - printf("server_test failed %d %s\n", svrArgs.return_code, + fprintf(stderr, "server_test failed %d %s\n", svrArgs.return_code, svrTestShouldFail ? "(should fail)" : ""); XEXIT(EXIT_FAILURE); } diff --git a/wolfssl/test.h b/wolfssl/test.h index c8f226444a..abe701cf1a 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -394,7 +394,7 @@ THREAD_RETURN #else WC_NORETURN void #endif -err_sys(const char* msg) +err_sys_func(const char* msg, const char *file, int line) { #if !defined(__GNUC__) /* scan-build (which pretends to be gnuc) can get confused and think the @@ -406,10 +406,11 @@ err_sys(const char* msg) if (msg) #endif { - fprintf(stderr, "wolfSSL error: %s\n", msg); + fprintf(stderr, "wolfSSL error, %s L %d: %s\n", file, line, msg); } XEXIT_T(EXIT_FAILURE); } +#define err_sys(msg) err_sys_func(msg, __FILE__, __LINE__) static WC_INLINE #if defined(WOLFSSL_FORCE_MALLOC_FAIL_TEST) || defined(WOLFSSL_ZEPHYR) @@ -417,7 +418,7 @@ THREAD_RETURN #else WC_NORETURN void #endif -err_sys_with_errno(const char* msg) +err_sys_with_errno_func(const char* msg, const char *file, int line) { #if !defined(__GNUC__) /* scan-build (which pretends to be gnuc) can get confused and think the @@ -430,13 +431,15 @@ err_sys_with_errno(const char* msg) #endif { #if defined(HAVE_STRING_H) && defined(HAVE_ERRNO_H) - fprintf(stderr, "wolfSSL error: %s: %s\n", msg, strerror(errno)); + fprintf(stderr, "wolfSSL error, %s L %d: %s: %s\n", file, line, + msg, strerror(errno)); #else - fprintf(stderr, "wolfSSL error: %s\n", msg); + fprintf(stderr, "wolfSSL error, %s L %d: %s\n", file, line, msg); #endif } XEXIT_T(EXIT_FAILURE); } +#define err_sys_with_errno(msg) err_sys_with_errno_func(msg, __FILE__, __LINE__) #define LIBCALL_CHECK_RET(...) do { \ int _libcall_ret = (__VA_ARGS__); \