# $NetBSD: t_setattr.sh,v 1.6 2024/04/28 07:27:41 rillig Exp $
#
# Copyright (c) 2005, 2006, 2007, 2008 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.
#
#
# Verifies that the setattr vnode operation works, using several commands
# that require this function.
#
atf_test_case chown
chown_head() {
atf_set "descr" "Tests that the file owner can be changed"
atf_set "require.user" "root"
}
chown_body() {
test_mount
atf_check -s exit:0 -o empty -e empty mkdir own
eval $(stat -s own | sed -e 's|st_|ost_|g')
atf_check -s exit:0 -o empty -e empty chown 1234 own
eval $(stat -s own)
[ ${st_uid} -eq 1234 ] || atf_fail "uid was not set"
[ ${st_gid} -eq ${ost_gid} ] || atf_fail "gid was modified"
test_unmount
}
atf_test_case chown_kqueue
chown_kqueue_head() {
atf_set "descr" "Tests that changing the file owner raises" \
"NOTE_ATTRIB on it"
atf_set "require.user" "root"
}
chown_kqueue_body() {
test_mount
atf_test_case chgrp
chgrp_head() {
atf_set "descr" "Tests that the file group can be changed"
atf_set "require.user" "root"
}
chgrp_body() {
test_mount
atf_test_case chowngrp
chowngrp_head() {
atf_set "descr" "Tests that the file owner and group can be" \
"changed at once"
atf_set "require.user" "root"
}
chowngrp_body() {
test_mount
atf_test_case chtimes
chtimes_head() {
atf_set "descr" "Tests that file times can be changed"
atf_set "require.user" "root"
}
chtimes_body() {
test_mount
atf_check -s exit:0 -o empty -e empty mkdir times
atf_check -s exit:0 -o empty -e empty \
-x 'TZ=GMT touch -t 200501010101 times'
eval $(stat -s times)
[ ${st_atime} = ${st_mtime} ] || \
atf_fail "atime does not match mtime"
[ ${st_atime} = 1104541260 ] || atf_fail "atime does not match"
test_unmount
}
atf_test_case chtimes_kqueue
chtimes_kqueue_head() {
atf_set "descr" "Tests that changing the file times raises" \
"NOTE_ATTRIB on it"
atf_set "require.user" "root"
}
chtimes_kqueue_body() {
test_mount