head	1.6;
access;
symbols
	netbsd-11-0-RC4:1.6
	netbsd-11-0-RC3:1.6
	netbsd-11-0-RC2:1.6
	netbsd-11-0-RC1:1.6
	perseant-exfatfs-base-20250801:1.6
	netbsd-11:1.6.0.4
	netbsd-11-base:1.6
	netbsd-10-1-RELEASE:1.5
	perseant-exfatfs-base-20240630:1.6
	perseant-exfatfs:1.6.0.2
	perseant-exfatfs-base:1.6
	netbsd-8-3-RELEASE:1.5
	netbsd-9-4-RELEASE:1.5
	netbsd-10-0-RELEASE:1.5
	netbsd-10-0-RC6:1.5
	netbsd-10-0-RC5:1.5
	netbsd-10-0-RC4:1.5
	netbsd-10-0-RC3:1.5
	netbsd-10-0-RC2:1.5
	netbsd-10-0-RC1:1.5
	netbsd-10:1.5.0.40
	netbsd-10-base:1.5
	netbsd-9-3-RELEASE:1.5
	cjep_sun2x-base1:1.5
	cjep_sun2x:1.5.0.38
	cjep_sun2x-base:1.5
	cjep_staticlib_x-base1:1.5
	netbsd-9-2-RELEASE:1.5
	cjep_staticlib_x:1.5.0.36
	cjep_staticlib_x-base:1.5
	netbsd-9-1-RELEASE:1.5
	phil-wifi-20200421:1.5
	phil-wifi-20200411:1.5
	is-mlppp:1.5.0.34
	is-mlppp-base:1.5
	phil-wifi-20200406:1.5
	netbsd-8-2-RELEASE:1.5
	netbsd-9-0-RELEASE:1.5
	netbsd-9-0-RC2:1.5
	netbsd-9-0-RC1:1.5
	phil-wifi-20191119:1.5
	netbsd-9:1.5.0.32
	netbsd-9-base:1.5
	phil-wifi-20190609:1.5
	netbsd-8-1-RELEASE:1.5
	netbsd-8-1-RC1:1.5
	pgoyette-compat-merge-20190127:1.5
	pgoyette-compat-20190127:1.5
	pgoyette-compat-20190118:1.5
	pgoyette-compat-1226:1.5
	pgoyette-compat-1126:1.5
	pgoyette-compat-1020:1.5
	pgoyette-compat-0930:1.5
	pgoyette-compat-0906:1.5
	netbsd-7-2-RELEASE:1.5
	pgoyette-compat-0728:1.5
	netbsd-8-0-RELEASE:1.5
	phil-wifi:1.5.0.30
	phil-wifi-base:1.5
	pgoyette-compat-0625:1.5
	netbsd-8-0-RC2:1.5
	pgoyette-compat-0521:1.5
	pgoyette-compat-0502:1.5
	pgoyette-compat-0422:1.5
	netbsd-8-0-RC1:1.5
	pgoyette-compat-0415:1.5
	pgoyette-compat-0407:1.5
	pgoyette-compat-0330:1.5
	pgoyette-compat-0322:1.5
	pgoyette-compat-0315:1.5
	netbsd-7-1-2-RELEASE:1.5
	pgoyette-compat:1.5.0.28
	pgoyette-compat-base:1.5
	netbsd-7-1-1-RELEASE:1.5
	matt-nb8-mediatek:1.5.0.26
	matt-nb8-mediatek-base:1.5
	perseant-stdc-iso10646:1.5.0.24
	perseant-stdc-iso10646-base:1.5
	netbsd-8:1.5.0.22
	netbsd-8-base:1.5
	prg-localcount2-base3:1.5
	prg-localcount2-base2:1.5
	prg-localcount2-base1:1.5
	prg-localcount2:1.5.0.20
	prg-localcount2-base:1.5
	pgoyette-localcount-20170426:1.5
	bouyer-socketcan-base1:1.5
	pgoyette-localcount-20170320:1.5
	netbsd-7-1:1.5.0.18
	netbsd-7-1-RELEASE:1.5
	netbsd-7-1-RC2:1.5
	netbsd-7-nhusb-base-20170116:1.5
	bouyer-socketcan:1.5.0.16
	bouyer-socketcan-base:1.5
	pgoyette-localcount-20170107:1.5
	netbsd-7-1-RC1:1.5
	pgoyette-localcount-20161104:1.5
	netbsd-7-0-2-RELEASE:1.5
	localcount-20160914:1.5
	netbsd-7-nhusb:1.5.0.14
	netbsd-7-nhusb-base:1.5
	pgoyette-localcount-20160806:1.5
	pgoyette-localcount-20160726:1.5
	pgoyette-localcount:1.5.0.12
	pgoyette-localcount-base:1.5
	netbsd-7-0-1-RELEASE:1.5
	netbsd-7-0:1.5.0.10
	netbsd-7-0-RELEASE:1.5
	netbsd-7-0-RC3:1.5
	netbsd-7-0-RC2:1.5
	netbsd-7-0-RC1:1.5
	netbsd-5-2-3-RELEASE:1.2
	netbsd-5-1-5-RELEASE:1.2
	netbsd-6-0-6-RELEASE:1.4
	netbsd-6-1-5-RELEASE:1.4
	netbsd-7:1.5.0.8
	netbsd-7-base:1.5
	yamt-pagecache-base9:1.5
	yamt-pagecache-tag8:1.4
	netbsd-6-1-4-RELEASE:1.4
	netbsd-6-0-5-RELEASE:1.4
	tls-earlyentropy:1.5.0.6
	tls-earlyentropy-base:1.5
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.5
	riastradh-drm2-base3:1.5
	netbsd-6-1-3-RELEASE:1.4
	netbsd-6-0-4-RELEASE:1.4
	netbsd-5-2-2-RELEASE:1.2
	netbsd-5-1-4-RELEASE:1.2
	netbsd-6-1-2-RELEASE:1.4
	netbsd-6-0-3-RELEASE:1.4
	netbsd-5-2-1-RELEASE:1.2
	netbsd-5-1-3-RELEASE:1.2
	netbsd-6-1-1-RELEASE:1.4
	riastradh-drm2-base2:1.5
	riastradh-drm2-base1:1.5
	riastradh-drm2:1.5.0.4
	riastradh-drm2-base:1.5
	netbsd-6-1:1.4.0.16
	netbsd-6-0-2-RELEASE:1.4
	netbsd-6-1-RELEASE:1.4
	netbsd-6-1-RC4:1.4
	netbsd-6-1-RC3:1.4
	agc-symver:1.5.0.2
	agc-symver-base:1.5
	netbsd-6-1-RC2:1.4
	netbsd-6-1-RC1:1.4
	yamt-pagecache-base8:1.4
	netbsd-5-2:1.2.0.4
	netbsd-6-0-1-RELEASE:1.4
	yamt-pagecache-base7:1.4
	netbsd-5-2-RELEASE:1.2
	netbsd-5-2-RC1:1.2
	matt-nb6-plus-nbase:1.4
	yamt-pagecache-base6:1.4
	netbsd-6-0:1.4.0.12
	netbsd-6-0-RELEASE:1.4
	netbsd-6-0-RC2:1.4
	tls-maxphys:1.4.0.10
	tls-maxphys-base:1.5
	matt-nb6-plus:1.4.0.8
	matt-nb6-plus-base:1.4
	netbsd-6-0-RC1:1.4
	yamt-pagecache-base5:1.4
	yamt-pagecache-base4:1.4
	netbsd-6:1.4.0.6
	netbsd-6-base:1.4
	netbsd-5-1-2-RELEASE:1.2
	netbsd-5-1-1-RELEASE:1.2
	yamt-pagecache-base3:1.4
	yamt-pagecache-base2:1.4
	yamt-pagecache:1.4.0.4
	yamt-pagecache-base:1.4
	cherry-xenmp:1.4.0.2
	cherry-xenmp-base:1.4
	bouyer-quota2-nbase:1.4
	bouyer-quota2:1.3.0.4
	bouyer-quota2-base:1.3
	matt-mips64-premerge-20101231:1.3
	matt-nb5-mips64-premerge-20101231:1.2
	matt-nb5-pq3:1.2.0.14
	matt-nb5-pq3-base:1.2
	netbsd-5-1:1.2.0.12
	netbsd-5-1-RELEASE:1.2
	netbsd-5-1-RC4:1.2
	matt-nb5-mips64-k15:1.2
	netbsd-5-1-RC3:1.2
	netbsd-5-1-RC2:1.2
	netbsd-5-1-RC1:1.2
	netbsd-5-0-2-RELEASE:1.2
	matt-nb5-mips64-premerge-20091211:1.2
	matt-premerge-20091211:1.3
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.2
	matt-nb4-mips64-k7-u2a-k9b:1.2
	matt-nb5-mips64-u1-k1-k5:1.2
	matt-nb5-mips64:1.2.0.10
	netbsd-5-0-1-RELEASE:1.2
	jym-xensuspend-nbase:1.3
	netbsd-5-0:1.2.0.8
	netbsd-5-0-RELEASE:1.2
	netbsd-5-0-RC4:1.2
	netbsd-5-0-RC3:1.2
	netbsd-5-0-RC2:1.2
	jym-xensuspend:1.3.0.2
	jym-xensuspend-base:1.3
	netbsd-5-0-RC1:1.2
	netbsd-5:1.2.0.6
	netbsd-5-base:1.2
	matt-mips64-base2:1.2
	wrstuden-revivesa-base-3:1.2
	wrstuden-revivesa-base-2:1.2
	wrstuden-revivesa-base-1:1.2
	yamt-pf42-base4:1.2
	yamt-pf42-base3:1.2
	hpcarm-cleanup-nbase:1.2
	yamt-pf42-baseX:1.1
	yamt-pf42-base2:1.2
	wrstuden-revivesa:1.2.0.2
	wrstuden-revivesa-base:1.2
	yamt-pf42:1.1.0.8
	yamt-pf42-base:1.1
	keiichi-mipv6-nbase:1.1
	hpcarm-cleanup-base:1.1
	keiichi-mipv6:1.1.0.6
	keiichi-mipv6-base:1.1
	matt-armv6-base:1.1
	matt-armv6:1.1.0.4
	matt-armv6-nbase:1.1
	cube-autoconf:1.1.0.2
	cube-autoconf-base:1.1;
locks; strict;
comment	@# @;


1.6
date	2024.04.28.07.27.41;	author rillig;	state Exp;
branches;
next	1.5;
commitid	MCYfSwtZvLAjIS7F;

1.5
date	2013.03.17.01.16.45;	author jmmv;	state Exp;
branches;
next	1.4;

1.4
date	2011.02.21.10.14.29;	author pooka;	state Exp;
branches
	1.4.4.1
	1.4.10.1;
next	1.3;

1.3
date	2009.01.19.07.15.46;	author jmmv;	state Exp;
branches
	1.3.4.1;
next	1.2;

1.2
date	2008.04.30.13.11.00;	author martin;	state Exp;
branches;
next	1.1;

1.1
date	2007.11.12.15.18.21;	author jmmv;	state Exp;
branches
	1.1.4.1
	1.1.8.1;
next	;

1.4.4.1
date	2014.05.22.11.42.19;	author yamt;	state Exp;
branches;
next	;
commitid	30ZGlhv2KNB1MwBx;

1.4.10.1
date	2013.06.23.06.28.56;	author tls;	state Exp;
branches;
next	;
commitid	OnlO1cBgtQRcIHUw;

1.3.4.1
date	2011.03.05.15.10.54;	author bouyer;	state Exp;
branches;
next	;

1.1.4.1
date	2007.11.12.15.18.21;	author matt;	state dead;
branches;
next	1.1.4.2;

1.1.4.2
date	2008.01.09.01.59.11;	author matt;	state Exp;
branches;
next	;

1.1.8.1
date	2008.05.18.12.36.01;	author yamt;	state Exp;
branches;
next	;


desc
@@


1.6
log
@tests: replace deprecated '-s eq:...' with '-s exit:...'
@
text
@#!/bin/sh
#
# $NetBSD: h_funcs.subr,v 1.5 2013/03/17 01:16:45 jmmv Exp $
#
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

Mount_Point=

#
# test_mount [args]
#
#	Mounts tmpfs over ${Mount_Point} and changes the current directory
#	to the mount point.  Optional arguments may be passed to the
#	mount command.
#
test_mount() {
	require_fs tmpfs

	Mount_Point=$(pwd)/mntpt
	atf_check -s exit:0 -o empty -e empty mkdir "${Mount_Point}"
	echo "mount -t tmpfs ${*} tmpfs ${Mount_Point}"
	mount -t tmpfs "${@@}" tmpfs "${Mount_Point}" 2>mounterr
	if [ "${?}" -ne 0 ]; then
		cat mounterr 1>&2
		if grep 'Operation not supported' mounterr > /dev/null; then
			atf_skip "tmpfs not supported"
		fi 
		atf_fail "Failed to mount a tmpfs file system"
	fi
	cd "${Mount_Point}"
}

#
# test_unmount
#
#	Unmounts the file system mounted by test_mount.
#
test_unmount() {
	cd - >/dev/null
	atf_check -s exit:0 -o empty -e empty umount ${Mount_Point}
	atf_check -s exit:0 -o empty -e empty rmdir ${Mount_Point}
	Mount_Point=
}

#
# kqueue_monitor expected_nevents file1 [.. fileN]
#
#	Monitors the commands given through stdin (one per line) using
#	kqueue and stores the events raised in a log that can be later
#	verified with kqueue_check.
#
kqueue_monitor() {
	nev=${1}; shift
	echo "Running kqueue-monitored commands and expecting" \
	    "${nev} events"
	$(atf_get_srcdir)/h_tools kqueue ${*} >kqueue.log || \
	    atf_fail "Could not launch kqueue monitor"
	got=$(wc -l kqueue.log | awk '{ print $1 }')
	test ${got} -eq ${nev} || \
	    atf_fail "Got ${got} events but expected ${nev}"
}

#
# kqueue_check file event
#
#	Checks if kqueue raised the given event when monitoring the
#	given file.
#
kqueue_check() {
	echo "Checking if ${1} received ${2}"
	grep "^${1} - ${2}$" kqueue.log >/dev/null || \
	    atf_fail "${1} did not receive ${2}"
}
@


1.5
log
@Simplify test_mount and log errors.

If mount_tmpfs fails, show what the stderr output of the command was instead
of failing without details.

While doing this, remove the stupidity to deal with the optional arguments
to the test_mount routine.
@
text
@d3 1
a3 1
# $NetBSD: h_funcs.subr,v 1.4 2011/02/21 10:14:29 pooka Exp $
d43 1
a43 1
	atf_check -s eq:0 -o empty -e empty mkdir "${Mount_Point}"
d63 2
a64 2
	atf_check -s eq:0 -o empty -e empty umount ${Mount_Point}
	atf_check -s eq:0 -o empty -e empty rmdir ${Mount_Point}
@


1.4
log
@Skip instead of fail test if tmpfs cannot be mounted and the
error is "Operation not supported".

makes the tmpfs tests produce a sensible result on platforms where
tmpfs is not available (such as the hpc* test runs)
@
text
@d3 1
a3 1
# $NetBSD: h_funcs.subr,v 1.3 2009/01/19 07:15:46 jmmv Exp $
d43 9
a51 17
	atf_check -s eq:0 -o empty -e empty mkdir ${Mount_Point}
	if [ $# -gt 0 ]; then
		mount -t tmpfs $* tmpfs ${Mount_Point} 2> mounterr
		if [ $? -ne 0 ]; then
			if grep 'Operation not supp' mounterr > /dev/null ; then
				atf_skip "tmpfs not supported"
			fi 
			atf_fail "mount tmpfs"
		fi
        else
		mount -t tmpfs tmpfs ${Mount_Point} 2> mounterr
		if [ $? -ne 0 ]; then
			if grep 'Operation not supp' mounterr > /dev/null ; then
				atf_skip "tmpfs not supported"
			fi 
			atf_fail "mount tmpfs"
		fi
d53 1
a53 1
	cd ${Mount_Point}
@


1.4.4.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d3 1
a3 1
# $NetBSD: h_funcs.subr,v 1.4 2011/02/21 10:14:29 pooka Exp $
d43 17
a59 9
	atf_check -s eq:0 -o empty -e empty mkdir "${Mount_Point}"
	echo "mount -t tmpfs ${*} tmpfs ${Mount_Point}"
	mount -t tmpfs "${@@}" tmpfs "${Mount_Point}" 2>mounterr
	if [ "${?}" -ne 0 ]; then
		cat mounterr 1>&2
		if grep 'Operation not supported' mounterr > /dev/null; then
			atf_skip "tmpfs not supported"
		fi 
		atf_fail "Failed to mount a tmpfs file system"
d61 1
a61 1
	cd "${Mount_Point}"
@


1.4.10.1
log
@resync from head
@
text
@d3 1
a3 1
# $NetBSD$
d43 17
a59 9
	atf_check -s eq:0 -o empty -e empty mkdir "${Mount_Point}"
	echo "mount -t tmpfs ${*} tmpfs ${Mount_Point}"
	mount -t tmpfs "${@@}" tmpfs "${Mount_Point}" 2>mounterr
	if [ "${?}" -ne 0 ]; then
		cat mounterr 1>&2
		if grep 'Operation not supported' mounterr > /dev/null; then
			atf_skip "tmpfs not supported"
		fi 
		atf_fail "Failed to mount a tmpfs file system"
d61 1
a61 1
	cd "${Mount_Point}"
@


1.3
log
@Adjust tests to work with the new API in ATF 0.6.
@
text
@d3 1
a3 1
# $NetBSD: h_funcs.subr,v 1.2 2008/04/30 13:11:00 martin Exp $
d45 15
a59 5
		atf_check -s eq:0 -o empty -e empty \
		    mount -t tmpfs $* tmpfs ${Mount_Point}
	else
		atf_check -s eq:0 -o empty -e empty \
		    mount -t tmpfs tmpfs ${Mount_Point}
@


1.3.4.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $NetBSD$
d45 5
a49 15
		mount -t tmpfs $* tmpfs ${Mount_Point} 2> mounterr
		if [ $? -ne 0 ]; then
			if grep 'Operation not supp' mounterr > /dev/null ; then
				atf_skip "tmpfs not supported"
			fi 
			atf_fail "mount tmpfs"
		fi
        else
		mount -t tmpfs tmpfs ${Mount_Point} 2> mounterr
		if [ $? -ne 0 ]; then
			if grep 'Operation not supp' mounterr > /dev/null ; then
				atf_skip "tmpfs not supported"
			fi 
			atf_fail "mount tmpfs"
		fi
@


1.2
log
@Convert TNF licenses to new 2 clause variant
@
text
@d3 1
a3 1
# $NetBSD: h_funcs.subr,v 1.1 2007/11/12 15:18:21 jmmv Exp $
d43 1
a43 1
	atf_check "mkdir ${Mount_Point}" 0 null null
d45 2
a46 2
		atf_check "mount -t tmpfs $* tmpfs ${Mount_Point}" \
		    0 null null
d48 2
a49 2
		atf_check "mount -t tmpfs tmpfs ${Mount_Point}" \
		    0 null null
d61 2
a62 2
	atf_check "umount ${Mount_Point}" 0 null null
	atf_check "rmdir ${Mount_Point}" 0 null null
@


1.1
log
@Convert the regress/sys/fs/tmpfs tests to the atf

This change converts all the existing regression tests in
regress/sys/fs/tmpfs to the new framework provided by atf.  As a side
effect, this also moves all the tests programs in regress/sys/fs/tmpfs to
tests/fs/tmpfs.
@
text
@d3 1
a3 1
# $NetBSD$
a15 7
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#        This product includes software developed by the NetBSD
#        Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
@


1.1.8.1
log
@sync with head.
@
text
@d3 1
a3 1
# $NetBSD: h_funcs.subr,v 1.1 2007/11/12 15:18:21 jmmv Exp $
d16 7
@


1.1.4.1
log
@file h_funcs.subr was added on branch matt-armv6 on 2008-01-09 01:59:11 +0000
@
text
@d1 101
@


1.1.4.2
log
@sync with HEAD
@
text
@a0 101
#!/bin/sh
#
# $NetBSD$
#
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#        This product includes software developed by the NetBSD
#        Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

Mount_Point=

#
# test_mount [args]
#
#	Mounts tmpfs over ${Mount_Point} and changes the current directory
#	to the mount point.  Optional arguments may be passed to the
#	mount command.
#
test_mount() {
	require_fs tmpfs

	Mount_Point=$(pwd)/mntpt
	atf_check "mkdir ${Mount_Point}" 0 null null
	if [ $# -gt 0 ]; then
		atf_check "mount -t tmpfs $* tmpfs ${Mount_Point}" \
		    0 null null
	else
		atf_check "mount -t tmpfs tmpfs ${Mount_Point}" \
		    0 null null
	fi
	cd ${Mount_Point}
}

#
# test_unmount
#
#	Unmounts the file system mounted by test_mount.
#
test_unmount() {
	cd - >/dev/null
	atf_check "umount ${Mount_Point}" 0 null null
	atf_check "rmdir ${Mount_Point}" 0 null null
	Mount_Point=
}

#
# kqueue_monitor expected_nevents file1 [.. fileN]
#
#	Monitors the commands given through stdin (one per line) using
#	kqueue and stores the events raised in a log that can be later
#	verified with kqueue_check.
#
kqueue_monitor() {
	nev=${1}; shift
	echo "Running kqueue-monitored commands and expecting" \
	    "${nev} events"
	$(atf_get_srcdir)/h_tools kqueue ${*} >kqueue.log || \
	    atf_fail "Could not launch kqueue monitor"
	got=$(wc -l kqueue.log | awk '{ print $1 }')
	test ${got} -eq ${nev} || \
	    atf_fail "Got ${got} events but expected ${nev}"
}

#
# kqueue_check file event
#
#	Checks if kqueue raised the given event when monitoring the
#	given file.
#
kqueue_check() {
	echo "Checking if ${1} received ${2}"
	grep "^${1} - ${2}$" kqueue.log >/dev/null || \
	    atf_fail "${1} did not receive ${2}"
}
@
