[PATCH] Printf: libc independent I/O error test
Printf test suite fails on systems with musl libc because tests for "%m" and "%M" formats expect "Input/output error" message but musl returns "I/O error". Proposed change compares the printf output with string returned from strerror function for EIO constant. See-also: https://bugs.gentoo.org/836713 Signed-off-by: Petr Vaněk <arkamar@atlas.cz> --- lib/printf_test.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/printf_test.c b/lib/printf_test.c index 47ea905d..ca278975 100644 --- a/lib/printf_test.c +++ b/lib/printf_test.c @@ -32,11 +32,14 @@ t_simple(void) BSPRINTF(1, "@", buf, "@", 64); BSPRINTF(1, "\xff", buf, "%c", 0xff); + const char * io_error_str = strerror(EIO); + const int io_error_len = strlen(io_error_str); + errno = 5; - BSPRINTF(18, "Input/output error", buf, "%m"); + BSPRINTF(io_error_len, io_error_str, buf, "%m"); errno = 0; - BSPRINTF(18, "Input/output error", buf, "%M", 5); + BSPRINTF(io_error_len, io_error_str, buf, "%M", 5); BSPRINTF(11, "TeSt%StRiNg", buf, "%s", "TeSt%StRiNg"); -- 2.39.2
On Sun, Mar 05, 2023 at 04:34:40PM +0100, Petr Vaněk wrote:
Printf test suite fails on systems with musl libc because tests for "%m" and "%M" formats expect "Input/output error" message but musl returns "I/O error". Proposed change compares the printf output with string returned from strerror function for EIO constant.
Thanks, merged. Note that the string returned by strerror() can be changed by subsequent calls to strerror(), including from inside bsprintf(), so i added string duplication call around it: - const char *io_error_str = strerror(EIO); + const char *io_error_str = lp_strdup(tmp_linpool, strerror(EIO)); -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
On Mon, Mar 06, 2023 at 11:43:40AM +0100, Ondrej Zajicek wrote:
On Sun, Mar 05, 2023 at 04:34:40PM +0100, Petr Vaněk wrote:
Printf test suite fails on systems with musl libc because tests for "%m" and "%M" formats expect "Input/output error" message but musl returns "I/O error". Proposed change compares the printf output with string returned from strerror function for EIO constant.
Thanks, merged. Note that the string returned by strerror() can be changed by subsequent calls to strerror(), including from inside bsprintf(), so i added string duplication call around it:
- const char *io_error_str = strerror(EIO); + const char *io_error_str = lp_strdup(tmp_linpool, strerror(EIO));
Yes, I see, string duplication makes sense. Thanks! Petr
participants (2)
-
Ondrej Zajicek -
Petr Vaněk