Remove building with NOCRYPTO option
[minix.git] / tests / lib / librumphijack / t_vfs.sh
blobc803e2a1974ca1133beacc4970ae30f14aee1e3c
1 # $NetBSD: t_vfs.sh,v 1.6 2012/08/04 03:56:47 riastradh Exp $
3 # Copyright (c) 2011 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 img=ffs.img
29 rumpsrv_ffs=\
30 "rump_server -lrumpvfs -lrumpfs_ffs -lrumpdev_disk -d key=/img,hostpath=${img},size=host"
31 export RUMP_SERVER=unix://csock
33 domount()
36 mntdir=$1
37 [ $# -eq 0 ] && mntdir=/rump/mnt
38 atf_check -s exit:0 -e ignore mount_ffs /img ${mntdir}
41 dounmount()
44 atf_check -s exit:0 umount -R ${mntdir}
47 remount()
50 dounmount
51 domount /rump/mnt2
54 simpletest()
56 local name="${1}"; shift
58 atf_test_case "${name}" cleanup
59 eval "${name}_head() { }"
60 eval "${name}_body() { \
61 atf_check -s exit:0 rump_server -lrumpvfs ${RUMP_SERVER} ; \
62 export LD_PRELOAD=/usr/lib/librumphijack.so ; \
63 ${name} " "${@}" "; \
65 eval "${name}_cleanup() { \
66 rump.halt
70 test_case()
72 local name="${1}"; shift
74 atf_test_case "${name}" cleanup
75 eval "${name}_head() { }"
76 eval "${name}_body() { \
77 atf_check -s exit:0 -o ignore newfs -F -s 20000 ${img} ; \
78 atf_check -s exit:0 ${rumpsrv_ffs} ${RUMP_SERVER} ; \
79 export LD_PRELOAD=/usr/lib/librumphijack.so ; \
80 mkdir /rump/mnt /rump/mnt2 ; \
81 domount ; \
82 ${name} " "${@}" "; \
83 dounmount ${mntdir}
85 eval "${name}_cleanup() { \
86 rump.halt
90 test_case paxcopy
91 test_case cpcopy
92 test_case mv_nox
93 test_case ln_nox
96 # use rumphijack to cp/pax stuff onto an image, unmount it, remount it
97 # at a different location, and check that we have an identical copy
98 # (we make a local copy to avoid the minor possibility that someone
99 # modifies the source dir data while the test is running)
101 paxcopy()
103 parent=$(dirname $(atf_get_srcdir))
104 thedir=$(basename $(atf_get_srcdir))
105 atf_check -s exit:0 pax -rw -s,${parent},, $(atf_get_srcdir) .
106 atf_check -s exit:0 pax -rw ${thedir} /rump/mnt
107 remount
108 atf_check -s exit:0 diff -ru ${thedir} /rump/mnt2/${thedir}
111 cpcopy()
113 thedir=$(basename $(atf_get_srcdir))
114 atf_check -s exit:0 cp -Rp $(atf_get_srcdir) .
115 atf_check -s exit:0 cp -Rp ${thedir} /rump/mnt
116 remount
117 atf_check -s exit:0 diff -ru ${thedir} /rump/mnt2/${thedir}
121 # non-crosskernel mv (non-simple test since this uses rename(2)
122 # which is not supported by rumpfs)
125 mv_nox()
127 # stat default format sans changetime and filename
128 statstr='%d %i %Sp %l %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%SB\" %k %b %#Xf'
130 atf_check -s exit:0 touch /rump/mnt/filename
131 atf_check -s exit:0 -o save:stat.out \
132 stat -f "${statstr}" /rump/mnt/filename
133 atf_check -s exit:0 mkdir /rump/mnt/dir
134 atf_check -s exit:0 mv /rump/mnt/filename /rump/mnt/dir/same
135 atf_check -s exit:0 -o file:stat.out \
136 stat -f "${statstr}" /rump/mnt/dir/same
139 ln_nox()
141 # Omit st_nlink too, since it will increase.
142 statstr='%d %i %Sp %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%SB\" %k %b %#Xf'
144 atf_check -s exit:0 touch /rump/mnt/filename
145 atf_check -s exit:0 -o save:stat.out \
146 stat -f "${statstr}" /rump/mnt/filename
147 atf_check -s exit:0 mkdir /rump/mnt/dir
148 atf_check -s exit:0 ln /rump/mnt/filename /rump/mnt/dir/same
149 atf_check -s exit:0 -o file:stat.out \
150 stat -f "${statstr}" /rump/mnt/filename
151 atf_check -s exit:0 -o file:stat.out \
152 stat -f "${statstr}" /rump/mnt/dir/same
155 simpletest mv_x
156 simpletest ln_x
157 simpletest runonprefix
158 simpletest blanket
159 simpletest doubleblanket
162 # do a cross-kernel mv
164 mv_x()
166 thedir=$(basename $(atf_get_srcdir))
167 atf_check -s exit:0 cp -Rp $(atf_get_srcdir) .
168 atf_check -s exit:0 cp -Rp ${thedir} ${thedir}.2
169 atf_check -s exit:0 mv ${thedir} /rump
170 atf_check -s exit:0 diff -ru ${thedir}.2 /rump/${thedir}
174 # Fail to make a cross-kernel hard link.
176 ln_x()
178 atf_check -s exit:0 touch ./loser
179 atf_check -s not-exit:0 -e ignore ln ./loser /rump/.
182 runonprefix()
184 atf_check -s exit:0 -o ignore stat /rump/dev
185 atf_check -s exit:1 -e ignore stat /rumpdev
188 blanket()
190 export RUMPHIJACK='blanket=/dev,path=/rump'
191 atf_check -s exit:0 -o save:stat.out \
192 stat -f "${statstr}" /rump/dev/null
193 atf_check -s exit:0 -o file:stat.out \
194 stat -f "${statstr}" /dev/null
197 doubleblanket()
199 atf_check -s exit:0 mkdir /rump/dir
200 atf_check -s exit:0 ln -s dir /rump/dirtoo
202 export RUMPHIJACK='blanket=/dirtoo:/dir'
203 atf_check -s exit:0 touch /dir/file
205 atf_check -s exit:0 -o save:stat.out \
206 stat -f "${statstr}" /dir/file
207 atf_check -s exit:0 -o file:stat.out \
208 stat -f "${statstr}" /dirtoo/file
211 atf_init_test_cases()
214 atf_add_test_case paxcopy
215 atf_add_test_case cpcopy
216 atf_add_test_case mv_x
217 atf_add_test_case ln_x
218 atf_add_test_case mv_nox
219 atf_add_test_case ln_nox
220 atf_add_test_case runonprefix
221 atf_add_test_case blanket
222 atf_add_test_case doubleblanket