* [PATCH] test_enosys: Handle musl libc error strings
@ 2026-03-23 3:03 Anna Wilcox
2026-03-23 13:32 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Anna Wilcox @ 2026-03-23 3:03 UTC (permalink / raw)
To: util-linux; +Cc: Anna Wilcox, Sam James
strerror(3) on musl gives different strings for some of the errnos we
test for, so the tests incorrectly fail on musl. Change the strings
back into the glibc ones so they match the expected values properly.
Signed-off-by: Anna Wilcox <AWilcox@Wilcox-Tech.com>
Suggested-by: Sam James <sam@gentoo.org>
---
tests/ts/enosys/enosys | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tests/ts/enosys/enosys b/tests/ts/enosys/enosys
index 591b292a8..698283056 100755
--- a/tests/ts/enosys/enosys
+++ b/tests/ts/enosys/enosys
@@ -20,6 +20,12 @@ TS_DESC="enosys"
. "$TS_TOPDIR"/functions.sh
ts_init "$*"
+function ts_canonicalise_strerror {
+ sed -Ei -e 's/Out of memory/Cannot allocate memory/g' \
+ -e 's/Not a tty/Inappropriate ioctl for device/g' \
+ -e 's/No error information/Success/g' $1
+}
+
ts_check_test_command "$TS_HELPER_ENOSYS"
ts_check_enosys_syscalls fallocate fsopen execve
@@ -34,6 +40,8 @@ $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
"$TS_CMD_ENOSYS" --syscall fallocate:12 $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
"$TS_CMD_ENOSYS" --syscall fallocate:ENOMEM $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+ts_canonicalise_strerror "$TS_OUTPUT"
+
ts_finalize_subtest
ts_init_subtest exec
@@ -43,6 +51,8 @@ FALLOCATE_TEST="$TS_HELPER_ENOSYS exec"
$FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
"$TS_CMD_ENOSYS" --syscall execve $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+ts_canonicalise_strerror "$TS_OUTPUT"
+
ts_finalize_subtest
ts_init_subtest ioctl
@@ -57,6 +67,8 @@ $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
"$TS_CMD_ENOSYS" --ioctl FIOCLEX:12 $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
"$TS_CMD_ENOSYS" --ioctl FIOCLEX:ENOMEM $FALLOCATE_TEST > /dev/null 2>> "$TS_OUTPUT"
+ts_canonicalise_strerror "$TS_OUTPUT"
+
ts_finalize_subtest
ts_finalize
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] test_enosys: Handle musl libc error strings
2026-03-23 3:03 [PATCH] test_enosys: Handle musl libc error strings Anna Wilcox
@ 2026-03-23 13:32 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2026-03-23 13:32 UTC (permalink / raw)
To: Anna Wilcox; +Cc: util-linux, Sam James
On Sun, Mar 22, 2026 at 10:03:52PM -0500, Anna Wilcox wrote:
> strerror(3) on musl gives different strings for some of the errnos we
> test for, so the tests incorrectly fail on musl. Change the strings
> back into the glibc ones so they match the expected values properly.
>
> Signed-off-by: Anna Wilcox <AWilcox@Wilcox-Tech.com>
> Suggested-by: Sam James <sam@gentoo.org>
> ---
> tests/ts/enosys/enosys | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/tests/ts/enosys/enosys b/tests/ts/enosys/enosys
> index 591b292a8..698283056 100755
> --- a/tests/ts/enosys/enosys
> +++ b/tests/ts/enosys/enosys
> @@ -20,6 +20,12 @@ TS_DESC="enosys"
> . "$TS_TOPDIR"/functions.sh
> ts_init "$*"
>
> +function ts_canonicalise_strerror {
> + sed -Ei -e 's/Out of memory/Cannot allocate memory/g' \
> + -e 's/Not a tty/Inappropriate ioctl for device/g' \
> + -e 's/No error information/Success/g' $1
> +}
For something like this we already use
tests/helpers/test_strerror.c
for example (git grep result):
tests/ts/fdisk/oddinput:ts_check_test_command "$TS_HELPER_STRERROR"
tests/ts/fdisk/oddinput:sed -i -e "s@$($TS_HELPER_STRERROR ENOENT)@ENOENT@" $TS_OUTPUT $TS_ERRLOG
tests/ts/fdisk/oddinput:sed -i -e "s@$($TS_HELPER_STRERROR EINVAL)@EINVAL@" $TS_OUTPUT $TS_ERRLOG
It replaces the error message with the errno abbreviation.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-23 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 3:03 [PATCH] test_enosys: Handle musl libc error strings Anna Wilcox
2026-03-23 13:32 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox