t_miscquota.sh revision 1.1.2.4 1 1.1.2.4 bouyer # $NetBSD: t_miscquota.sh,v 1.1.2.4 2011/02/13 20:58:28 bouyer Exp $
2 1.1.2.1 bouyer #
3 1.1.2.1 bouyer # Copyright (c) 2011 Manuel Bouyer
4 1.1.2.1 bouyer # All rights reserved.
5 1.1.2.1 bouyer #
6 1.1.2.1 bouyer # Redistribution and use in source and binary forms, with or without
7 1.1.2.1 bouyer # modification, are permitted provided that the following conditions
8 1.1.2.1 bouyer # are met:
9 1.1.2.1 bouyer # 1. Redistributions of source code must retain the above copyright
10 1.1.2.1 bouyer # notice, this list of conditions and the following disclaimer.
11 1.1.2.1 bouyer # 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.1 bouyer # notice, this list of conditions and the following disclaimer in the
13 1.1.2.1 bouyer # documentation and/or other materials provided with the distribution.
14 1.1.2.1 bouyer #
15 1.1.2.1 bouyer # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1.2.1 bouyer # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1.2.1 bouyer # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1.2.1 bouyer # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1.2.1 bouyer # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1.2.1 bouyer # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1.2.1 bouyer # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1.2.1 bouyer # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1.2.1 bouyer # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1.2.1 bouyer # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1.2.1 bouyer # POSSIBILITY OF SUCH DAMAGE.
26 1.1.2.1 bouyer #
27 1.1.2.1 bouyer
28 1.1.2.2 bouyer test_case_root walk_list_user quota_walk_list \
29 1.1.2.1 bouyer "walk user quota list over several disk blocks" -b le 1 user
30 1.1.2.1 bouyer
31 1.1.2.3 bouyer test_case_root psnapshot_user quota_snap \
32 1.1.2.3 bouyer "create a persistent shapshot of quota-enabled fs, and do some writes" \
33 1.1.2.3 bouyer -b le 1 user
34 1.1.2.3 bouyer
35 1.1.2.3 bouyer test_case_root npsnapshot_user quota_snap \
36 1.1.2.3 bouyer "create a non-persistent shapshot of quota-enabled fs, and do some writes" \
37 1.1.2.3 bouyer -boL le 1 user
38 1.1.2.3 bouyer
39 1.1.2.3 bouyer test_case_root psnapshot_unconf_user quota_snap \
40 1.1.2.3 bouyer "create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \
41 1.1.2.3 bouyer -boC le 1 user
42 1.1.2.3 bouyer
43 1.1.2.3 bouyer test_case_root npsnapshot_unconf_user quota_snap \
44 1.1.2.3 bouyer "create a non-persistent shapshot of quota-enabled fs, and do some writes and unconf" \
45 1.1.2.3 bouyer -boLC le 1 user
46 1.1.2.3 bouyer
47 1.1.2.4 bouyer test_case log_unlink quota_log \
48 1.1.2.4 bouyer "an unlinked file cleaned by the log replay should update quota" \
49 1.1.2.4 bouyer -l le 1 user
50 1.1.2.4 bouyer
51 1.1.2.4 bouyer test_case log_unlink_remount quota_log \
52 1.1.2.4 bouyer "an unlinked file cleaned by the log replay after remount" \
53 1.1.2.4 bouyer -oRL le 1 user
54 1.1.2.4 bouyer
55 1.1.2.3 bouyer
56 1.1.2.1 bouyer quota_walk_list()
57 1.1.2.1 bouyer {
58 1.1.2.1 bouyer create_with_quotas_server $*
59 1.1.2.1 bouyer local q=$4
60 1.1.2.1 bouyer local expect
61 1.1.2.1 bouyer
62 1.1.2.1 bouyer case ${q} in
63 1.1.2.1 bouyer user)
64 1.1.2.1 bouyer expect=u
65 1.1.2.1 bouyer fail=g
66 1.1.2.1 bouyer ;;
67 1.1.2.1 bouyer group)
68 1.1.2.1 bouyer expect=g
69 1.1.2.1 bouyer fail=u
70 1.1.2.1 bouyer ;;
71 1.1.2.1 bouyer *)
72 1.1.2.1 bouyer atf_fail "wrong quota type"
73 1.1.2.1 bouyer ;;
74 1.1.2.1 bouyer esac
75 1.1.2.1 bouyer
76 1.1.2.1 bouyer # create 100 users, all in the same hash list
77 1.1.2.1 bouyer local i=1;
78 1.1.2.1 bouyer while [ $i -lt 101 ]; do
79 1.1.2.1 bouyer atf_check -s exit:0 \
80 1.1.2.1 bouyer $(atf_get_srcdir)/rump_edquota -${expect} \
81 1.1.2.1 bouyer -s10k/20 -h40M/50k -t 2W/3D $((i * 4096))
82 1.1.2.1 bouyer i=$((i + 1))
83 1.1.2.1 bouyer done
84 1.1.2.1 bouyer # do a repquota
85 1.1.2.1 bouyer atf_check -s exit:0 -o 'match:<integer>0x64000' \
86 1.1.2.1 bouyer $(atf_get_srcdir)/rump_repquota -x -${expect} /mnt
87 1.1.2.1 bouyer rump_shutdown
88 1.1.2.1 bouyer }
89 1.1.2.3 bouyer
90 1.1.2.3 bouyer quota_snap()
91 1.1.2.3 bouyer {
92 1.1.2.3 bouyer local flag=$1; shift
93 1.1.2.3 bouyer create_with_quotas $*
94 1.1.2.3 bouyer local q=$3
95 1.1.2.3 bouyer local expect
96 1.1.2.3 bouyer
97 1.1.2.3 bouyer case ${q} in
98 1.1.2.3 bouyer user)
99 1.1.2.3 bouyer expect=u
100 1.1.2.3 bouyer fail=g
101 1.1.2.3 bouyer ;;
102 1.1.2.3 bouyer group)
103 1.1.2.3 bouyer expect=g
104 1.1.2.3 bouyer fail=u
105 1.1.2.3 bouyer ;;
106 1.1.2.3 bouyer *)
107 1.1.2.3 bouyer atf_fail "wrong quota type"
108 1.1.2.3 bouyer ;;
109 1.1.2.3 bouyer esac
110 1.1.2.3 bouyer
111 1.1.2.3 bouyer #start our server which takes a snapshot
112 1.1.2.3 bouyer atf_check -s exit:0 -o ignore \
113 1.1.2.3 bouyer $(atf_get_srcdir)/h_quota2_tests ${flag} 4 ${IMG} ${RUMP_SERVER}
114 1.1.2.3 bouyer # create a few users
115 1.1.2.3 bouyer local i=1;
116 1.1.2.3 bouyer while [ $i -lt 11 ]; do
117 1.1.2.3 bouyer atf_check -s exit:0 \
118 1.1.2.3 bouyer $(atf_get_srcdir)/rump_edquota -${expect} \
119 1.1.2.3 bouyer -s10k/20 -h40M/50k -t 2W/3D $i
120 1.1.2.3 bouyer i=$((i + 1))
121 1.1.2.3 bouyer done
122 1.1.2.3 bouyer # we should have 5 files (root + 4 regular files)
123 1.1.2.3 bouyer atf_check -s exit:0 \
124 1.1.2.3 bouyer -o 'match:- - 7days 5 - - 7days' \
125 1.1.2.3 bouyer $(atf_get_srcdir)/rump_repquota -av
126 1.1.2.3 bouyer #shutdown and check filesystem
127 1.1.2.3 bouyer rump_shutdown
128 1.1.2.3 bouyer }
129 1.1.2.4 bouyer
130 1.1.2.4 bouyer quota_log()
131 1.1.2.4 bouyer {
132 1.1.2.4 bouyer local srv2args=$1; shift
133 1.1.2.4 bouyer create_with_quotas $*
134 1.1.2.4 bouyer local q=$3
135 1.1.2.4 bouyer local expect
136 1.1.2.4 bouyer
137 1.1.2.4 bouyer case ${q} in
138 1.1.2.4 bouyer user)
139 1.1.2.4 bouyer expect=u
140 1.1.2.4 bouyer fail=g
141 1.1.2.4 bouyer ;;
142 1.1.2.4 bouyer group)
143 1.1.2.4 bouyer expect=g
144 1.1.2.4 bouyer fail=u
145 1.1.2.4 bouyer ;;
146 1.1.2.4 bouyer *)
147 1.1.2.4 bouyer atf_fail "wrong quota type"
148 1.1.2.4 bouyer ;;
149 1.1.2.4 bouyer esac
150 1.1.2.4 bouyer
151 1.1.2.4 bouyer #start our server which create a file and unlink while keeping
152 1.1.2.4 bouyer # it open. The server halts itself without flush
153 1.1.2.4 bouyer atf_check -s exit:0 -o ignore \
154 1.1.2.4 bouyer $(atf_get_srcdir)/h_quota2_tests -loU 5 ${IMG} ${RUMP_SERVER}
155 1.1.2.4 bouyer # we should have one unlinked file, but the log covers it.
156 1.1.2.4 bouyer atf_check -s exit:0 -o match:'3 files' -e ignore \
157 1.1.2.4 bouyer fsck_ffs -nf -F ${IMG}
158 1.1.2.4 bouyer # have a kernel mount the fs again; it should cleanup the
159 1.1.2.4 bouyer # unlinked file
160 1.1.2.4 bouyer atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \
161 1.1.2.4 bouyer ${srv2args} -b 5 ${IMG} ${RUMP_SERVER}
162 1.1.2.4 bouyer #shutdown and check filesystem
163 1.1.2.4 bouyer rump_shutdown
164 1.1.2.4 bouyer }
165