test_suite_debug: test the printf used by debug.c

In `test_suite_debug`, test `mbedtls_debug_snprintf()`, which uses
`mbedtls_vsnprintf()` like `mbedtls_debug_print_msg()`. Do this instead of
testing `mbedtls_snprintf()`, which might be subtly different (older
Windows runtimes had slightly different behavior for vsnprintf() vs
snprintf(); TF-PSA-Crypto might pick up a different function if the
platform configuration is different in TF-PSA-Crypto and Mbed TLS).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-02-17 17:08:12 +01:00
parent 7af09b4f21
commit 3c67824964
3 changed files with 26 additions and 3 deletions

View File

@@ -21,6 +21,16 @@
/* DEBUG_BUF_SIZE must be at least 2 */
#define DEBUG_BUF_SIZE 512
int mbedtls_debug_snprintf(char *dest, size_t maxlen,
const char *format, ...)
{
va_list argp;
va_start(argp, format);
int ret = mbedtls_vsnprintf(dest, maxlen, format, argp);
va_end(argp);
return ret;
}
static int debug_threshold = 0;
void mbedtls_debug_set_threshold(int threshold)