Source-Changes-HG archive

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

[src/trunk]: src Add simple test for md(4) which just stuffs junk into /dev/r...



details:   https://anonhg.NetBSD.org/src/rev/cb11cab4e10f
branches:  trunk
changeset: 759001:cb11cab4e10f
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Nov 23 15:38:53 2010 +0000

description:
Add simple test for md(4) which just stuffs junk into /dev/rmd0d
and checks the same data can be retrieved.

diffstat:

 distrib/sets/lists/tests/mi |   8 +++++-
 etc/mtree/NetBSD.dist.base  |   4 ++-
 tests/dev/Makefile          |   4 +-
 tests/dev/md/Atffile        |   6 +++++
 tests/dev/md/Makefile       |  23 +++++++++++++++++++
 tests/dev/md/h_mdserv.c     |  33 ++++++++++++++++++++++++++++
 tests/dev/md/t_md.sh        |  53 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 127 insertions(+), 4 deletions(-)

diffs (201 lines):

diff -r 8f194f1404ba -r cb11cab4e10f distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Nov 23 14:02:01 2010 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Nov 23 15:38:53 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.158 2010/11/19 18:18:54 njoly Exp $
+# $NetBSD: mi,v 1.159 2010/11/23 15:38:53 pooka Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -218,6 +218,8 @@
 ./usr/libdata/debug/usr/tests/dev/cgd                                  tests-fs-debug
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd                                        tests-fs-debug
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd/h_img2cgd.debug                        tests-fs-debug          debug,atf
+./usr/libdata/debug/usr/tests/dev/md                                   tests-fs-debug
+./usr/libdata/debug/usr/tests/dev/md/h_mdserv.debug                                    tests-fs-debug
 ./usr/libdata/debug/usr/tests/dev/scsipi                                       tests-fs-debug
 ./usr/libdata/debug/usr/tests/dev/scsipi/t_cd.debug                    tests-fs-debug          debug,atf
 ./usr/libdata/debug/usr/tests/dev/sysmon                                       tests-fs-debug
@@ -1026,6 +1028,10 @@
 ./usr/tests/dev/cgd/h_img2cgd                          tests-fs-tests
 ./usr/tests/dev/cgd/h_img2cgd/h_img2cgd                        tests-fs-tests          atf
 ./usr/tests/dev/cgd/h_img2cgd/cgd.conf                 tests-fs-tests          atf
+./usr/tests/dev/md                             tests-fs-tests
+./usr/tests/dev/md/Atffile                     tests-fs-tests          atf
+./usr/tests/dev/md/h_mdserv                    tests-fs-tests          atf
+./usr/tests/dev/md/t_md                        tests-fs-tests          atf
 ./usr/tests/dev/scsipi                         tests-fs-tests
 ./usr/tests/dev/scsipi/Atffile                 tests-fs-tests          atf
 ./usr/tests/dev/scsipi/t_cd                    tests-fs-tests          atf
diff -r 8f194f1404ba -r cb11cab4e10f etc/mtree/NetBSD.dist.base
--- a/etc/mtree/NetBSD.dist.base        Tue Nov 23 14:02:01 2010 +0000
+++ b/etc/mtree/NetBSD.dist.base        Tue Nov 23 15:38:53 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.base,v 1.61 2010/11/11 22:48:47 pooka Exp $
+#      $NetBSD: NetBSD.dist.base,v 1.62 2010/11/23 15:38:53 pooka Exp $
 #      @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
 
 # Do not customize this file as it may be overwritten on upgrades.
@@ -210,6 +210,7 @@
 ./usr/libdata/debug/usr/tests/dev/audio
 ./usr/libdata/debug/usr/tests/dev/cgd
 ./usr/libdata/debug/usr/tests/dev/cgd/h_img2cgd
+./usr/libdata/debug/usr/tests/dev/md
 ./usr/libdata/debug/usr/tests/dev/scsipi
 ./usr/libdata/debug/usr/tests/dev/sysmon
 ./usr/libdata/debug/usr/tests/fs
@@ -1149,6 +1150,7 @@
 ./usr/tests/dev/audio
 ./usr/tests/dev/cgd
 ./usr/tests/dev/cgd/h_img2cgd
+./usr/tests/dev/md
 ./usr/tests/dev/scsipi
 ./usr/tests/dev/sysmon
 ./usr/tests/fs
diff -r 8f194f1404ba -r cb11cab4e10f tests/dev/Makefile
--- a/tests/dev/Makefile        Tue Nov 23 14:02:01 2010 +0000
+++ b/tests/dev/Makefile        Tue Nov 23 15:38:53 2010 +0000
@@ -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 -r 8f194f1404ba -r cb11cab4e10f tests/dev/md/Atffile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dev/md/Atffile      Tue Nov 23 15:38:53 2010 +0000
@@ -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 -r 8f194f1404ba -r cb11cab4e10f tests/dev/md/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dev/md/Makefile     Tue Nov 23 15:38:53 2010 +0000
@@ -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 -r 8f194f1404ba -r cb11cab4e10f tests/dev/md/h_mdserv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dev/md/h_mdserv.c   Tue Nov 23 15:38:53 2010 +0000
@@ -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 -r 8f194f1404ba -r cb11cab4e10f tests/dev/md/t_md.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dev/md/t_md.sh      Tue Nov 23 15:38:53 2010 +0000
@@ -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
+}



Home | Main Index | Thread Index | Old Index