t_miscquota.sh revision 1.1.2.3 1 # $NetBSD: t_miscquota.sh,v 1.1.2.3 2011/02/12 21:49:08 bouyer Exp $
2 #
3 # Copyright (c) 2011 Manuel Bouyer
4 # All rights reserved.
5 #
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.
14 #
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.
26 #
27
28 test_case_root walk_list_user quota_walk_list \
29 "walk user quota list over several disk blocks" -b le 1 user
30
31 test_case_root psnapshot_user quota_snap \
32 "create a persistent shapshot of quota-enabled fs, and do some writes" \
33 -b le 1 user
34
35 test_case_root npsnapshot_user quota_snap \
36 "create a non-persistent shapshot of quota-enabled fs, and do some writes" \
37 -boL le 1 user
38
39 test_case_root psnapshot_unconf_user quota_snap \
40 "create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \
41 -boC le 1 user
42
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" \
45 -boLC le 1 user
46
47
48 quota_walk_list()
49 {
50 create_with_quotas_server $*
51 local q=$4
52 local expect
53
54 case ${q} in
55 user)
56 expect=u
57 fail=g
58 ;;
59 group)
60 expect=g
61 fail=u
62 ;;
63 *)
64 atf_fail "wrong quota type"
65 ;;
66 esac
67
68 # create 100 users, all in the same hash list
69 local i=1;
70 while [ $i -lt 101 ]; do
71 atf_check -s exit:0 \
72 $(atf_get_srcdir)/rump_edquota -${expect} \
73 -s10k/20 -h40M/50k -t 2W/3D $((i * 4096))
74 i=$((i + 1))
75 done
76 # do a repquota
77 atf_check -s exit:0 -o 'match:<integer>0x64000' \
78 $(atf_get_srcdir)/rump_repquota -x -${expect} /mnt
79 rump_shutdown
80 }
81
82 quota_snap()
83 {
84 local flag=$1; shift
85 create_with_quotas $*
86 local q=$3
87 local expect
88
89 case ${q} in
90 user)
91 expect=u
92 fail=g
93 ;;
94 group)
95 expect=g
96 fail=u
97 ;;
98 *)
99 atf_fail "wrong quota type"
100 ;;
101 esac
102
103 #start our server which takes a snapshot
104 atf_check -s exit:0 -o ignore \
105 $(atf_get_srcdir)/h_quota2_tests ${flag} 4 ${IMG} ${RUMP_SERVER}
106 # create a few users
107 local i=1;
108 while [ $i -lt 11 ]; do
109 atf_check -s exit:0 \
110 $(atf_get_srcdir)/rump_edquota -${expect} \
111 -s10k/20 -h40M/50k -t 2W/3D $i
112 i=$((i + 1))
113 done
114 # we should have 5 files (root + 4 regular files)
115 atf_check -s exit:0 \
116 -o 'match:- - 7days 5 - - 7days' \
117 $(atf_get_srcdir)/rump_repquota -av
118 #shutdown and check filesystem
119 rump_shutdown
120 }
121