Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/librumphijack simple vfs tests (mount ffs, cp/pax ...



details:   https://anonhg.NetBSD.org/src/rev/0ed68497de9c
branches:  trunk
changeset: 762581:0ed68497de9c
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Feb 23 13:01:57 2011 +0000

description:
simple vfs tests (mount ffs, cp/pax files there, un/remount,
check with diff)

diffstat:

 tests/lib/librumphijack/Makefile |    3 +-
 tests/lib/librumphijack/t_vfs.sh |  107 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+), 1 deletions(-)

diffs (128 lines):

diff -r 5647903b5b8a -r 0ed68497de9c tests/lib/librumphijack/Makefile
--- a/tests/lib/librumphijack/Makefile  Wed Feb 23 12:38:47 2011 +0000
+++ b/tests/lib/librumphijack/Makefile  Wed Feb 23 13:01:57 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.4 2011/02/19 13:19:52 pooka Exp $
+#      $NetBSD: Makefile,v 1.5 2011/02/23 13:01:57 pooka Exp $
 #
 
 .include <bsd.own.mk>
@@ -8,6 +8,7 @@
 TESTS_SH=      t_asyncio
 TESTS_SH+=     t_cwd
 TESTS_SH+=     t_tcpip
+TESTS_SH+=     t_vfs
 TESTS_C=       h_client
 TESTS_C+=      h_netget
 TESTS_C+=      h_cwd
diff -r 5647903b5b8a -r 0ed68497de9c tests/lib/librumphijack/t_vfs.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/librumphijack/t_vfs.sh  Wed Feb 23 13:01:57 2011 +0000
@@ -0,0 +1,107 @@
+#       $NetBSD: t_vfs.sh,v 1.1 2011/02/23 13:01:57 pooka Exp $
+#
+# Copyright (c) 2011 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.
+#
+
+img=ffs.img
+rumpsrv=\
+"rump_server -lrumpvfs -lrumpfs_ffs -d key=/img,hostpath=${img},size=host"
+export RUMP_SERVER=unix://csock
+
+domount()
+{
+
+       mntdir=$1
+       [ $# -eq 0 ] && mntdir=/rump/mnt
+       atf_check -s exit:0 -e ignore mount_ffs /img ${mntdir}
+}
+
+unmount()
+{
+
+       atf_check -s exit:0 umount -R ${1}
+}
+
+remount()
+{
+
+       unmount /rump/mnt
+       domount /rump/mnt2
+}
+
+test_case()
+{
+       local name="${1}"; shift
+
+       atf_test_case "${name}" cleanup
+       eval "${name}_head() {  }"
+       eval "${name}_body() { \
+               atf_check -s exit:0 -o ignore newfs -F -s 20000 ${img} ; \
+               atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER} ; \
+               export LD_PRELOAD=/usr/lib/librumphijack.so ; \
+               mkdir /rump/mnt /rump/mnt2 ; \
+               domount ; \
+               ${name} " "${@}" "; \
+               unmount /rump/mnt2 ;\
+       }"
+       eval "${name}_cleanup() { \
+               rump.halt
+       }"
+}
+
+test_case paxcopy
+test_case cpcopy
+
+#
+# use rumphijack to cp/pax stuff onto an image, unmount it, remount it
+# at a different location, and check that we have an identical copy
+# (we make a local copy to avoid the minor possibility that someone
+# modifies the source dir data while the test is running)
+#
+paxcopy()
+{
+       parent=$(dirname $(atf_get_srcdir))
+       thedir=$(basename $(atf_get_srcdir))
+       atf_check -s exit:0 pax -rw -s,${parent},, $(atf_get_srcdir) .
+       atf_check -s exit:0 pax -rw ${thedir} /rump/mnt
+       remount
+       atf_check -s exit:0 diff -ru ${thedir} /rump/mnt2/${thedir}
+}
+
+cpcopy()
+{
+       thedir=$(basename $(atf_get_srcdir))
+       atf_check -s exit:0 cp -Rp $(atf_get_srcdir) .
+       atf_check -s exit:0 cp -Rp ${thedir} /rump/mnt
+       remount
+       atf_check -s exit:0 diff -ru ${thedir} /rump/mnt2/${thedir}
+}
+
+atf_init_test_cases()
+{
+
+       atf_add_test_case paxcopy
+       atf_add_test_case cpcopy
+}



Home | Main Index | Thread Index | Old Index