1 # $NetBSD: t_miscquota.sh,v 1.8 2013/01/22 06:24:11 dholland Exp $
3 # Copyright (c) 2011 Manuel Bouyer
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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 test_case_root walk_list_user quota_walk_list \
29 "walk user quota list over several disk blocks" -b le
1 user
31 test_case_root psnapshot_user quota_snap \
32 "create a persistent shapshot of quota-enabled fs, and do some writes" \
35 test_case_root npsnapshot_user quota_snap \
36 "create a non-persistent shapshot of quota-enabled fs, and do some writes" \
39 test_case_root psnapshot_unconf_user quota_snap \
40 "create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \
43 test_case_root npsnapshot_unconf_user quota_snap \
44 "create a non-persistent shapshot of quota-enabled fs, and do some writes and unconf" \
47 test_case log_unlink quota_log \
48 "an unlinked file cleaned by the log replay should update quota" \
51 test_case log_unlink_remount quota_log \
52 "an unlinked file cleaned by the log replay after remount" \
56 test_case_root default_deny_user quota_default_deny \
57 "new quota entry denied by default entry" 5 -b le
1 user
59 test_case_root default_deny_user_big quota_default_deny \
60 "new quota entry denied by default entry, with list on more than one block" 5000 -b le
1 user
79 atf_fail
"wrong quota type"
83 # create 100 users, all in the same hash list
85 while [ $i -lt 101 ]; do
87 env LD_PRELOAD
=/usr
/lib
/librumphijack.so RUMPHIJACK
=vfs
=getvfsstat
,blanket
=/mnt edquota
-${expect} \
88 -s10k/20 -h40M/50k
-t 2W
/3D $
((i
* 4096))
92 atf_check
-s exit:0 -o 'match:user 409600 block *81920 20 0' \
93 env LD_PRELOAD
=/usr
/lib
/librumphijack.so RUMPHIJACK
=vfs
=getvfsstat
,blanket
=/mnt repquota
-x -${expect} /mnt
114 atf_fail
"wrong quota type"
118 #start our server which takes a snapshot
119 atf_check
-s exit:0 -o ignore \
120 $
(atf_get_srcdir
)/h_quota2_tests
${flag} 4 ${IMG} ${RUMP_SERVER}
123 while [ $i -lt 11 ]; do
124 atf_check
-s exit:0 \
125 env LD_PRELOAD
=/usr
/lib
/librumphijack.so RUMPHIJACK
=vfs
=getvfsstat
,blanket
=/mnt edquota
-${expect} \
126 -s10k/20 -h40M/50k
-t 2W
/3D
$i
129 # we should have 5 files (root + 4 regular files)
130 atf_check
-s exit:0 \
131 -o 'match:- - 7days 5 - - 7days' \
132 env LD_PRELOAD
=/usr
/lib
/librumphijack.so RUMPHIJACK
=vfs
=getvfsstat
,blanket
=/mnt repquota
-av
133 #shutdown and check filesystem
139 local srv2args
=$1; shift
154 atf_fail
"wrong quota type"
158 #start our server which create a file and unlink while keeping
159 # it open. The server halts itself without flush
160 atf_check
-s exit:0 -o ignore \
161 $
(atf_get_srcdir
)/h_quota2_tests
-loU 5 ${IMG} ${RUMP_SERVER}
162 # we should have one unlinked file, but the log covers it.
163 atf_check
-s exit:0 -o match
:'3 files' -e ignore \
164 fsck_ffs
-nf -F ${IMG}
165 # have a kernel mount the fs again; it should cleanup the
167 atf_check
-o ignore
-e ignore $
(atf_get_srcdir
)/h_quota2_tests \
168 ${srv2args} -b 5 ${IMG} ${RUMP_SERVER}
169 #shutdown and check filesystem
175 local nusers
=$1; shift
190 atf_fail
"wrong quota type"
194 # create $nusers users, so we are sure the free list has entries
195 # from block 1. Start from 10, as non-root id is 1.
196 # set default to deny all
197 ( echo "@format netbsd-quota-dump v1"
198 echo "# idtype id objtype hard soft usage expire grace"
199 echo "$q default block 0 0 0 0 0"
200 echo "$q default file 0 0 0 0 0"
202 while [ $i -lt $
(($nusers + 10)) ]; do
203 echo "$q $i block 0 0 0 0 0"
204 echo "$q $i file 0 0 0 0 0"
207 ) | atf_check
-s exit:0 \
208 env LD_PRELOAD
=/usr
/lib
/librumphijack.so RUMPHIJACK
=vfs
=getvfsstat
,blanket
=/mnt quotarestore
-d /mnt
209 atf_check
-s exit:0 rump.halt
210 #now start the server which does the limits tests
211 $
(atf_get_srcdir
)/h_quota2_tests
-oC -b 0 ${IMG} ${RUMP_SERVER}