Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/librumpclient test FD_CLOEXEC
details: https://anonhg.NetBSD.org/src/rev/0f0d1463a202
branches: trunk
changeset: 762097:0f0d1463a202
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Feb 15 15:54:56 2011 +0000
description:
test FD_CLOEXEC
diffstat:
tests/lib/librumpclient/h_exec.c | 17 ++++++++++++-----
tests/lib/librumpclient/t_exec.sh | 26 +++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 6 deletions(-)
diffs (86 lines):
diff -r c4578935f721 -r 0f0d1463a202 tests/lib/librumpclient/h_exec.c
--- a/tests/lib/librumpclient/h_exec.c Tue Feb 15 15:54:28 2011 +0000
+++ b/tests/lib/librumpclient/h_exec.c Tue Feb 15 15:54:56 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_exec.c,v 1.1 2011/02/15 15:16:46 pooka Exp $ */
+/* $NetBSD: h_exec.c,v 1.2 2011/02/15 15:54:56 pooka Exp $ */
/*
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -56,10 +56,10 @@
if (argc > 1) {
if (strcmp(argv[1], "_didexec") == 0) {
daemon(0, 0); /* detach-me-notnot ergo detach */
- s1 = atoi(argv[2]);
+ s2 = atoi(argv[2]);
slen = sizeof(sin);
/* see below */
- accept(s1, (struct sockaddr *)&sin, &slen);
+ accept(s2, (struct sockaddr *)&sin, &slen);
}
}
@@ -92,11 +92,18 @@
* "pause()", but conveniently gets rid of this helper
* since we were called with RUMPCLIENT_RETRYCONN_DIE set
*/
- accept(s1, (struct sockaddr *)&sin, &slen);
+ accept(s2, (struct sockaddr *)&sin, &slen);
+ }
+
+ if (argc == 3 && strcmp(argv[2], "cloexec1") == 0) {
+ if (fcntl(s1, F_SETFD, FD_CLOEXEC) == -1) {
+ fprintf(stderr, "repomies jumalauta %d!\n", errno);
+ err(1, "cloexec failed");
+ }
}
/* omstart! */
- sprintf(buf, "%d", s1);
+ sprintf(buf, "%d", s2);
if (execl(argv[1], "h_ution", "_didexec", buf, NULL) == -1)
err(1, "exec");
}
diff -r c4578935f721 -r 0f0d1463a202 tests/lib/librumpclient/t_exec.sh
--- a/tests/lib/librumpclient/t_exec.sh Tue Feb 15 15:54:28 2011 +0000
+++ b/tests/lib/librumpclient/t_exec.sh Tue Feb 15 15:54:56 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_exec.sh,v 1.1 2011/02/15 15:16:46 pooka Exp $
+# $NetBSD: t_exec.sh,v 1.2 2011/02/15 15:54:56 pooka Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -77,9 +77,33 @@
rump.halt
}
+atf_test_case cloexec cleanup
+cloexec_head()
+{
+ atf_set "descr" "check that FD_CLOEXEC works"
+}
+
+cloexec_body()
+{
+
+ atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
+ atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+ $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_ution cloexec1
+ atf_check -s exit:0 -o save:sstat.out rump.sockstat
+ atf_check -s exit:0 -o inline:'2\n' sed -n '$=' sstat.out
+ atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.2345' \
+ sed -n 2p sstat.out
+}
+
+cloexec_cleanup()
+{
+ rump.halt
+}
+
atf_init_test_cases()
{
atf_add_test_case noexec
atf_add_test_case exec
+ atf_add_test_case cloexec
}
Home |
Main Index |
Thread Index |
Old Index