Module Name:    src
Committed By:   thorpej
Date:           Sat Oct  2 14:41:36 UTC 2021

Modified Files:
        src/tests/lib/libc/sys: t_poll.c

Log Message:
In the fifo_hup1 test, also ensure that POLLHUP is de-asserted when a
new writer appears.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_poll.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_poll.c
diff -u src/tests/lib/libc/sys/t_poll.c:1.5 src/tests/lib/libc/sys/t_poll.c:1.6
--- src/tests/lib/libc/sys/t_poll.c:1.5	Sat Oct  2 02:07:41 2021
+++ src/tests/lib/libc/sys/t_poll.c	Sat Oct  2 14:41:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_poll.c,v 1.5 2021/10/02 02:07:41 thorpej Exp $	*/
+/*	$NetBSD: t_poll.c,v 1.6 2021/10/02 14:41:36 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -278,6 +278,18 @@ ATF_TC_BODY(fifo_hup1, tc)
 
 	ATF_REQUIRE(poll(&pfd, 1, 0) == 1);
 	ATF_REQUIRE((pfd.revents & POLLHUP) != 0);
+
+	/*
+	 * Check that POLLHUP is cleared when a writer re-connects.
+	 * Since the writer will not put any data into the FIFO, we
+	 * expect no events.
+	 */
+	memset(&pfd, 0, sizeof(pfd));
+	pfd.fd = rfd;
+	pfd.events = POLLIN;
+
+	ATF_REQUIRE((wfd = open(fifo_path, O_WRONLY)) >= 0);
+	ATF_REQUIRE(poll(&pfd, 1, 0) == 0);
 }
 
 ATF_TC_CLEANUP(fifo_hup1, tc)

Reply via email to