summaryrefslogtreecommitdiff
path: root/tests/lib/libc
diff options
context:
space:
mode:
authorgutteridge <gutteridge@NetBSD.org>2023-05-17 03:16:11 +0000
committergutteridge <gutteridge@NetBSD.org>2023-05-17 03:16:11 +0000
commit5c8b2a46bbfaeb4359e4603ebe23bd61d845c907 (patch)
tree8a0bc6abe25ed3ff1f3f8bad4c3fccfeba170dd4 /tests/lib/libc
parentb2b2e5fee1c684e58ad248ac35bfc47b0e4e9937 (diff)
t_ptm.c: add a test case that passes extra flags
Validate that O_NONBLOCK and O_CLOEXEC are actually set by posix_openpt(3), as until circa 9.99.101 they were not. If/when other flags are added like close-on-fork, this test could be adjusted. The current concern is with supporting the expectations of components like vte3, used by various graphical terminal clients.
Diffstat (limited to 'tests/lib/libc')
-rw-r--r--tests/lib/libc/ttyio/t_ptm.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/lib/libc/ttyio/t_ptm.c b/tests/lib/libc/ttyio/t_ptm.c
index 5346898bdfc..4428ee33893 100644
--- a/tests/lib/libc/ttyio/t_ptm.c
+++ b/tests/lib/libc/ttyio/t_ptm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptm.c,v 1.1 2011/01/13 03:19:57 pgoyette Exp $ */
+/* $NetBSD: t_ptm.c,v 1.2 2023/05/17 03:16:11 gutteridge Exp $ */
/*
* Copyright (c) 2004, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_ptm.c,v 1.1 2011/01/13 03:19:57 pgoyette Exp $");
+__RCSID("$NetBSD: t_ptm.c,v 1.2 2023/05/17 03:16:11 gutteridge Exp $");
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -164,11 +164,37 @@ ATF_TC_BODY(ptmx, tc)
ATF_REQUIRE_EQ_MSG(sts.st_gid, gp->gr_gid, "bad slave gid");
}
+ATF_TC(ptmx_extra);
+
+ATF_TC_HEAD(ptmx_extra, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Checks /dev/ptmx device "
+ "applies O_NONBLOCK and O_CLOEXEC");
+}
+
+ATF_TC_BODY(ptmx_extra, tc)
+{
+ int fdm;
+
+ if ((fdm = posix_openpt(O_RDWR|O_NOCTTY|O_NONBLOCK|O_CLOEXEC)) == -1) {
+ if (errno == ENOENT || errno == ENODEV)
+ atf_tc_skip("/dev/ptmx: %s", strerror(errno));
+
+ atf_tc_fail("/dev/ptmx: %s", strerror(errno));
+ }
+
+ /* O_NOCTTY is ignored, not set. */
+ ATF_CHECK_EQ(O_RDWR|O_NONBLOCK, fcntl(fdm, F_GETFL));
+ ATF_CHECK_EQ(FD_CLOEXEC, fcntl(fdm, F_GETFD));
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, ptm);
ATF_TP_ADD_TC(tp, ptmx);
+ ATF_TP_ADD_TC(tp, ptmx_extra);
return atf_no_error();
}