Home | History | Annotate | Line # | Download | only in kernel
t_umountstress.sh revision 1.1
      1  1.1  mlelstv # $NetBSD: t_umountstress.sh,v 1.1 2013/04/16 22:05:44 mlelstv 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.1  mlelstv atf_test_case umountstress cleanup
     37  1.1  mlelstv umountstress_head()
     38  1.1  mlelstv {
     39  1.1  mlelstv 	atf_set "descr" "Checks stressing unmounting a busy filesystem"
     40  1.1  mlelstv 	atf_set "require.user" "root"
     41  1.1  mlelstv }
     42  1.1  mlelstv umountstress_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 touch ${TMPMP}/under_the_mount
     57  1.1  mlelstv 	atf_check -o ignore -e ignore dd if=/dev/zero of=${TMPIM} count=5860
     58  1.1  mlelstv 	atf_check -o ignore -e ignore vnconfig -v ${VND} ${TMPIM}
     59  1.1  mlelstv 	atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
     60  1.1  mlelstv 	atf_check -o ignore -e ignore newfs -i 500 -b 8192 -f 1024 ${CVND}${MPART}
     61  1.1  mlelstv 	atf_check -o ignore -e ignore mount -o async ${BVND}${MPART} ${TMPMP}
     62  1.1  mlelstv 
     63  1.1  mlelstv 	echo "*** Testing unmount"
     64  1.1  mlelstv 
     65  1.1  mlelstv 	touch ${TMPMP}/hold
     66  1.1  mlelstv 	exec 3< ${TMPMP}/hold
     67  1.1  mlelstv 
     68  1.1  mlelstv 	(
     69  1.1  mlelstv 		for l in 0 1 2 3 4 5 6 7 8 9 10; do
     70  1.1  mlelstv 		for i in 0 1 2 3; do
     71  1.1  mlelstv 		for j in 0 1 2 3 4 5 6 7 8 9; do
     72  1.1  mlelstv 		for k in 0 1 2 3 4 5 6 7 8 9; do
     73  1.1  mlelstv 			dd msgfmt=quiet if=/dev/zero count=1 of=test$i$j$k
     74  1.1  mlelstv 			if [ $? -ne 0 ]; then
     75  1.1  mlelstv 				atf_fail "File operation failed"
     76  1.1  mlelstv 			fi
     77  1.1  mlelstv 		done
     78  1.1  mlelstv 		done
     79  1.1  mlelstv 		done
     80  1.1  mlelstv 		done
     81  1.1  mlelstv 	) &
     82  1.1  mlelstv 	busypid=$!
     83  1.1  mlelstv 
     84  1.1  mlelstv 	while kill 2>/dev/null -0 $busypid; do
     85  1.1  mlelstv 		if err=$(umount ${TMPMP} 2>&1); then
     86  1.1  mlelstv 			kill $busypid
     87  1.1  mlelstv 			wait
     88  1.1  mlelstv 			atf_fail "Unmount succeeded while busy"
     89  1.1  mlelstv 		else
     90  1.1  mlelstv 			case $err in
     91  1.1  mlelstv 			*:\ Device\ busy)
     92  1.1  mlelstv 				;;
     93  1.1  mlelstv 			*)
     94  1.1  mlelstv 				kill $busypid
     95  1.1  mlelstv 				wait
     96  1.1  mlelstv 				atf_fail "Unmount failed: $err"
     97  1.1  mlelstv 				;;
     98  1.1  mlelstv 			esac
     99  1.1  mlelstv 		fi
    100  1.1  mlelstv 	done
    101  1.1  mlelstv 	wait
    102  1.1  mlelstv }
    103  1.1  mlelstv umountstress_cleanup()
    104  1.1  mlelstv {
    105  1.1  mlelstv 	echo "*** Cleaning up ${TMPMP}, ${TMPIM}."
    106  1.1  mlelstv 	umount -f "${TMPMP}"
    107  1.1  mlelstv 	vnconfig -u "${VND}"
    108  1.1  mlelstv }
    109  1.1  mlelstv 
    110  1.1  mlelstv atf_init_test_cases()
    111  1.1  mlelstv {
    112  1.1  mlelstv 	atf_add_test_case umountstress
    113  1.1  mlelstv }
    114