t_umountstress.sh revision 1.5 1 1.5 gson # $NetBSD: t_umountstress.sh,v 1.5 2013/05/31 14:40:48 gson Exp $
2 1.1 mlelstv #
3 1.1 mlelstv # Copyright (c) 2013 The NetBSD Foundation, Inc.
4 1.1 mlelstv # All rights reserved.
5 1.1 mlelstv #
6 1.1 mlelstv # Redistribution and use in source and binary forms, with or without
7 1.1 mlelstv # modification, are permitted provided that the following conditions
8 1.1 mlelstv # are met:
9 1.1 mlelstv # 1. Redistributions of source code must retain the above copyright
10 1.1 mlelstv # notice, this list of conditions and the following disclaimer.
11 1.1 mlelstv # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 mlelstv # notice, this list of conditions and the following disclaimer in the
13 1.1 mlelstv # documentation and/or other materials provided with the distribution.
14 1.1 mlelstv #
15 1.1 mlelstv # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 mlelstv # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 mlelstv # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 mlelstv # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 mlelstv # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 mlelstv # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 mlelstv # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 mlelstv # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 mlelstv # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 mlelstv # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 mlelstv # POSSIBILITY OF SUCH DAMAGE.
26 1.1 mlelstv #
27 1.1 mlelstv
28 1.1 mlelstv TMPMP=umount-stress_mount
29 1.1 mlelstv TMPIM=umount-stress.im
30 1.1 mlelstv
31 1.1 mlelstv VND=vnd0
32 1.1 mlelstv BVND=/dev/${VND}
33 1.1 mlelstv CVND=/dev/r${VND}
34 1.1 mlelstv MPART=a
35 1.1 mlelstv
36 1.4 mlelstv atf_test_case fileop cleanup
37 1.4 mlelstv fileop_head()
38 1.1 mlelstv {
39 1.4 mlelstv atf_set "descr" "Checks unmounting a filesystem doing file operations"
40 1.1 mlelstv atf_set "require.user" "root"
41 1.1 mlelstv }
42 1.4 mlelstv fileop_body()
43 1.1 mlelstv {
44 1.1 mlelstv cat >disktab <<EOF
45 1.1 mlelstv floppy288|2.88MB 3.5in Extra High Density Floppy:\
46 1.1 mlelstv :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
47 1.1 mlelstv :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
48 1.1 mlelstv :pb#5760:ob#0:\
49 1.1 mlelstv :pc#5760:oc#0:
50 1.1 mlelstv EOF
51 1.1 mlelstv
52 1.1 mlelstv echo "*** Creating a dummy directory tree at" \
53 1.1 mlelstv "${TMPMP} mounted on ${TMPIM}"
54 1.1 mlelstv
55 1.1 mlelstv atf_check -o ignore -e ignore mkdir ${TMPMP}
56 1.1 mlelstv atf_check -o ignore -e ignore dd if=/dev/zero of=${TMPIM} count=5860
57 1.1 mlelstv atf_check -o ignore -e ignore vnconfig -v ${VND} ${TMPIM}
58 1.1 mlelstv atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
59 1.1 mlelstv atf_check -o ignore -e ignore newfs -i 500 -b 8192 -f 1024 ${CVND}${MPART}
60 1.1 mlelstv atf_check -o ignore -e ignore mount -o async ${BVND}${MPART} ${TMPMP}
61 1.1 mlelstv
62 1.4 mlelstv echo "*** Testing fileops"
63 1.1 mlelstv
64 1.1 mlelstv touch ${TMPMP}/hold
65 1.2 mlelstv exec 9< ${TMPMP}/hold
66 1.1 mlelstv
67 1.1 mlelstv (
68 1.4 mlelstv for j in 0 1 2; do
69 1.1 mlelstv for k in 0 1 2 3 4 5 6 7 8 9; do
70 1.2 mlelstv if ! dd msgfmt=quiet if=/dev/zero \
71 1.2 mlelstv count=1 of=${TMPMP}/test$i$j$k; then
72 1.5 gson echo 1 >result
73 1.2 mlelstv exit
74 1.1 mlelstv fi
75 1.1 mlelstv done
76 1.1 mlelstv done
77 1.5 gson echo 0 >result
78 1.5 gson ) &
79 1.1 mlelstv busypid=$!
80 1.1 mlelstv
81 1.5 gson while ! test -f result; do
82 1.1 mlelstv if err=$(umount ${TMPMP} 2>&1); then
83 1.1 mlelstv kill $busypid
84 1.2 mlelstv exec 9<&-
85 1.1 mlelstv wait
86 1.1 mlelstv atf_fail "Unmount succeeded while busy"
87 1.2 mlelstv return
88 1.1 mlelstv fi
89 1.2 mlelstv
90 1.2 mlelstv case $err in
91 1.2 mlelstv *:\ Device\ busy)
92 1.2 mlelstv ;;
93 1.2 mlelstv *)
94 1.2 mlelstv kill $busypid
95 1.2 mlelstv exec 9<&-
96 1.2 mlelstv wait
97 1.2 mlelstv atf_fail "Unmount failed: $err"
98 1.2 mlelstv return
99 1.2 mlelstv ;;
100 1.2 mlelstv esac
101 1.1 mlelstv done
102 1.2 mlelstv
103 1.2 mlelstv exec 9<&-
104 1.1 mlelstv wait
105 1.2 mlelstv
106 1.2 mlelstv rc=`cat result`
107 1.2 mlelstv rm -f result
108 1.2 mlelstv
109 1.2 mlelstv case $rc in
110 1.2 mlelstv 0) ;;
111 1.3 mlelstv *) atf_fail "File operation failed"
112 1.2 mlelstv esac
113 1.1 mlelstv }
114 1.4 mlelstv fileop_cleanup()
115 1.4 mlelstv {
116 1.4 mlelstv echo "*** Cleaning up ${TMPMP}, ${TMPIM}."
117 1.4 mlelstv umount -f "${TMPMP}"
118 1.4 mlelstv vnconfig -u "${VND}"
119 1.4 mlelstv }
120 1.4 mlelstv
121 1.4 mlelstv atf_test_case mountlist cleanup
122 1.4 mlelstv mountlist_head()
123 1.4 mlelstv {
124 1.4 mlelstv atf_set "descr" "Checks unmounting a filesystem using mountlist"
125 1.4 mlelstv atf_set "require.user" "root"
126 1.4 mlelstv }
127 1.4 mlelstv mountlist_body()
128 1.4 mlelstv {
129 1.4 mlelstv cat >disktab <<EOF
130 1.4 mlelstv floppy288|2.88MB 3.5in Extra High Density Floppy:\
131 1.4 mlelstv :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
132 1.4 mlelstv :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
133 1.4 mlelstv :pb#5760:ob#0:\
134 1.4 mlelstv :pc#5760:oc#0:
135 1.4 mlelstv EOF
136 1.4 mlelstv
137 1.4 mlelstv echo "*** Creating a dummy directory tree at" \
138 1.4 mlelstv "${TMPMP} mounted on ${TMPIM}"
139 1.4 mlelstv
140 1.4 mlelstv atf_check -o ignore -e ignore mkdir ${TMPMP}
141 1.4 mlelstv atf_check -o ignore -e ignore dd if=/dev/zero of=${TMPIM} count=5860
142 1.4 mlelstv atf_check -o ignore -e ignore vnconfig -v ${VND} ${TMPIM}
143 1.4 mlelstv atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
144 1.4 mlelstv atf_check -o ignore -e ignore newfs -i 500 -b 8192 -f 1024 ${CVND}${MPART}
145 1.4 mlelstv atf_check -o ignore -e ignore mount -o async ${BVND}${MPART} ${TMPMP}
146 1.4 mlelstv
147 1.4 mlelstv echo "*** Testing mountlist"
148 1.4 mlelstv
149 1.4 mlelstv (
150 1.4 mlelstv for j in 0 1 2 3 4 5 6 7 8 9; do
151 1.4 mlelstv for k in 0 1 2 3 4 5 6 7 8 9; do
152 1.4 mlelstv if ! out=$(mount); then
153 1.5 gson echo 1 >result
154 1.4 mlelstv exit
155 1.4 mlelstv fi
156 1.4 mlelstv done
157 1.4 mlelstv done
158 1.5 gson echo 0 >result
159 1.5 gson ) &
160 1.4 mlelstv busypid=$!
161 1.4 mlelstv
162 1.5 gson while ! test -f result; do
163 1.4 mlelstv if err=$(umount ${TMPMP} 2>&1); then
164 1.4 mlelstv if ! mount -o async ${BVND}${MPART} ${TMPMP}; then
165 1.4 mlelstv kill $busypid
166 1.4 mlelstv exec 9<&-
167 1.4 mlelstv wait
168 1.4 mlelstv atf_fail "Remount failed"
169 1.4 mlelstv return
170 1.4 mlelstv fi
171 1.4 mlelstv continue
172 1.4 mlelstv fi
173 1.4 mlelstv
174 1.4 mlelstv case $err in
175 1.4 mlelstv *:\ Device\ busy)
176 1.4 mlelstv ;;
177 1.4 mlelstv *)
178 1.4 mlelstv kill $busypid
179 1.4 mlelstv exec 9<&-
180 1.4 mlelstv wait
181 1.4 mlelstv atf_fail "Unmount failed: $err"
182 1.4 mlelstv return
183 1.4 mlelstv ;;
184 1.4 mlelstv esac
185 1.4 mlelstv done
186 1.4 mlelstv
187 1.4 mlelstv exec 9<&-
188 1.4 mlelstv wait
189 1.4 mlelstv
190 1.4 mlelstv rc=`cat result`
191 1.4 mlelstv rm -f result
192 1.4 mlelstv
193 1.4 mlelstv case $rc in
194 1.4 mlelstv 0) ;;
195 1.4 mlelstv *) atf_fail "Mountlist operation failed"
196 1.4 mlelstv esac
197 1.4 mlelstv }
198 1.4 mlelstv mountlist_cleanup()
199 1.1 mlelstv {
200 1.1 mlelstv echo "*** Cleaning up ${TMPMP}, ${TMPIM}."
201 1.1 mlelstv umount -f "${TMPMP}"
202 1.1 mlelstv vnconfig -u "${VND}"
203 1.1 mlelstv }
204 1.1 mlelstv
205 1.1 mlelstv atf_init_test_cases()
206 1.1 mlelstv {
207 1.4 mlelstv atf_add_test_case fileop
208 1.4 mlelstv atf_add_test_case mountlist
209 1.1 mlelstv }
210