Module Name: src Committed By: pooka Date: Thu Jan 6 07:00:28 UTC 2011
Modified Files: src/tests/rump/rumpkern: t_sp.sh src/tests/rump/rumpkern/h_client: Makefile Added Files: src/tests/rump/rumpkern/h_client: h_sigcli.c Log Message: test rumpclient syscalls from a signal handler To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/rump/rumpkern/t_sp.sh cvs rdiff -u -r1.3 -r1.4 src/tests/rump/rumpkern/h_client/Makefile cvs rdiff -u -r0 -r1.1 src/tests/rump/rumpkern/h_client/h_sigcli.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/rump/rumpkern/t_sp.sh diff -u src/tests/rump/rumpkern/t_sp.sh:1.4 src/tests/rump/rumpkern/t_sp.sh:1.5 --- src/tests/rump/rumpkern/t_sp.sh:1.4 Wed Jan 5 17:19:09 2011 +++ src/tests/rump/rumpkern/t_sp.sh Thu Jan 6 07:00:28 2011 @@ -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 } Index: src/tests/rump/rumpkern/h_client/Makefile diff -u src/tests/rump/rumpkern/h_client/Makefile:1.3 src/tests/rump/rumpkern/h_client/Makefile:1.4 --- src/tests/rump/rumpkern/h_client/Makefile:1.3 Wed Jan 5 17:19:09 2011 +++ src/tests/rump/rumpkern/h_client/Makefile Thu Jan 6 07:00:28 2011 @@ -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 Added files: Index: src/tests/rump/rumpkern/h_client/h_sigcli.c diff -u /dev/null src/tests/rump/rumpkern/h_client/h_sigcli.c:1.1 --- /dev/null Thu Jan 6 07:00:28 2011 +++ src/tests/rump/rumpkern/h_client/h_sigcli.c Thu Jan 6 07:00:28 2011 @@ -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"); + } +}