[PATCH] test_enosys: Handle musl libc error strings

Anna Wilcox <[email protected]> Sun, 22 Mar 2026 22:03:52 -0500
Newsgroups org.kernel.vger.util-linux
Message-ID <[email protected]>
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 <[email protected]>
Suggested-by: Sam James <[email protected]>
---
 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