From: Thomas Weißschuh Date: Sun, 30 Apr 2023 08:18:20 +0000 (+0200) Subject: tests: (test_sysinfo) add helper for invalid ioctl errno X-Git-Tag: v2.39~39^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eefdc51113c50798f7b332e9dc48c6631ec9c841;p=thirdparty%2Futil-linux.git tests: (test_sysinfo) add helper for invalid ioctl errno This can be used to detect qemu-user returning ENOSYS for invalid ioctl numbers. Signed-off-by: Thomas Weißschuh --- diff --git a/tests/functions.sh b/tests/functions.sh index 3d2c93d77a..71d716781e 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -137,6 +137,15 @@ function ts_check_native_byteorder { fi } +function ts_check_enotty { + # https://lore.kernel.org/qemu-devel/20230426070659.80649-1-thomas@t-8ch.de/ + if [ -e "$TS_HELPER_SYSINFO" ] && + [ "$("$TS_HELPER_SYSINFO" enotty-ok)" = "0" ]; then + + ts_skip "broken ENOTTY return" + fi +} + function ts_report_skip { ts_report " SKIPPED ($1)" } diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c index ef7515c120..82227ca3f2 100644 --- a/tests/helpers/test_sysinfo.c +++ b/tests/helpers/test_sysinfo.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include typedef struct { const char *name; @@ -99,6 +101,15 @@ static int hlp_wcsspn_ok(void) return 0; } +static int hlp_enotty_ok(void) +{ + errno = 0; + ioctl(STDOUT_FILENO, 0); + + printf("%d\n", errno != ENOSYS); + return 0; +} + static mntHlpfnc hlps[] = { { "WORDSIZE", hlp_wordsize }, @@ -111,6 +122,7 @@ static mntHlpfnc hlps[] = { "UINT64_MAX", hlp_u64_max }, { "byte-order", hlp_endianness }, { "wcsspn-ok", hlp_wcsspn_ok }, + { "enotty-ok", hlp_enotty_ok }, { NULL, NULL } };