mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-16 13:57:23 +00:00
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 <[email protected]>
This commit is contained in:
@@ -116,11 +116,11 @@ void printf_int_expr(int format_indicator, intmax_t sizeof_x, intmax_t x, char *
|
||||
/* Nominal case: buffer just large enough */
|
||||
TEST_CALLOC(output, n + 1);
|
||||
if ((size_t) sizeof_x <= sizeof(int)) { // Any smaller integers would be promoted to an int due to calling a vararg function
|
||||
TEST_EQUAL(n, mbedtls_snprintf(output, n + 1, format, (int) x));
|
||||
TEST_EQUAL(n, mbedtls_debug_snprintf(output, n + 1, format, (int) x));
|
||||
} else if (sizeof_x == sizeof(long)) {
|
||||
TEST_EQUAL(n, mbedtls_snprintf(output, n + 1, format, (long) x));
|
||||
TEST_EQUAL(n, mbedtls_debug_snprintf(output, n + 1, format, (long) x));
|
||||
} else if (sizeof_x == sizeof(long long)) {
|
||||
TEST_EQUAL(n, mbedtls_snprintf(output, n + 1, format, (long long) x));
|
||||
TEST_EQUAL(n, mbedtls_debug_snprintf(output, n + 1, format, (long long) x));
|
||||
} else {
|
||||
TEST_FAIL(
|
||||
"sizeof_x <= sizeof(int) || sizeof_x == sizeof(long) || sizeof_x == sizeof(long long)");
|
||||
|
||||
Reference in New Issue
Block a user