Module Name:    src
Committed By:   riastradh
Date:           Sun Feb  9 17:09:51 UTC 2025

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

Log Message:
t_poll: Make sure POLLOUT is clear when testing POLLHUP.

POLLOUT and POLLHUP are mutually exclusive in POSIX.  Also, we're
only polling for POLLIN anyway.

PR kern/59056: poll POLLHUP bugs


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.8 src/tests/lib/libc/sys/t_poll.c:1.9
--- src/tests/lib/libc/sys/t_poll.c:1.8	Sat Oct  2 17:32:55 2021
+++ src/tests/lib/libc/sys/t_poll.c	Sun Feb  9 17:09:51 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_poll.c,v 1.8 2021/10/02 17:32:55 thorpej Exp $	*/
+/*	$NetBSD: t_poll.c,v 1.9 2025/02/09 17:09:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -385,7 +385,9 @@ ATF_TC_BODY(fifo_hup1, tc)
 	(void)close(wfd);
 
 	ATF_REQUIRE(poll(&pfd, 1, 0) == 1);
-	ATF_REQUIRE((pfd.revents & POLLHUP) != 0);
+	ATF_REQUIRE_EQ_MSG((pfd.revents & (POLLHUP|POLLOUT)), POLLHUP,
+	    "revents=0x%x expected POLLHUP=0x%x and not POLLOUT=0x%x",
+	    pfd.revents, POLLHUP, POLLOUT);
 
 	/*
 	 * Check that POLLHUP is cleared when a writer re-connects.
@@ -447,7 +449,9 @@ ATF_TC_BODY(fifo_hup2, tc)
 	/* Make sure at least a couple of seconds have elapsed. */
 	ATF_REQUIRE(ts2.tv_sec - ts1.tv_sec >= 2);
 
-	ATF_REQUIRE((pfd.revents & POLLHUP) != 0);
+	ATF_REQUIRE_EQ_MSG((pfd.revents & (POLLHUP|POLLOUT)), POLLHUP,
+	    "revents=0x%x expected POLLHUP=0x%x and not POLLOUT=0x%x",
+	    pfd.revents, POLLHUP, POLLOUT);
 }
 
 ATF_TC_CLEANUP(fifo_hup2, tc)

Reply via email to