@@ -11,5 +11,6 @@ ptem02 ptem02
ptem03 ptem03
ptem04 ptem04
ptem05 ptem05
+ptem06 ptem06
hangup01 hangup01
@@ -4,6 +4,7 @@
/ptem03
/ptem04
/ptem05
+/ptem06
/pty01
/pty02
/pty03
new file mode 100644
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) International Business Machines Corp., 2002
+ * Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, to obtain
+ * a slave device and to set baudrate to B0 (which means hang up).
+ */
+
+#define _GNU_SOURCE
+
+#include <termios.h>
+#include "tst_test.h"
+
+#define MASTERCLONE "/dev/ptmx"
+
+static void run(void)
+{
+ int masterfd, slavefd;
+ struct termios termios;
+ char *slavename;
+
+ masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR);
+
+ slavename = ptsname(masterfd);
+ if (slavename == NULL)
+ tst_res(TFAIL, "Can't get slave device location");
+ else
+ tst_res(TPASS, "pts device location is %s", slavename);
+
+ TST_EXP_PASS(grantpt(masterfd));
+ TST_EXP_PASS(unlockpt(masterfd));
+
+ slavefd = SAFE_OPEN(slavename, O_RDWR);
+
+ TST_EXP_PASS(ioctl(slavefd, TCGETS, &termios));
+ termios.c_cflag &= ~CBAUD;
+ termios.c_cflag |= B0 & CBAUD;
+ TST_EXP_PASS(ioctl(slavefd, TCSETS, &termios));
+
+ SAFE_CLOSE(slavefd);
+ SAFE_CLOSE(masterfd);
+}
+
+static void setup(void)
+{
+ if (access(MASTERCLONE, F_OK))
+ tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+};