diff options
| author | pooka <pooka@NetBSD.org> | 2010-11-23 15:38:53 +0000 |
|---|---|---|
| committer | pooka <pooka@NetBSD.org> | 2010-11-23 15:38:53 +0000 |
| commit | 48e1b6d6d5be82ec0755d63dad76d82456d36fb0 (patch) | |
| tree | 4de89c52237c5627a83dc76ef0208a5143cc79a5 /tests/dev | |
| parent | 05f534f3c763cc6877fb03fb8048a429e6e93ff6 (diff) | |
Add simple test for md(4) which just stuffs junk into /dev/rmd0d
and checks the same data can be retrieved.
Diffstat (limited to 'tests/dev')
| -rw-r--r-- | tests/dev/Makefile | 4 | ||||
| -rw-r--r-- | tests/dev/md/Atffile | 6 | ||||
| -rw-r--r-- | tests/dev/md/Makefile | 23 | ||||
| -rw-r--r-- | tests/dev/md/h_mdserv.c | 33 | ||||
| -rw-r--r-- | tests/dev/md/t_md.sh | 53 |
5 files changed, 117 insertions, 2 deletions
diff --git a/tests/dev/Makefile b/tests/dev/Makefile index 7d5311d1e39..e5a273b06d1 100644 --- a/tests/dev/Makefile +++ b/tests/dev/Makefile @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.4 2010/11/11 22:38:46 pooka Exp $ +# $NetBSD: Makefile,v 1.5 2010/11/23 15:38:54 pooka Exp $ # .include <bsd.own.mk> TESTSDIR= ${TESTSBASE}/dev -TESTS_SUBDIRS+= audio cgd scsipi sysmon +TESTS_SUBDIRS+= audio cgd md scsipi sysmon .include <bsd.test.mk> diff --git a/tests/dev/md/Atffile b/tests/dev/md/Atffile new file mode 100644 index 00000000000..6ff27680328 --- /dev/null +++ b/tests/dev/md/Atffile @@ -0,0 +1,6 @@ +Content-Type: application/X-atf-atffile; version="1" +X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2010/11/23 15:38:54 pooka Exp $" + +prop: test-suite = "NetBSD" + +tp-glob: t_* diff --git a/tests/dev/md/Makefile b/tests/dev/md/Makefile new file mode 100644 index 00000000000..202d075b96d --- /dev/null +++ b/tests/dev/md/Makefile @@ -0,0 +1,23 @@ +# $NetBSD: Makefile,v 1.1 2010/11/23 15:38:54 pooka Exp $ +# + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/dev/md +FILESDIR= ${TESTSDIR} + +TESTS_SH= t_md +TESTS_C= h_mdserv + +ATFFILE= yes + +LDADD+= -lrumpdev_md -lrumpdev_disk -lrumpdev -lrumpvfs +LDADD+= -lrump +LDADD+= -lrumpuser +LDADD+= -lrump +LDADD+= -lpthread + +WARNS= 4 +NOMAN= + +.include <bsd.test.mk> diff --git a/tests/dev/md/h_mdserv.c b/tests/dev/md/h_mdserv.c new file mode 100644 index 00000000000..06014be6b14 --- /dev/null +++ b/tests/dev/md/h_mdserv.c @@ -0,0 +1,33 @@ +/* $NetBSD: h_mdserv.c,v 1.1 2010/11/23 15:38:54 pooka Exp $ */ + +#include <sys/types.h> +#include <sys/mman.h> +#include <sys/ioctl.h> + +#include <dev/md.h> + +#include <fcntl.h> +#include <unistd.h> + +#include <rump/rump.h> +#include <rump/rump_syscalls.h> + +#include "../../h_macros.h" + +#define MDSIZE (1024*1024) + +int +main(void) +{ + struct md_conf md; + int fd; + + 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(); +} diff --git a/tests/dev/md/t_md.sh b/tests/dev/md/t_md.sh new file mode 100644 index 00000000000..f64e9676757 --- /dev/null +++ b/tests/dev/md/t_md.sh @@ -0,0 +1,53 @@ +# $NetBSD: t_md.sh,v 1.1 2010/11/23 15:38:54 pooka Exp $ +# +# Copyright (c) 2010 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. +# + +atf_test_case basic +basic() +{ + + atf_set "descr" "Check that md can be created, read and written" +} + +basic_body() +{ + + RUMPSOCK=unix://commsock + env RUMP_SP_SERVER=${RUMPSOCK} $(atf_get_srcdir)/h_mdserv & + + sleep 1 # XXX: wait for server to start + + export RUMP_SP_CLIENT=${RUMPSOCK} + 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 +} + +atf_init_test_cases() +{ + + atf_add_test_case basic +} |
