1 # $NetBSD: t_mknod.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
3 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
29 # Verifies that the mknod operation works.
34 atf_set
"descr" "Tests that block devices can be created"
35 atf_set
"require.user" "root"
41 atf_check
-s eq
:0 -o empty
-e empty mknod fd0a b
2 0
43 [ ${st_mode} = 060644 ] || atf_fail
"Invalid mode"
44 [ ${st_rdev} -eq 512 ] || atf_fail
"Invalid device"
49 atf_test_case block_kqueue
51 atf_set
"descr" "Tests that creating a block device raises the" \
52 "appropriate kqueue events"
53 atf_set
"require.user" "root"
59 atf_check
-s eq
:0 -o empty
-e empty mkdir dir
60 echo 'mknod dir/fd0a b 2 0' | kqueue_monitor
1 dir
61 kqueue_check dir NOTE_WRITE
68 atf_set
"descr" "Tests that character devices can be created"
69 atf_set
"require.user" "root"
75 atf_check
-s eq
:0 -o empty
-e empty mknod null c
2 2
77 [ ${st_mode} = 020644 ] || atf_fail
"Invalid mode"
78 [ ${st_rdev} -eq 514 ] || atf_fail
"Invalid device"
83 atf_test_case char_kqueue
85 atf_set
"descr" "Tests that creating a character device raises the" \
86 "appropriate kqueue events"
87 atf_set
"require.user" "root"
93 atf_check
-s eq
:0 -o empty
-e empty mkdir dir
94 echo 'mknod dir/null c 2 2' | kqueue_monitor
1 dir
95 kqueue_check dir NOTE_WRITE
102 atf_set
"descr" "Tests that named pipes can be created"
103 atf_set
"require.user" "root"
109 atf_check
-s eq
:0 -o empty
-e empty mknod pipe p
111 [ ${st_mode} = 010644 ] || atf_fail
"Invalid mode"
116 atf_test_case pipe_kqueue
118 atf_set
"descr" "Tests that creating a named pipe raises the" \
119 "appropriate kqueue events"
120 atf_set
"require.user" "root"
126 atf_check
-s eq
:0 -o empty
-e empty mkdir dir
127 echo 'mknod dir/pipe p' | kqueue_monitor
1 dir
128 kqueue_check dir NOTE_WRITE
133 atf_init_test_cases
() {
134 . $
(atf_get_srcdir
)/..
/h_funcs.subr
135 . $
(atf_get_srcdir
)/h_funcs.subr
137 atf_add_test_case block
138 atf_add_test_case block_kqueue
139 atf_add_test_case char
140 atf_add_test_case char_kqueue
141 atf_add_test_case pipe
142 atf_add_test_case pipe_kqueue