CVS commit: src/tests/dev/md
Module Name:src Committed By: he Date: Mon Jun 9 18:22:05 UTC 2014 Modified Files: src/tests/dev/md: Makefile Log Message: When linking statically (as for sun2), need to list -lrump also after -lrumpuser, because rump_pub_lwproc_switch is used in the latter and defined in the former. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/dev/md/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/md/Makefile diff -u src/tests/dev/md/Makefile:1.3 src/tests/dev/md/Makefile:1.4 --- src/tests/dev/md/Makefile:1.3 Sun Dec 2 18:39:53 2012 +++ src/tests/dev/md/Makefile Mon Jun 9 18:22:05 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2012/12/02 18:39:53 pgoyette Exp $ +# $NetBSD: Makefile,v 1.4 2014/06/09 18:22:05 he Exp $ # .include bsd.own.mk @@ -16,6 +16,7 @@ PROGS= h_mdserv LDADD+= -lrumpdev_md -lrumpdev_disk -lrumpdev -lrumpvfs LDADD+= -lrump LDADD+= -lrumpuser +LDADD+= -lrump LDADD+= -lpthread WARNS= 4
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Thu Feb 10 13:29:03 UTC 2011 Modified Files: src/tests/dev/md: h_mdserv.c Log Message: explicitly zero-fill the initial md backend To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/dev/md/h_mdserv.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/dev/md/h_mdserv.c diff -u src/tests/dev/md/h_mdserv.c:1.3 src/tests/dev/md/h_mdserv.c:1.4 --- src/tests/dev/md/h_mdserv.c:1.3 Tue Nov 30 14:31:14 2010 +++ src/tests/dev/md/h_mdserv.c Thu Feb 10 13:29:02 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: h_mdserv.c,v 1.3 2010/11/30 14:31:14 pooka Exp $ */ +/* $NetBSD: h_mdserv.c,v 1.4 2011/02/10 13:29:02 pooka Exp $ */ #include sys/types.h #include sys/mman.h @@ -70,7 +70,7 @@ if (argc != 2) exit(1); - md.md_addr = malloc(MDSIZE); + md.md_addr = calloc(1, MDSIZE); md.md_size = MDSIZE; md.md_type = MD_UMEM_SERVER;
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Mon Jan 3 09:39:46 UTC 2011 Modified Files: src/tests/dev/md: t_md.sh Log Message: use rawpart To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/dev/md/t_md.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/md/t_md.sh diff -u src/tests/dev/md/t_md.sh:1.4 src/tests/dev/md/t_md.sh:1.5 --- src/tests/dev/md/t_md.sh:1.4 Sun Dec 12 12:49:59 2010 +++ src/tests/dev/md/t_md.sh Mon Jan 3 09:39:46 2011 @@ -1,4 +1,4 @@ -# $NetBSD: t_md.sh,v 1.4 2010/12/12 12:49:59 pooka Exp $ +# $NetBSD: t_md.sh,v 1.5 2011/01/03 09:39:46 pooka Exp $ # # Copyright (c) 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,6 +25,9 @@ # POSSIBILITY OF SUCH DAMAGE. # +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawmd=/dev/rmd0${rawpart} + atf_test_case basic cleanup basic_head() { @@ -39,11 +42,11 @@ # but just let it slide for now, since they *should* be the same. rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` - atf_check -s exit:0 $(atf_get_srcdir)/h_mdserv /dev/rmd0${rawpart} + atf_check -s exit:0 $(atf_get_srcdir)/h_mdserv ${rawmd} export RUMP_SERVER=unix://commsock - atf_check -s exit:0 -e ignore dd if=/bin/ls rof=/dev/rmd0d seek=100 count=10 - atf_check -s exit:0 -e ignore dd of=testfile rif=/dev/rmd0d skip=100 count=10 + atf_check -s exit:0 -e ignore dd if=/bin/ls rof=${rawmd} seek=100 count=10 + atf_check -s exit:0 -e ignore dd of=testfile rif=${rawmd} skip=100 count=10 atf_check -s exit:0 -e ignore -o file:testfile dd if=/bin/ls count=10 }
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Sun Dec 12 12:50:00 UTC 2010 Modified Files: src/tests/dev/md: t_md.sh Log Message: use rump.halt To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/dev/md/t_md.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/md/t_md.sh diff -u src/tests/dev/md/t_md.sh:1.3 src/tests/dev/md/t_md.sh:1.4 --- src/tests/dev/md/t_md.sh:1.3 Tue Nov 30 22:15:02 2010 +++ src/tests/dev/md/t_md.sh Sun Dec 12 12:49:59 2010 @@ -1,4 +1,4 @@ -# $NetBSD: t_md.sh,v 1.3 2010/11/30 22:15:02 pooka Exp $ +# $NetBSD: t_md.sh,v 1.4 2010/12/12 12:49:59 pooka Exp $ # # Copyright (c) 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -50,8 +50,7 @@ basic_cleanup() { - export RUMP_SERVER=unix://commsock - $(atf_get_srcdir)/../../rump/rumpkern/h_client/h_reboot + env RUMP_SERVER=unix://commsock rump.halt } atf_init_test_cases()
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Tue Nov 30 14:29:05 UTC 2010 Modified Files: src/tests/dev/md: h_mdserv.c t_md.sh Log Message: Get rid of the sleep 1 by using rump_daemonize_begin/end(). Notably, md is a little tricky for this, since the ioctl that configures the service also blocks in the kernel. Therefore, use an additional pthread to probe when the service is fully configured and the server can detach. Also, rawpart love. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/dev/md/h_mdserv.c src/tests/dev/md/t_md.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/md/h_mdserv.c diff -u src/tests/dev/md/h_mdserv.c:1.1 src/tests/dev/md/h_mdserv.c:1.2 --- src/tests/dev/md/h_mdserv.c:1.1 Tue Nov 23 15:38:54 2010 +++ src/tests/dev/md/h_mdserv.c Tue Nov 30 14:29:05 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: h_mdserv.c,v 1.1 2010/11/23 15:38:54 pooka Exp $ */ +/* $NetBSD: h_mdserv.c,v 1.2 2010/11/30 14:29:05 pooka Exp $ */ #include sys/types.h #include sys/mman.h @@ -6,28 +6,104 @@ #include dev/md.h +#include err.h +#include errno.h #include fcntl.h +#include pthread.h +#include stdio.h +#include stdlib.h #include unistd.h #include rump/rump.h #include rump/rump_syscalls.h -#include ../../h_macros.h - #define MDSIZE (1024*1024) +#define REQUIRE(a, msg) if ((a) != 0) err(1, msg); + +static void * +prober(void *arg) +{ + int fd, error; + char buf[4]; + ssize_t n; + + fd = rump_sys_open(arg, O_RDONLY); + for (;;) { + n = rump_sys_read(fd, buf, sizeof(buf)); + + switch (n) { + case 4: + error = 0; + goto out; + + case -1: + if (errno == ENXIO) { +usleep(1000); +continue; + } + + /* FALLTHROUGH */ + default: + error = EPIPE; + goto out; + } + } + out: + + error = rump_daemonize_done(error); + REQUIRE(error, rump_daemonize_done); + + if (error) + exit(1); + + return NULL; +} + int -main(void) +main(int argc, char *argv[]) { + pthread_t pt; struct md_conf md; - int fd; + int fd, error; + + if (argc != 2) + exit(1); md.md_addr = malloc(MDSIZE); md.md_size = MDSIZE; md.md_type = MD_UMEM_SERVER; - RL(rump_init()); - RL(fd = rump_sys_open(/dev/rmd0d, O_RDWR)); - RL(rump_sys_ioctl(fd, MD_SETCONF, md)); - pause(); + error = rump_daemonize_begin(); + REQUIRE(error, rump_daemonize_begin); + + error = rump_init(); + REQUIRE(error, rump_init); + + error = rump_init_server(unix://commsock); + REQUIRE(error, init server); + + if ((fd = rump_sys_open(argv[1], O_RDWR)) == -1) + err(1, open); + + /* + * Now, configuring the md driver also causes our process + * to start acting as the worker for the md. Splitting is + * into two steps in the driver is not easy, since md is + * supposed to be unconfigured when the process dies + * (process may exit between calling ioctl1 and ioctl2). + * So, start a probe thread which attempt to read the md + * and declares the md as configured when the read is + * succesful. + */ + error = pthread_create(pt, NULL, prober, argv[1]); + REQUIRE(error, pthread_create); + pthread_detach(pt); + + if (rump_sys_ioctl(fd, MD_SETCONF, md) == -1) { + rump_daemonize_done(errno); + exit(1); + } + + return 0; } Index: src/tests/dev/md/t_md.sh diff -u src/tests/dev/md/t_md.sh:1.1 src/tests/dev/md/t_md.sh:1.2 --- src/tests/dev/md/t_md.sh:1.1 Tue Nov 23 15:38:54 2010 +++ src/tests/dev/md/t_md.sh Tue Nov 30 14:29:05 2010 @@ -1,4 +1,4 @@ -# $NetBSD: t_md.sh,v 1.1 2010/11/23 15:38:54 pooka Exp $ +# $NetBSD: t_md.sh,v 1.2 2010/11/30 14:29:05 pooka Exp $ # # Copyright (c) 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -35,12 +35,13 @@ basic_body() { - RUMPSOCK=unix://commsock - env RUMP_SP_SERVER=${RUMPSOCK} $(atf_get_srcdir)/h_mdserv + # Scope out raw part. This is actually the *host* raw partition, + # but just let it slide for now, since they *should* be the same. + rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` - sleep 1 # XXX: wait for server to start + atf_check -s exit:0 $(atf_get_srcdir)/h_mdserv /dev/rmd0${rawpart} - export RUMP_SP_CLIENT=${RUMPSOCK} + export RUMP_SERVER=unix://commsock atf_check -s exit:0 -e ignore dd if=/bin/ls rof=/dev/rmd0d seek=100 count=10 atf_check -s exit:0 -e ignore dd of=testfile rif=/dev/rmd0d skip=100 count=10 atf_check -s exit:0 -e ignore -o file:testfile dd if=/bin/ls count=10
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Tue Nov 30 14:31:14 UTC 2010 Modified Files: src/tests/dev/md: h_mdserv.c Log Message: comment tyops To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/dev/md/h_mdserv.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/dev/md/h_mdserv.c diff -u src/tests/dev/md/h_mdserv.c:1.2 src/tests/dev/md/h_mdserv.c:1.3 --- src/tests/dev/md/h_mdserv.c:1.2 Tue Nov 30 14:29:05 2010 +++ src/tests/dev/md/h_mdserv.c Tue Nov 30 14:31:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: h_mdserv.c,v 1.2 2010/11/30 14:29:05 pooka Exp $ */ +/* $NetBSD: h_mdserv.c,v 1.3 2010/11/30 14:31:14 pooka Exp $ */ #include sys/types.h #include sys/mman.h @@ -88,11 +88,11 @@ /* * Now, configuring the md driver also causes our process - * to start acting as the worker for the md. Splitting is + * to start acting as the worker for the md. Splitting it * into two steps in the driver is not easy, since md is * supposed to be unconfigured when the process dies * (process may exit between calling ioctl1 and ioctl2). - * So, start a probe thread which attempt to read the md + * So, start a probe thread which attempts to read the md * and declares the md as configured when the read is * succesful. */
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Tue Nov 30 19:03:44 UTC 2010 Modified Files: src/tests/dev/md: Makefile Log Message: don't include librump twice To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/dev/md/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/md/Makefile diff -u src/tests/dev/md/Makefile:1.1 src/tests/dev/md/Makefile:1.2 --- src/tests/dev/md/Makefile:1.1 Tue Nov 23 15:38:54 2010 +++ src/tests/dev/md/Makefile Tue Nov 30 19:03:44 2010 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2010/11/23 15:38:54 pooka Exp $ +# $NetBSD: Makefile,v 1.2 2010/11/30 19:03:44 pooka Exp $ # .include bsd.own.mk @@ -14,7 +14,6 @@ LDADD+= -lrumpdev_md -lrumpdev_disk -lrumpdev -lrumpvfs LDADD+= -lrump LDADD+= -lrumpuser -LDADD+= -lrump LDADD+= -lpthread WARNS= 4
CVS commit: src/tests/dev/md
Module Name:src Committed By: pooka Date: Tue Nov 30 22:15:02 UTC 2010 Modified Files: src/tests/dev/md: t_md.sh Log Message: cleanup server after use (XXX: need better way to reboot it) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/dev/md/t_md.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/dev/md/t_md.sh diff -u src/tests/dev/md/t_md.sh:1.2 src/tests/dev/md/t_md.sh:1.3 --- src/tests/dev/md/t_md.sh:1.2 Tue Nov 30 14:29:05 2010 +++ src/tests/dev/md/t_md.sh Tue Nov 30 22:15:02 2010 @@ -1,4 +1,4 @@ -# $NetBSD: t_md.sh,v 1.2 2010/11/30 14:29:05 pooka Exp $ +# $NetBSD: t_md.sh,v 1.3 2010/11/30 22:15:02 pooka Exp $ # # Copyright (c) 2010 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,8 +25,8 @@ # POSSIBILITY OF SUCH DAMAGE. # -atf_test_case basic -basic() +atf_test_case basic cleanup +basic_head() { atf_set descr Check that md can be created, read and written @@ -47,6 +47,13 @@ atf_check -s exit:0 -e ignore -o file:testfile dd if=/bin/ls count=10 } +basic_cleanup() +{ + + export RUMP_SERVER=unix://commsock + $(atf_get_srcdir)/../../rump/rumpkern/h_client/h_reboot +} + atf_init_test_cases() {