Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib Add test which checks rumpclient does not use fds ...
details: https://anonhg.NetBSD.org/src/rev/a490a6596a30
branches: trunk
changeset: 761858:a490a6596a30
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Feb 09 14:32:45 2011 +0000
description:
Add test which checks rumpclient does not use fds 0-2 for its
internal purposes.
diffstat:
tests/lib/Makefile | 4 +-
tests/lib/librumpclient/Makefile | 12 +++++
tests/lib/librumpclient/t_fd.c | 92 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 2 deletions(-)
diffs (127 lines):
diff -r fcd1c1ba1dde -r a490a6596a30 tests/lib/Makefile
--- a/tests/lib/Makefile Wed Feb 09 14:29:58 2011 +0000
+++ b/tests/lib/Makefile Wed Feb 09 14:32:45 2011 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.11 2011/02/06 18:44:29 pooka Exp $
+# $NetBSD: Makefile,v 1.12 2011/02/09 14:32:45 pooka Exp $
.include <bsd.own.mk>
TESTS_SUBDIRS= csu libc libm libevent libobjc libposix libprop librt \
- libpthread librumphijack libutil semaphore
+ libpthread librumpclient librumphijack libutil semaphore
.if ${MKCRYPTO} != "no"
TESTS_SUBDIRS+= libdes
diff -r fcd1c1ba1dde -r a490a6596a30 tests/lib/librumpclient/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/librumpclient/Makefile Wed Feb 09 14:32:45 2011 +0000
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1 2011/02/09 14:32:45 pooka Exp $
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/lib/librumpclient
+
+TESTS_C= t_fd
+
+LDADD+= -lrumpclient
+
+.include <bsd.test.mk>
diff -r fcd1c1ba1dde -r a490a6596a30 tests/lib/librumpclient/t_fd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/librumpclient/t_fd.c Wed Feb 09 14:32:45 2011 +0000
@@ -0,0 +1,92 @@
+/* $NetBSD: t_fd.c,v 1.1 2011/02/09 14:32:45 pooka Exp $ */
+
+/*
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <atf-c.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <rump/rumpclient.h>
+#include <rump/rump_syscalls.h>
+
+#include "../../h_macros.h"
+
+ATF_TC_WITH_CLEANUP(bigenough);
+ATF_TC_HEAD(bigenough, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that rumpclient uses "
+ "fd > 2");
+}
+
+#define RUMPSERV "unix://sucket"
+
+ATF_TC_BODY(bigenough, tc)
+{
+ struct stat sb;
+
+ RZ(system("rump_server " RUMPSERV));
+ RL(setenv("RUMP_SERVER", RUMPSERV, 1));
+
+ RL(dup2(0, 10));
+ RL(dup2(1, 11));
+ RL(dup2(2, 12));
+
+ RL(close(0));
+ RL(close(1));
+ RL(close(2));
+
+ RL(rumpclient_init());
+ RL(rump_sys_getpid());
+
+ ATF_REQUIRE_ERRNO(EBADF, fstat(0, &sb) == -1);
+ ATF_REQUIRE_ERRNO(EBADF, fstat(1, &sb) == -1);
+ ATF_REQUIRE_ERRNO(EBADF, fstat(2, &sb) == -1);
+
+ RL(rump_sys_getpid());
+
+ /* restore these. does it help? */
+ dup2(10, 0);
+ dup2(11, 1);
+ dup2(12, 2);
+}
+
+ATF_TC_CLEANUP(bigenough, tc)
+{
+
+ system("env RUMP_SERVER=" RUMPSERV " rump.halt");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, bigenough);
+
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index