3 # $NetBSD: h_funcs.subr,v 1.2 2008/04/30 13:11:00 martin Exp $
5 # Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
35 # Mounts tmpfs over ${Mount_Point} and changes the current directory
36 # to the mount point. Optional arguments may be passed to the
42 Mount_Point
=$
(pwd)/mntpt
43 atf_check
-s eq
:0 -o empty
-e empty mkdir
${Mount_Point}
45 atf_check
-s eq
:0 -o empty
-e empty \
46 mount
-t tmpfs $
* tmpfs
${Mount_Point}
48 atf_check
-s eq
:0 -o empty
-e empty \
49 mount
-t tmpfs tmpfs
${Mount_Point}
57 # Unmounts the file system mounted by test_mount.
61 atf_check
-s eq
:0 -o empty
-e empty umount
${Mount_Point}
62 atf_check
-s eq
:0 -o empty
-e empty
rmdir ${Mount_Point}
67 # kqueue_monitor expected_nevents file1 [.. fileN]
69 # Monitors the commands given through stdin (one per line) using
70 # kqueue and stores the events raised in a log that can be later
71 # verified with kqueue_check.
75 echo "Running kqueue-monitored commands and expecting" \
77 $
(atf_get_srcdir
)/h_tools kqueue
${*} >kqueue.log || \
78 atf_fail
"Could not launch kqueue monitor"
79 got
=$
(wc -l kqueue.log |
awk '{ print $1 }')
80 test ${got} -eq ${nev} || \
81 atf_fail
"Got ${got} events but expected ${nev}"
85 # kqueue_check file event
87 # Checks if kqueue raised the given event when monitoring the
91 echo "Checking if ${1} received ${2}"
92 grep "^${1} - ${2}$" kqueue.log
>/dev
/null || \
93 atf_fail
"${1} did not receive ${2}"