]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (test_sysinfo) add helper for invalid ioctl errno
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 30 Apr 2023 08:18:20 +0000 (10:18 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 30 Apr 2023 22:54:23 +0000 (00:54 +0200)
This can be used to detect qemu-user returning ENOSYS for invalid ioctl
numbers.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tests/functions.sh
tests/helpers/test_sysinfo.c

index 3d2c93d77af34885cc0c744409069fe13c815128..71d716781efd3e6f1c9076c2b4848c65ad4e97ca 100644 (file)
@@ -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)"
 }
index ef7515c120288cc4c0d589cb5ee8227c50b13756..82227ca3f2589972c397f04a0ed48ccacdbb14af 100644 (file)
@@ -24,6 +24,8 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <wchar.h>
+#include <errno.h>
+#include <sys/ioctl.h>
 
 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 }
 };