Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/librumphijack check that poll on an invalid fd doe...
details: https://anonhg.NetBSD.org/src/rev/338efae6bd6a
branches: trunk
changeset: 762436:338efae6bd6a
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Feb 20 23:45:46 2011 +0000
description:
check that poll on an invalid fd doesn't hang in the dual poll case
diffstat:
tests/lib/librumphijack/h_client.c | 24 +++++++++++++++++++++++-
tests/lib/librumphijack/t_asyncio.sh | 23 ++++++++++++++++++++++-
2 files changed, 45 insertions(+), 2 deletions(-)
diffs (88 lines):
diff -r f7e5ed2ba425 -r 338efae6bd6a tests/lib/librumphijack/h_client.c
--- a/tests/lib/librumphijack/h_client.c Sun Feb 20 23:12:09 2011 +0000
+++ b/tests/lib/librumphijack/h_client.c Sun Feb 20 23:45:46 2011 +0000
@@ -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;
}
diff -r f7e5ed2ba425 -r 338efae6bd6a tests/lib/librumphijack/t_asyncio.sh
--- a/tests/lib/librumphijack/t_asyncio.sh Sun Feb 20 23:12:09 2011 +0000
+++ b/tests/lib/librumphijack/t_asyncio.sh Sun Feb 20 23:45:46 2011 +0000
@@ -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
}
Home |
Main Index |
Thread Index |
Old Index