[LTP] [PATCH] pty04: Check for ioctl(TIOCVHANGUP) support

Martin Doucha mdoucha@suse.cz
Fri Dec 1 15:26:30 CET 2023


TIOCVHANGUP support in 32bit compat mode ioctl() was added in kernel
v4.20. The syscall will fail on earlier kernels with ENOTTY.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/pty/pty04.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/testcases/kernel/pty/pty04.c b/testcases/kernel/pty/pty04.c
index 8c7b1bf92..204703253 100644
--- a/testcases/kernel/pty/pty04.c
+++ b/testcases/kernel/pty/pty04.c
@@ -93,6 +93,19 @@ static struct ldisc_info ldiscs[] = {
 
 static int ptmx = -1, pts = -1, sk = -1, mtu, no_check;
 
+static void setup(void)
+{
+	int fd = SAFE_OPEN("/dev/ptmx", O_RDWR);
+
+	TEST(ioctl(fd, TIOCVHANGUP));
+	SAFE_CLOSE(fd);
+
+	if (TST_RET && TST_ERR == ENOTTY)
+		tst_brk(TCONF | TTERRNO, "ioctl(TIOCVHANGUP) not supported");
+	else if (TST_RET)
+		tst_brk(TBROK | TTERRNO, "ioctl(TIOCVHANGUP) failed");
+}
+
 static int set_ldisc(int tty, const struct ldisc_info *ldisc)
 {
 	TEST(ioctl(tty, TIOCSETD, &ldisc->n));
@@ -467,6 +480,7 @@ static void cleanup(void)
 }
 
 static struct tst_test test = {
+	.setup = setup,
 	.test = do_test,
 	.cleanup = cleanup,
 	.tcnt = 2,
-- 
2.42.1



More information about the ltp mailing list