Add a regression test to check that forced unmounts work correctly.

Bug described in PR kern/5683
This commit is contained in:
erh 2003-04-15 06:19:57 +00:00
parent 6dbbe09cdf
commit 6070c46916
4 changed files with 95 additions and 2 deletions

View File

@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.21 2003/01/30 19:47:00 thorpej Exp $
# $NetBSD: Makefile,v 1.22 2003/04/15 06:19:57 erh Exp $
SUBDIR+= execve extent getcwd ipf kqueue lock lockf pipe poll ras \
sigtramp sysvmsg sysvsem sysvshm ucontext unfdpass writev
sigtramp sysvmsg sysvsem sysvshm ucontext umount unfdpass writev
.include <bsd.subdir.mk>

View File

@ -0,0 +1,53 @@
# $NetBSD: Makefile,v 1.1 2003/04/15 06:19:59 erh Exp $
#
# This test creates and mounts a temporary filesystem. Then it
# forcibly unmounts it while in the mount point and checks that
# things work as expected.
#
.include <bsd.own.mk>
TMPMP=${.OBJDIR}/umount-f_mount
TMPIM=${.OBJDIR}/umount-f.im
VND?= vnd0
BVND= /dev/${VND}
CVND= /dev/r${VND}
MPART?= a
regress: mountfs run_script clean
clean:
@echo "*** Cleaning up ${TMPMP}, ${TMPIM}."
-umount -f "${TMPMP}"
-vnconfig -u "${VND}"
-rm -rf "${TMPMP}" "${TMPIM}"
mountfs:
@mkdir ${TMPMP}
@touch ${TMPMP}/under_the_mount
@echo "*** Creating a dummy directory tree at ${TMPMP} monted on" \
"${TMPIM}"
@dd if=/dev/zero of=${TMPIM} count=5860
@vnconfig -v ${VND} ${TMPIM}
@disklabel -f ${.CURDIR}/disktab -rw ${VND} floppy288
@newfs -i 500 -b 8192 -f 1024 ${CVND}${MPART}
@mount -o async ${BVND}${MPART} ${TMPMP}
@touch ${TMPMP}/in_mounted_directory
run_script:
@echo "*** Testing forced unmount"
@if [ ! -e "${TMPMP}/in_mounted_directory" ] ; then \
echo "Test file not present in mounted directory!" ;\
false ;\
fi
@cd "${TMPMP}" && umount -f "${BVND}${MPART}" && \
sh ${.CURDIR}/check_umount.sh
@if [ ! -e "${TMPMP}/under_the_mount" ]; then \
echo "Original mount point dissapeared!" ;\
false ;\
fi
@echo "*** SUCCESS"
.include <bsd.obj.mk>

View File

@ -0,0 +1,33 @@
#!/bin/sh
# $NetBSD: check_umount.sh,v 1.1 2003/04/15 06:19:59 erh Exp $
# This script expects to be run with the current directory
# set to a location that has just been forcibly unmounted.
retval=0
checkit()
{
OUTPUT=`$CMD 2>&1`
if [ "$OUTPUT" != "$EXPECT" ] ; then
retval=1
echo "Command \"$CMD\" failed:"
echo "OUTPUT: $OUTPUT"
echo "EXPECTED: $EXPECT"
fi
}
CMD="ls ."
EXPECT="ls: .: No such file or directory"
checkit
CMD="ls .."
EXPECT="ls: ..: No such file or directory"
checkit
CMD="cd ."
EXPECT="cd: can't cd to ."
checkit
CMD="cd .."
EXPECT="cd: can't cd to .."
checkit
exit $retval

View File

@ -0,0 +1,7 @@
# $NetBSD: disktab,v 1.1 2003/04/15 06:19:59 erh Exp $
floppy288|2.88MB 3.5in Extra High Density Floppy:\
:ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
:pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
:pb#5760:ob#0:\
:pc#5760:oc#0: