Module Name:    src
Committed By:   pooka
Date:           Sun Feb 20 23:45:46 UTC 2011

Modified Files:
        src/tests/lib/librumphijack: h_client.c t_asyncio.sh

Log Message:
check that poll on an invalid fd doesn't hang in the dual poll case


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/librumphijack/h_client.c \
    src/tests/lib/librumphijack/t_asyncio.sh

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/librumphijack/h_client.c
diff -u src/tests/lib/librumphijack/h_client.c:1.2 src/tests/lib/librumphijack/h_client.c:1.3
--- src/tests/lib/librumphijack/h_client.c:1.2	Sat Feb 12 10:28:08 2011
+++ src/tests/lib/librumphijack/h_client.c	Sun Feb 20 23:45:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_client.c,v 1.2 2011/02/12 10:28:08 pooka Exp $	*/
+/*	$NetBSD: h_client.c,v 1.3 2011/02/20 23:45:46 pooka Exp $	*/
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -28,10 +28,12 @@
  */
 
 #include <sys/types.h>
+#include <sys/poll.h>
 #include <sys/select.h>
 
 #include <err.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -88,6 +90,26 @@
 			errx(1, "select2 succesful");
 
 		exit(0);
+	} else if (strcmp(argv[1], "invafd") == 0) {
+		struct pollfd pfd[2];
+		int fd;
+
+		fd = open("/rump/dev/null", O_RDWR);
+		if (fd == -1)
+			err(1, "open");
+		close(fd);
+
+		pfd[0].fd = STDIN_FILENO;
+		pfd[0].events = POLLIN;
+		pfd[1].fd = fd;
+		pfd[1].events = POLLIN;
+
+		if (poll(pfd, 2, INFTIM) != 1)
+			errx(1, "poll unexpected rv");
+		if (pfd[1].revents != POLLNVAL || pfd[0].revents != 0)
+			errx(1, "poll unexpected revents");
+
+		exit(0);
 	} else {
 		return ENOTSUP;
 	}
Index: src/tests/lib/librumphijack/t_asyncio.sh
diff -u src/tests/lib/librumphijack/t_asyncio.sh:1.2 src/tests/lib/librumphijack/t_asyncio.sh:1.3
--- src/tests/lib/librumphijack/t_asyncio.sh:1.2	Sat Feb 12 10:28:08 2011
+++ src/tests/lib/librumphijack/t_asyncio.sh	Sun Feb 20 23:45:46 2011
@@ -1,4 +1,4 @@
-#       $NetBSD: t_asyncio.sh,v 1.2 2011/02/12 10:28:08 pooka Exp $
+#       $NetBSD: t_asyncio.sh,v 1.3 2011/02/20 23:45:46 pooka Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -66,8 +66,29 @@
 	rump.halt
 }
 
+atf_test_case invafd cleanup
+invafd_head()
+{
+        atf_set "descr" "poll on invalid rump fd"
+	atf_set "timeout" "4"
+}
+
+invafd_body()
+{
+
+	atf_check -s exit:0 rump_server -lrumpvfs ${RUMP_SERVER}
+	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+	    $(atf_get_srcdir)/h_client invafd
+}
+
+invafd_cleanup()
+{
+	rump.halt
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case select_timeout
 	atf_add_test_case select_allunset
+	atf_add_test_case invafd
 }

Reply via email to