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, ...)).
This commit is contained in:
Daniel Pouzzner
2026-08-05 13:53:46 -05:00
parent 0e1a3f91c2
commit 4803bbd58e
2 changed files with 10 additions and 7 deletions
+2 -2
View File
@@ -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);
}
+8 -5
View File
@@ -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__); \