test_enosys: Handle musl libc error strings
PATCH 1/1 test_enosys: Handle musl libc error strings
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.
--- tests/ts/enosys/enosys | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tests/ts/enosys/enosys +12 -0
@@ -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
Signature · 1 line
2.52.0
Karel Zak
maintainerQuoted 15 lines · Anna Wilcox
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(+)tests/ts/enosys/enosys +0
-0
tests/ts/enosys/enosys TS_DESC="enosys" · line 27
Quoted 8 lines
tests/ts/enosys/enosys +5
-0@@ -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
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com