t_umountstress.sh revision 1.6 1 1.6 rin # $NetBSD: t_umountstress.sh,v 1.6 2025/04/19 02:07:43 rin 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.6 rin if [ $(uname -p) = vax ]; then
45 1.6 rin atf_skip "port-vax/59287 vnd(4) can cause kernel crash"
46 1.6 rin fi
47 1.6 rin
48 1.1 mlelstv cat >disktab <<EOF
49 1.1 mlelstv floppy288|2.88MB 3.5in Extra High Density Floppy:\
50 1.1 mlelstv :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
51 1.1 mlelstv :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
52 1.1 mlelstv :pb#5760:ob#0:\
53 1.1 mlelstv :pc#5760:oc#0:
54 1.1 mlelstv EOF
55 1.1 mlelstv
56 1.1 mlelstv echo "*** Creating a dummy directory tree at" \
57 1.1 mlelstv "${TMPMP} mounted on ${TMPIM}"
58 1.1 mlelstv
59 1.1 mlelstv atf_check -o ignore -e ignore mkdir ${TMPMP}
60 1.1 mlelstv atf_check -o ignore -e ignore dd if=/dev/zero of=${TMPIM} count=5860
61 1.1 mlelstv atf_check -o ignore -e ignore vnconfig -v ${VND} ${TMPIM}
62 1.1 mlelstv atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
63 1.1 mlelstv atf_check -o ignore -e ignore newfs -i 500 -b 8192 -f 1024 ${CVND}${MPART}
64 1.1 mlelstv atf_check -o ignore -e ignore mount -o async ${BVND}${MPART} ${TMPMP}
65 1.1 mlelstv
66 1.4 mlelstv echo "*** Testing fileops"
67 1.1 mlelstv
68 1.1 mlelstv touch ${TMPMP}/hold
69 1.2 mlelstv exec 9< ${TMPMP}/hold
70 1.1 mlelstv
71 1.1 mlelstv (
72 1.4 mlelstv for j in 0 1 2; do
73 1.1 mlelstv for k in 0 1 2 3 4 5 6 7 8 9; do
74 1.2 mlelstv if ! dd msgfmt=quiet if=/dev/zero \
75 1.2 mlelstv count=1 of=${TMPMP}/test$i$j$k; then
76 1.5 gson echo 1 >result
77 1.2 mlelstv exit
78 1.1 mlelstv fi
79 1.1 mlelstv done
80 1.1 mlelstv done
81 1.5 gson echo 0 >result
82 1.5 gson ) &
83 1.1 mlelstv busypid=$!
84 1.1 mlelstv
85 1.5 gson while ! test -f result; do
86 1.1 mlelstv if err=$(umount ${TMPMP} 2>&1); then
87 1.1 mlelstv kill $busypid
88 1.2 mlelstv exec 9<&-
89 1.1 mlelstv wait
90 1.1 mlelstv atf_fail "Unmount succeeded while busy"
91 1.2 mlelstv return
92 1.1 mlelstv fi
93 1.2 mlelstv
94 1.2 mlelstv case $err in
95 1.2 mlelstv *:\ Device\ busy)
96 1.2 mlelstv ;;
97 1.2 mlelstv *)
98 1.2 mlelstv kill $busypid
99 1.2 mlelstv exec 9<&-
100 1.2 mlelstv wait
101 1.2 mlelstv atf_fail "Unmount failed: $err"
102 1.2 mlelstv return
103 1.2 mlelstv ;;
104 1.2 mlelstv esac
105 1.1 mlelstv done
106 1.2 mlelstv
107 1.2 mlelstv exec 9<&-
108 1.1 mlelstv wait
109 1.2 mlelstv
110 1.2 mlelstv rc=`cat result`
111 1.2 mlelstv rm -f result
112 1.2 mlelstv
113 1.2 mlelstv case $rc in
114 1.2 mlelstv 0) ;;
115 1.3 mlelstv *) atf_fail "File operation failed"
116 1.2 mlelstv esac
117 1.1 mlelstv }
118 1.4 mlelstv fileop_cleanup()
119 1.4 mlelstv {
120 1.4 mlelstv echo "*** Cleaning up ${TMPMP}, ${TMPIM}."
121 1.4 mlelstv umount -f "${TMPMP}"
122 1.4 mlelstv vnconfig -u "${VND}"
123 1.4 mlelstv }
124 1.4 mlelstv
125 1.4 mlelstv atf_test_case mountlist cleanup
126 1.4 mlelstv mountlist_head()
127 1.4 mlelstv {
128 1.4 mlelstv atf_set "descr" "Checks unmounting a filesystem using mountlist"
129 1.4 mlelstv atf_set "require.user" "root"
130 1.4 mlelstv }
131 1.4 mlelstv mountlist_body()
132 1.4 mlelstv {
133 1.6 rin if [ $(uname -p) = vax ]; then
134 1.6 rin atf_skip "port-vax/59287 vnd(4) can cause kernel crash"
135 1.6 rin fi
136 1.6 rin
137 1.4 mlelstv cat >disktab <<EOF
138 1.4 mlelstv floppy288|2.88MB 3.5in Extra High Density Floppy:\
139 1.4 mlelstv :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
140 1.4 mlelstv :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
141 1.4 mlelstv :pb#5760:ob#0:\
142 1.4 mlelstv :pc#5760:oc#0:
143 1.4 mlelstv EOF
144 1.4 mlelstv
145 1.4 mlelstv echo "*** Creating a dummy directory tree at" \
146 1.4 mlelstv "${TMPMP} mounted on ${TMPIM}"
147 1.4 mlelstv
148 1.4 mlelstv atf_check -o ignore -e ignore mkdir ${TMPMP}
149 1.4 mlelstv atf_check -o ignore -e ignore dd if=/dev/zero of=${TMPIM} count=5860
150 1.4 mlelstv atf_check -o ignore -e ignore vnconfig -v ${VND} ${TMPIM}
151 1.4 mlelstv atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
152 1.4 mlelstv atf_check -o ignore -e ignore newfs -i 500 -b 8192 -f 1024 ${CVND}${MPART}
153 1.4 mlelstv atf_check -o ignore -e ignore mount -o async ${BVND}${MPART} ${TMPMP}
154 1.4 mlelstv
155 1.4 mlelstv echo "*** Testing mountlist"
156 1.4 mlelstv
157 1.4 mlelstv (
158 1.4 mlelstv for j in 0 1 2 3 4 5 6 7 8 9; do
159 1.4 mlelstv for k in 0 1 2 3 4 5 6 7 8 9; do
160 1.4 mlelstv if ! out=$(mount); then
161 1.5 gson echo 1 >result
162 1.4 mlelstv exit
163 1.4 mlelstv fi
164 1.4 mlelstv done
165 1.4 mlelstv done
166 1.5 gson echo 0 >result
167 1.5 gson ) &
168 1.4 mlelstv busypid=$!
169 1.4 mlelstv
170 1.5 gson while ! test -f result; do
171 1.4 mlelstv if err=$(umount ${TMPMP} 2>&1); then
172 1.4 mlelstv if ! mount -o async ${BVND}${MPART} ${TMPMP}; then
173 1.4 mlelstv kill $busypid
174 1.4 mlelstv exec 9<&-
175 1.4 mlelstv wait
176 1.4 mlelstv atf_fail "Remount failed"
177 1.4 mlelstv return
178 1.4 mlelstv fi
179 1.4 mlelstv continue
180 1.4 mlelstv fi
181 1.4 mlelstv
182 1.4 mlelstv case $err in
183 1.4 mlelstv *:\ Device\ busy)
184 1.4 mlelstv ;;
185 1.4 mlelstv *)
186 1.4 mlelstv kill $busypid
187 1.4 mlelstv exec 9<&-
188 1.4 mlelstv wait
189 1.4 mlelstv atf_fail "Unmount failed: $err"
190 1.4 mlelstv return
191 1.4 mlelstv ;;
192 1.4 mlelstv esac
193 1.4 mlelstv done
194 1.4 mlelstv
195 1.4 mlelstv exec 9<&-
196 1.4 mlelstv wait
197 1.4 mlelstv
198 1.4 mlelstv rc=`cat result`
199 1.4 mlelstv rm -f result
200 1.4 mlelstv
201 1.4 mlelstv case $rc in
202 1.4 mlelstv 0) ;;
203 1.4 mlelstv *) atf_fail "Mountlist operation failed"
204 1.4 mlelstv esac
205 1.4 mlelstv }
206 1.4 mlelstv mountlist_cleanup()
207 1.1 mlelstv {
208 1.1 mlelstv echo "*** Cleaning up ${TMPMP}, ${TMPIM}."
209 1.1 mlelstv umount -f "${TMPMP}"
210 1.1 mlelstv vnconfig -u "${VND}"
211 1.1 mlelstv }
212 1.1 mlelstv
213 1.1 mlelstv atf_init_test_cases()
214 1.1 mlelstv {
215 1.4 mlelstv atf_add_test_case fileop
216 1.4 mlelstv atf_add_test_case mountlist
217 1.1 mlelstv }
218