Module Name: src
Committed By: pooka
Date: Wed Feb 23 13:01:57 UTC 2011
Modified Files:
src/tests/lib/librumphijack: Makefile
Added Files:
src/tests/lib/librumphijack: t_vfs.sh
Log Message:
simple vfs tests (mount ffs, cp/pax files there, un/remount,
check with diff)
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/librumphijack/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/librumphijack/t_vfs.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/lib/librumphijack/Makefile
diff -u src/tests/lib/librumphijack/Makefile:1.4 src/tests/lib/librumphijack/Makefile:1.5
--- src/tests/lib/librumphijack/Makefile:1.4 Sat Feb 19 13:19:52 2011
+++ src/tests/lib/librumphijack/Makefile Wed Feb 23 13:01:57 2011
@@ -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
Added files:
Index: src/tests/lib/librumphijack/t_vfs.sh
diff -u /dev/null src/tests/lib/librumphijack/t_vfs.sh:1.1
--- /dev/null Wed Feb 23 13:01:57 2011
+++ src/tests/lib/librumphijack/t_vfs.sh Wed Feb 23 13:01:57 2011
@@ -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
+}