t_miscquota.sh revision 1.8 1 1.8 dholland # $NetBSD: t_miscquota.sh,v 1.8 2013/01/22 06:24:11 dholland Exp $
2 1.2 bouyer #
3 1.2 bouyer # Copyright (c) 2011 Manuel Bouyer
4 1.2 bouyer # All rights reserved.
5 1.2 bouyer #
6 1.2 bouyer # Redistribution and use in source and binary forms, with or without
7 1.2 bouyer # modification, are permitted provided that the following conditions
8 1.2 bouyer # are met:
9 1.2 bouyer # 1. Redistributions of source code must retain the above copyright
10 1.2 bouyer # notice, this list of conditions and the following disclaimer.
11 1.2 bouyer # 2. Redistributions in binary form must reproduce the above copyright
12 1.2 bouyer # notice, this list of conditions and the following disclaimer in the
13 1.2 bouyer # documentation and/or other materials provided with the distribution.
14 1.2 bouyer #
15 1.2 bouyer # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.2 bouyer # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.2 bouyer # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.2 bouyer # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.2 bouyer # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.2 bouyer # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.2 bouyer # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.2 bouyer # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.2 bouyer # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.2 bouyer # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.2 bouyer # POSSIBILITY OF SUCH DAMAGE.
26 1.2 bouyer #
27 1.2 bouyer
28 1.2 bouyer test_case_root walk_list_user quota_walk_list \
29 1.2 bouyer "walk user quota list over several disk blocks" -b le 1 user
30 1.2 bouyer
31 1.2 bouyer test_case_root psnapshot_user quota_snap \
32 1.2 bouyer "create a persistent shapshot of quota-enabled fs, and do some writes" \
33 1.2 bouyer -b le 1 user
34 1.2 bouyer
35 1.2 bouyer test_case_root npsnapshot_user quota_snap \
36 1.2 bouyer "create a non-persistent shapshot of quota-enabled fs, and do some writes" \
37 1.2 bouyer -boL le 1 user
38 1.2 bouyer
39 1.2 bouyer test_case_root psnapshot_unconf_user quota_snap \
40 1.2 bouyer "create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \
41 1.2 bouyer -boC le 1 user
42 1.2 bouyer
43 1.2 bouyer test_case_root npsnapshot_unconf_user quota_snap \
44 1.2 bouyer "create a non-persistent shapshot of quota-enabled fs, and do some writes and unconf" \
45 1.2 bouyer -boLC le 1 user
46 1.2 bouyer
47 1.2 bouyer test_case log_unlink quota_log \
48 1.2 bouyer "an unlinked file cleaned by the log replay should update quota" \
49 1.2 bouyer -l le 1 user
50 1.2 bouyer
51 1.2 bouyer test_case log_unlink_remount quota_log \
52 1.2 bouyer "an unlinked file cleaned by the log replay after remount" \
53 1.2 bouyer -oRL le 1 user
54 1.2 bouyer
55 1.2 bouyer
56 1.8 dholland test_case_root default_deny_user quota_default_deny \
57 1.7 bouyer "new quota entry denied by default entry" 5 -b le 1 user
58 1.7 bouyer
59 1.8 dholland test_case_root default_deny_user_big quota_default_deny \
60 1.7 bouyer "new quota entry denied by default entry, with list on more than one block" 5000 -b le 1 user
61 1.7 bouyer
62 1.7 bouyer
63 1.2 bouyer quota_walk_list()
64 1.2 bouyer {
65 1.4 bouyer create_ffs_server $*
66 1.2 bouyer local q=$4
67 1.2 bouyer local expect
68 1.2 bouyer
69 1.2 bouyer case ${q} in
70 1.2 bouyer user)
71 1.2 bouyer expect=u
72 1.2 bouyer fail=g
73 1.2 bouyer ;;
74 1.2 bouyer group)
75 1.2 bouyer expect=g
76 1.2 bouyer fail=u
77 1.2 bouyer ;;
78 1.2 bouyer *)
79 1.2 bouyer atf_fail "wrong quota type"
80 1.2 bouyer ;;
81 1.2 bouyer esac
82 1.2 bouyer
83 1.2 bouyer # create 100 users, all in the same hash list
84 1.2 bouyer local i=1;
85 1.2 bouyer while [ $i -lt 101 ]; do
86 1.2 bouyer atf_check -s exit:0 \
87 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \
88 1.2 bouyer -s10k/20 -h40M/50k -t 2W/3D $((i * 4096))
89 1.2 bouyer i=$((i + 1))
90 1.2 bouyer done
91 1.2 bouyer # do a repquota
92 1.6 dholland atf_check -s exit:0 -o 'match:user 409600 block *81920 20 0' \
93 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt
94 1.4 bouyer rump_quota_shutdown
95 1.2 bouyer }
96 1.2 bouyer
97 1.2 bouyer quota_snap()
98 1.2 bouyer {
99 1.2 bouyer local flag=$1; shift
100 1.4 bouyer create_ffs $*
101 1.2 bouyer local q=$3
102 1.2 bouyer local expect
103 1.2 bouyer
104 1.2 bouyer case ${q} in
105 1.2 bouyer user)
106 1.2 bouyer expect=u
107 1.2 bouyer fail=g
108 1.2 bouyer ;;
109 1.2 bouyer group)
110 1.2 bouyer expect=g
111 1.2 bouyer fail=u
112 1.2 bouyer ;;
113 1.2 bouyer *)
114 1.2 bouyer atf_fail "wrong quota type"
115 1.2 bouyer ;;
116 1.2 bouyer esac
117 1.2 bouyer
118 1.2 bouyer #start our server which takes a snapshot
119 1.2 bouyer atf_check -s exit:0 -o ignore \
120 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests ${flag} 4 ${IMG} ${RUMP_SERVER}
121 1.2 bouyer # create a few users
122 1.2 bouyer local i=1;
123 1.2 bouyer while [ $i -lt 11 ]; do
124 1.2 bouyer atf_check -s exit:0 \
125 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \
126 1.2 bouyer -s10k/20 -h40M/50k -t 2W/3D $i
127 1.2 bouyer i=$((i + 1))
128 1.2 bouyer done
129 1.2 bouyer # we should have 5 files (root + 4 regular files)
130 1.2 bouyer atf_check -s exit:0 \
131 1.2 bouyer -o 'match:- - 7days 5 - - 7days' \
132 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -av
133 1.2 bouyer #shutdown and check filesystem
134 1.4 bouyer rump_quota_shutdown
135 1.2 bouyer }
136 1.2 bouyer
137 1.2 bouyer quota_log()
138 1.2 bouyer {
139 1.2 bouyer local srv2args=$1; shift
140 1.4 bouyer create_ffs $*
141 1.2 bouyer local q=$3
142 1.2 bouyer local expect
143 1.2 bouyer
144 1.2 bouyer case ${q} in
145 1.2 bouyer user)
146 1.2 bouyer expect=u
147 1.2 bouyer fail=g
148 1.2 bouyer ;;
149 1.2 bouyer group)
150 1.2 bouyer expect=g
151 1.2 bouyer fail=u
152 1.2 bouyer ;;
153 1.2 bouyer *)
154 1.2 bouyer atf_fail "wrong quota type"
155 1.2 bouyer ;;
156 1.2 bouyer esac
157 1.2 bouyer
158 1.2 bouyer #start our server which create a file and unlink while keeping
159 1.2 bouyer # it open. The server halts itself without flush
160 1.2 bouyer atf_check -s exit:0 -o ignore \
161 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -loU 5 ${IMG} ${RUMP_SERVER}
162 1.2 bouyer # we should have one unlinked file, but the log covers it.
163 1.2 bouyer atf_check -s exit:0 -o match:'3 files' -e ignore \
164 1.2 bouyer fsck_ffs -nf -F ${IMG}
165 1.2 bouyer # have a kernel mount the fs again; it should cleanup the
166 1.2 bouyer # unlinked file
167 1.2 bouyer atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \
168 1.2 bouyer ${srv2args} -b 5 ${IMG} ${RUMP_SERVER}
169 1.2 bouyer #shutdown and check filesystem
170 1.4 bouyer rump_quota_shutdown
171 1.2 bouyer }
172 1.7 bouyer
173 1.8 dholland quota_default_deny()
174 1.7 bouyer {
175 1.7 bouyer local nusers=$1; shift
176 1.7 bouyer create_ffs_server $*
177 1.7 bouyer local q=$4
178 1.7 bouyer local expect
179 1.7 bouyer
180 1.7 bouyer case ${q} in
181 1.7 bouyer user)
182 1.7 bouyer expect=u
183 1.7 bouyer fail=g
184 1.7 bouyer ;;
185 1.7 bouyer group)
186 1.7 bouyer expect=g
187 1.7 bouyer fail=u
188 1.7 bouyer ;;
189 1.7 bouyer *)
190 1.7 bouyer atf_fail "wrong quota type"
191 1.7 bouyer ;;
192 1.7 bouyer esac
193 1.7 bouyer
194 1.7 bouyer # create $nusers users, so we are sure the free list has entries
195 1.7 bouyer # from block 1. Start from 10, as non-root id is 1.
196 1.7 bouyer # set default to deny all
197 1.7 bouyer ( echo "@format netbsd-quota-dump v1"
198 1.7 bouyer echo "# idtype id objtype hard soft usage expire grace"
199 1.7 bouyer echo "$q default block 0 0 0 0 0"
200 1.7 bouyer echo "$q default file 0 0 0 0 0"
201 1.7 bouyer local i=10;
202 1.7 bouyer while [ $i -lt $(($nusers + 10)) ]; do
203 1.7 bouyer echo "$q $i block 0 0 0 0 0"
204 1.7 bouyer echo "$q $i file 0 0 0 0 0"
205 1.7 bouyer i=$((i + 1))
206 1.7 bouyer done
207 1.7 bouyer ) | atf_check -s exit:0 \
208 1.7 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quotarestore -d /mnt
209 1.7 bouyer atf_check -s exit:0 rump.halt
210 1.7 bouyer #now start the server which does the limits tests
211 1.7 bouyer $(atf_get_srcdir)/h_quota2_tests -oC -b 0 ${IMG} ${RUMP_SERVER}
212 1.7 bouyer rump_quota_shutdown
213 1.7 bouyer }
214