etc/services - sync with NetBSD-8
[minix.git] / tests / fs / tmpfs / t_setattr.sh
blobf64344646e480cbf460fd26e174366064f615d5b
1 # $NetBSD: t_setattr.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
3 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
4 # All rights reserved.
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.
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 setattr vnode operation works, using several commands
30 # that require this function.
33 atf_test_case chown
34 chown_head() {
35 atf_set "descr" "Tests that the file owner can be changed"
36 atf_set "require.user" "root"
38 chown_body() {
39 test_mount
41 atf_check -s eq:0 -o empty -e empty mkdir own
42 eval $(stat -s own | sed -e 's|st_|ost_|g')
43 atf_check -s eq:0 -o empty -e empty chown 1234 own
44 eval $(stat -s own)
45 [ ${st_uid} -eq 1234 ] || atf_fail "uid was not set"
46 [ ${st_gid} -eq ${ost_gid} ] || atf_fail "gid was modified"
48 test_unmount
51 atf_test_case chown_kqueue
52 chown_kqueue_head() {
53 atf_set "descr" "Tests that changing the file owner raises" \
54 "NOTE_ATTRIB on it"
55 atf_set "require.user" "root"
57 chown_kqueue_body() {
58 test_mount
60 atf_check -s eq:0 -o empty -e empty mkdir ownq
61 echo 'chown 1234 ownq' | kqueue_monitor 1 ownq
62 kqueue_check ownq NOTE_ATTRIB
64 test_unmount
67 atf_test_case chgrp
68 chgrp_head() {
69 atf_set "descr" "Tests that the file group can be changed"
70 atf_set "require.user" "root"
72 chgrp_body() {
73 test_mount
75 atf_check -s eq:0 -o empty -e empty mkdir grp
76 eval $(stat -s grp | sed -e 's|st_|ost_|g')
77 atf_check -s eq:0 -o empty -e empty chgrp 5678 grp
78 eval $(stat -s grp)
79 [ ${st_uid} -eq ${ost_uid} ] || atf_fail "uid was modified"
80 [ ${st_gid} -eq 5678 ] || atf_fail "gid was not set"
82 test_unmount
85 atf_test_case chgrp_kqueue
86 chgrp_kqueue_head() {
87 atf_set "descr" "Tests that changing the file group raises" \
88 "NOTE_ATTRIB on it"
89 atf_set "require.user" "root"
91 chgrp_kqueue_body() {
92 test_mount
94 atf_check -s eq:0 -o empty -e empty mkdir grpq
95 echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq
96 kqueue_check grpq NOTE_ATTRIB
98 test_unmount
101 atf_test_case chowngrp
102 chowngrp_head() {
103 atf_set "descr" "Tests that the file owner and group can be" \
104 "changed at once"
105 atf_set "require.user" "root"
107 chowngrp_body() {
108 test_mount
110 atf_check -s eq:0 -o empty -e empty mkdir owngrp
111 atf_check -s eq:0 -o empty -e empty chown 1234:5678 owngrp
112 eval $(stat -s owngrp)
113 [ ${st_uid} -eq 1234 ] || atf_fail "uid was not modified"
114 [ ${st_gid} -eq 5678 ] || atf_fail "gid was not modified"
116 test_unmount
119 atf_test_case chowngrp_kqueue
120 chowngrp_kqueue_head() {
121 atf_set "descr" "Tests that changing the file owner and group" \
122 "raises NOTE_ATTRIB on it"
123 atf_set "require.user" "root"
125 chowngrp_kqueue_body() {
126 test_mount
128 atf_check -s eq:0 -o empty -e empty mkdir owngrpp
129 echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp
130 kqueue_check owngrpp NOTE_ATTRIB
132 test_unmount
135 atf_test_case chmod
136 chmod_head() {
137 atf_set "descr" "Tests that the file mode can be changed"
138 atf_set "require.user" "root"
140 chmod_body() {
141 test_mount
143 atf_check -s eq:0 -o empty -e empty mkdir mode
144 atf_check -s eq:0 -o empty -e empty chmod 0000 mode
145 eval $(stat -s mode)
146 [ ${st_mode} -eq 40000 ] || af_fail "mode was not set"
148 test_unmount
151 atf_test_case chmod_kqueue
152 chmod_kqueue_head() {
153 atf_set "descr" "Tests that changing the file mode raises" \
154 "NOTE_ATTRIB on it"
155 atf_set "require.user" "root"
157 chmod_kqueue_body() {
158 test_mount
160 atf_check -s eq:0 -o empty -e empty mkdir modeq
161 echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq
162 kqueue_check modeq NOTE_ATTRIB
164 test_unmount
167 atf_test_case chtimes
168 chtimes_head() {
169 atf_set "descr" "Tests that file times can be changed"
170 atf_set "require.user" "root"
172 chtimes_body() {
173 test_mount
175 atf_check -s eq:0 -o empty -e empty mkdir times
176 atf_check -s eq:0 -o empty -e empty \
177 -x 'TZ=GMT touch -t 200501010101 times'
178 eval $(stat -s times)
179 [ ${st_atime} = ${st_mtime} ] || \
180 atf_fail "atime does not match mtime"
181 [ ${st_atime} = 1104541260 ] || atf_fail "atime does not match"
183 test_unmount
186 atf_test_case chtimes_kqueue
187 chtimes_kqueue_head() {
188 atf_set "descr" "Tests that changing the file times raises" \
189 "NOTE_ATTRIB on it"
190 atf_set "require.user" "root"
192 chtimes_kqueue_body() {
193 test_mount
195 atf_check -s eq:0 -o empty -e empty mkdir timesq
196 echo 'touch timesq' | kqueue_monitor 1 timesq
197 kqueue_check timesq NOTE_ATTRIB
199 test_unmount
202 atf_init_test_cases() {
203 . $(atf_get_srcdir)/../h_funcs.subr
204 . $(atf_get_srcdir)/h_funcs.subr
206 atf_add_test_case chown
207 atf_add_test_case chown_kqueue
208 atf_add_test_case chgrp
209 atf_add_test_case chgrp_kqueue
210 atf_add_test_case chowngrp
211 atf_add_test_case chowngrp_kqueue
212 atf_add_test_case chmod
213 atf_add_test_case chmod_kqueue
214 atf_add_test_case chtimes
215 atf_add_test_case chtimes_kqueue