Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/rump/rumpkern test rumpclient syscalls from a signal h...



details:   https://anonhg.NetBSD.org/src/rev/96bfb834bf9f
branches:  trunk
changeset: 760496:96bfb834bf9f
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Jan 06 07:00:28 2011 +0000

description:
test rumpclient syscalls from a signal handler

diffstat:

 tests/rump/rumpkern/h_client/Makefile   |   3 +-
 tests/rump/rumpkern/h_client/h_sigcli.c |  65 +++++++++++++++++++++++++++++++++
 tests/rump/rumpkern/t_sp.sh             |  12 +++++-
 3 files changed, 78 insertions(+), 2 deletions(-)

diffs (124 lines):

diff -r a6d00c37bfcd -r 96bfb834bf9f tests/rump/rumpkern/h_client/Makefile
--- a/tests/rump/rumpkern/h_client/Makefile     Thu Jan 06 06:59:25 2011 +0000
+++ b/tests/rump/rumpkern/h_client/Makefile     Thu Jan 06 07:00:28 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.3 2011/01/05 17:19:09 pooka Exp $
+#      $NetBSD: Makefile,v 1.4 2011/01/06 07:00:28 pooka Exp $
 #
 
 .include <bsd.own.mk>
@@ -6,6 +6,7 @@
 TESTSDIR=      ${TESTSBASE}/rump/rumpkern/h_client
 
 TESTS_C+=      h_forkcli
+TESTS_C+=      h_sigcli
 TESTS_C+=      h_simplecli
 TESTS_C+=      h_stresscli
 
diff -r a6d00c37bfcd -r 96bfb834bf9f tests/rump/rumpkern/h_client/h_sigcli.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/rump/rumpkern/h_client/h_sigcli.c   Thu Jan 06 07:00:28 2011 +0000
@@ -0,0 +1,65 @@
+/*     $NetBSD: h_sigcli.c,v 1.1 2011/01/06 07:00:28 pooka Exp $       */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <err.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <rump/rump_syscalls.h>
+#include <rump/rumpclient.h>
+
+static const int hostnamemib[] = { CTL_KERN, KERN_HOSTNAME };
+static char hostnamebuf[128];
+
+static void
+sighand(int sig)
+{
+       char buf[128];
+       size_t blen = sizeof(buf);
+
+       if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
+           buf, &blen, NULL, 0) == -1)
+               err(1, "sighand sysctl");
+       if (strcmp(buf, hostnamebuf) != 0)
+               errx(1, "sighandler hostname");
+}
+
+int
+main(void)
+{
+       char buf[128];
+       struct itimerval itv;
+       size_t hnbsize;
+       int i;
+       size_t blen;
+
+       if (rumpclient_init() == -1)
+               err(1, "rumpclient init");
+
+       hnbsize = sizeof(hostnamebuf);
+       if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
+           hostnamebuf, &hnbsize, NULL, 0) == -1)
+               err(1, "sysctl");
+
+       if (signal(SIGALRM, sighand) == SIG_ERR)
+               err(1, "signal");
+
+       itv.it_interval.tv_sec = itv.it_value.tv_sec = 0;
+       itv.it_interval.tv_usec = itv.it_value.tv_usec = 10000; /* 10ms */
+
+       if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
+               err(1, "itimer");
+
+       for (i = 0; i < 20000; i++) {
+               blen = sizeof(buf);
+               if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
+                   buf, &blen, NULL, 0) == -1)
+                       err(1, "sysctl");
+               if (strcmp(buf, hostnamebuf) != 0)
+                       errx(1, "main hostname");
+       }
+}
diff -r a6d00c37bfcd -r 96bfb834bf9f tests/rump/rumpkern/t_sp.sh
--- a/tests/rump/rumpkern/t_sp.sh       Thu Jan 06 06:59:25 2011 +0000
+++ b/tests/rump/rumpkern/t_sp.sh       Thu Jan 06 07:00:28 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_sp.sh,v 1.4 2011/01/05 17:19:09 pooka Exp $
+#      $NetBSD: t_sp.sh,v 1.5 2011/01/06 07:00:28 pooka Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -46,6 +46,7 @@
 test_case fork_simple fork simple
 test_case fork_pipecomm fork pipecomm
 test_case fork_fakeauth fork fakeauth
+test_case sigsafe sigsafe sigsafe
 
 basic()
 {
@@ -70,6 +71,14 @@
        atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_forkcli ${1}
 }
 
+sigsafe()
+{
+
+       export RUMP_SERVER=unix://commsock
+       atf_check -s exit:0 rump_server ${RUMP_SERVER}
+       atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_sigcli
+}
+
 atf_init_test_cases()
 {
 
@@ -79,4 +88,5 @@
        atf_add_test_case fork_simple
        atf_add_test_case fork_pipecomm
        atf_add_test_case fork_fakeauth
+       atf_add_test_case sigsafe
 }



Home | Main Index | Thread Index | Old Index