t_mknod.sh revision 1.1.4.2 1 # $NetBSD: t_mknod.sh,v 1.1.4.2 2008/01/09 01:59:16 matt Exp $
2 #
3 # Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
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.
14 # 3. All advertising materials mentioning features or use of this software
15 # must display the following acknowledgement:
16 # This product includes software developed by the NetBSD
17 # Foundation, Inc. and its contributors.
18 # 4. Neither the name of The NetBSD Foundation nor the names of its
19 # contributors may be used to endorse or promote products derived
20 # from this software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 #
34
35 #
36 # Verifies that the mknod operation works.
37 #
38
39 atf_test_case block
40 block_head() {
41 atf_set "descr" "Tests that block devices can be created"
42 atf_set "require.user" "root"
43 }
44 block_body() {
45 test_mount
46 umask 022
47
48 atf_check 'mknod fd0a b 2 0' 0 null null
49 eval $(stat -s fd0a)
50 [ ${st_mode} = 060644 ] || atf_fail "Invalid mode"
51 [ ${st_rdev} -eq 512 ] || atf_fail "Invalid device"
52
53 test_unmount
54 }
55
56 atf_test_case block_kqueue
57 block_kqueue_head() {
58 atf_set "descr" "Tests that creating a block device raises the" \
59 "appropriate kqueue events"
60 atf_set "require.user" "root"
61 }
62 block_kqueue_body() {
63 test_mount
64 umask 022
65
66 atf_check 'mkdir dir' 0 null null
67 echo 'mknod dir/fd0a b 2 0' | kqueue_monitor 1 dir
68 kqueue_check dir NOTE_WRITE
69
70 test_unmount
71 }
72
73 atf_test_case char
74 char_head() {
75 atf_set "descr" "Tests that character devices can be created"
76 atf_set "require.user" "root"
77 }
78 char_body() {
79 test_mount
80 umask 022
81
82 atf_check 'mknod null c 2 2' 0 null null
83 eval $(stat -s null)
84 [ ${st_mode} = 020644 ] || atf_fail "Invalid mode"
85 [ ${st_rdev} -eq 514 ] || atf_fail "Invalid device"
86
87 test_unmount
88 }
89
90 atf_test_case char_kqueue
91 char_kqueue_head() {
92 atf_set "descr" "Tests that creating a character device raises the" \
93 "appropriate kqueue events"
94 atf_set "require.user" "root"
95 }
96 char_kqueue_body() {
97 test_mount
98 umask 022
99
100 atf_check 'mkdir dir' 0 null null
101 echo 'mknod dir/null c 2 2' | kqueue_monitor 1 dir
102 kqueue_check dir NOTE_WRITE
103
104 test_unmount
105 }
106
107 atf_test_case pipe
108 pipe_head() {
109 atf_set "descr" "Tests that named pipes can be created"
110 atf_set "require.user" "root"
111 }
112 pipe_body() {
113 test_mount
114 umask 022
115
116 atf_check 'mknod pipe p' 0 null null
117 eval $(stat -s pipe)
118 [ ${st_mode} = 010644 ] || atf_fail "Invalid mode"
119
120 test_unmount
121 }
122
123 atf_test_case pipe_kqueue
124 pipe_kqueue_head() {
125 atf_set "descr" "Tests that creating a named pipe raises the" \
126 "appropriate kqueue events"
127 atf_set "require.user" "root"
128 }
129 pipe_kqueue_body() {
130 test_mount
131 umask 022
132
133 atf_check 'mkdir dir' 0 null null
134 echo 'mknod dir/pipe p' | kqueue_monitor 1 dir
135 kqueue_check dir NOTE_WRITE
136
137 test_unmount
138 }
139
140 atf_init_test_cases() {
141 . $(atf_get_srcdir)/../h_funcs.subr
142 . $(atf_get_srcdir)/h_funcs.subr
143
144 atf_add_test_case block
145 atf_add_test_case block_kqueue
146 atf_add_test_case char
147 atf_add_test_case char_kqueue
148 atf_add_test_case pipe
149 atf_add_test_case pipe_kqueue
150 }
151