diff --git a/tests/suites/test_suite_platform_printf.data b/tests/suites/test_suite_platform_printf.data index 25c1ed33a8..a359e8c581 100644 --- a/tests/suites/test_suite_platform_printf.data +++ b/tests/suites/test_suite_platform_printf.data @@ -60,16 +60,19 @@ printf "%u", 0x80000000 printf_integer:"%u":PRINTF_CAST_INT:-0x80000000:"2147483648" printf "%zx", 0x12345678 +depends_on:HAVE_C99_PRINTF printf_integer:"%zx":PRINTF_CAST_SIZE_T:0x12345678:"12345678" printf "%zu", 0x80000000 +depends_on:HAVE_C99_PRINTF printf_integer:"%zu":PRINTF_CAST_SIZE_T:0x80000000:"2147483648" printf "%zx", 0xffffffff +depends_on:HAVE_C99_PRINTF printf_integer:"%zx":PRINTF_CAST_SIZE_T:0xffffffff:"ffffffff" printf "%zx", 0xffffffffffffffff -depends_on:SIZE_T_AT_LEAST_64_BIT +depends_on:HAVE_C99_PRINTF:SIZE_T_AT_LEAST_64_BIT printf_integer:"%zx":PRINTF_CAST_SIZE_T:0xffffffffffffffff:"ffffffffffffffff" printf "%lld", 0x7fffffffffffffff diff --git a/tests/suites/test_suite_platform_printf.function b/tests/suites/test_suite_platform_printf.function index 000d265a53..5a132b7954 100644 --- a/tests/suites/test_suite_platform_printf.function +++ b/tests/suites/test_suite_platform_printf.function @@ -19,6 +19,20 @@ #define SIZE_T_AT_LEAST_64_BIT #endif +/* Older Windows runtimes have a non-compliant printf family, e.g. + * it doesn't understand `%zu` to print a `size_t`. MSVC provides a + * C99-compliant printf family (at least enough for our purposes), + * since Visual Studio 2015. With MinGW, you get the non-compliant legacy + * printf by default, but can select the standard-compliant version + * at compile time. In the Mbed TLS 3.6 LTS, we use the default, so + * we can't rely on %z being understood. The debug module defines + * `MBEDTLS_PRINTF_SIZET` for that, and this is tested in test_suite_debug. + * Here we just skip the test cases that break the legacy Windows printf. + */ +#if !(defined(__MINGW32__)) +#define HAVE_C99_PRINTF +#endif + typedef enum { PRINTF_CAST_INT, PRINTF_CAST_UNSIGNED,