t_setattr revision 170809
1170809Sdelphij#!/bin/sh 2170809Sdelphij# 3170809Sdelphij# $NetBSD: t_setattr,v 1.6 2006/11/09 16:20:06 jmmv Exp $ 4170809Sdelphij# 5170809Sdelphij# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 6170809Sdelphij# All rights reserved. 7170809Sdelphij# 8170809Sdelphij# This code is derived from software contributed to The NetBSD Foundation 9170809Sdelphij# by Julio M. Merino Vidal, developed as part of Google's Summer of Code 10170809Sdelphij# 2005 program. 11170809Sdelphij# 12170809Sdelphij# Redistribution and use in source and binary forms, with or without 13170809Sdelphij# modification, are permitted provided that the following conditions 14170809Sdelphij# are met: 15170809Sdelphij# 1. Redistributions of source code must retain the above copyright 16170809Sdelphij# notice, this list of conditions and the following disclaimer. 17170809Sdelphij# 2. Redistributions in binary form must reproduce the above copyright 18170809Sdelphij# notice, this list of conditions and the following disclaimer in the 19170809Sdelphij# documentation and/or other materials provided with the distribution. 20170809Sdelphij# 3. All advertising materials mentioning features or use of this software 21170809Sdelphij# must display the following acknowledgement: 22170809Sdelphij# This product includes software developed by the NetBSD 23170809Sdelphij# Foundation, Inc. and its contributors. 24170809Sdelphij# 4. Neither the name of The NetBSD Foundation nor the names of its 25170809Sdelphij# contributors may be used to endorse or promote products derived 26170809Sdelphij# from this software without specific prior written permission. 27170809Sdelphij# 28170809Sdelphij# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 29170809Sdelphij# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 30170809Sdelphij# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31170809Sdelphij# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 32170809Sdelphij# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33170809Sdelphij# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34170809Sdelphij# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35170809Sdelphij# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36170809Sdelphij# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37170809Sdelphij# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38170809Sdelphij# POSSIBILITY OF SUCH DAMAGE. 39170809Sdelphij# 40170809Sdelphij# $FreeBSD: head/tools/regression/tmpfs/t_setattr 170809 2007-06-16 02:04:44Z delphij $ 41170809Sdelphij# 42170809Sdelphij 43170809Sdelphij# 44170809Sdelphij# Verifies that the setattr vnode operation works, using several commands 45170809Sdelphij# that require this function. 46170809Sdelphij# 47170809Sdelphij 48170809Sdelphijtest_run() { 49170809Sdelphij test_mount 50170809Sdelphij 51170809Sdelphij test_name "File owner can be changed on its own" 52170809Sdelphij mkdir own || die 53170809Sdelphij eval $(stat -s own | sed -e 's|st_|ost_|g') 54170809Sdelphij chown 1234 own || die 55170809Sdelphij eval $(stat -s own) 56170809Sdelphij [ ${st_uid} -eq 1234 ] || die 57170809Sdelphij [ ${st_gid} -eq ${ost_gid} ] || die 58170809Sdelphij 59170809Sdelphij mkdir ownq || die 60170809Sdelphij echo 'chown 1234 ownq' | kqueue_monitor 1 ownq || die 61170809Sdelphij test_name "Changing a file's owner raises NOTE_ATTRIB on it" 62170809Sdelphij kqueue_check ownq NOTE_ATTRIB || die 63170809Sdelphij 64170809Sdelphij test_name "File group can be changed on its own" 65170809Sdelphij mkdir grp || die 66170809Sdelphij eval $(stat -s grp | sed -e 's|st_|ost_|g') 67170809Sdelphij chgrp 5678 grp || die 68170809Sdelphij eval $(stat -s grp) 69170809Sdelphij [ ${st_uid} -eq ${ost_uid} ] || die 70170809Sdelphij [ ${st_gid} -eq 5678 ] || die 71170809Sdelphij 72170809Sdelphij mkdir grpq || die 73170809Sdelphij echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq || die 74170809Sdelphij test_name "Changing a file's group raises NOTE_ATTRIB on it" 75170809Sdelphij kqueue_check grpq NOTE_ATTRIB || die 76170809Sdelphij 77170809Sdelphij test_name "File owner and group can be changed at once" 78170809Sdelphij mkdir owngrp || die 79170809Sdelphij chown 1234:5678 owngrp || die 80170809Sdelphij eval $(stat -s owngrp) 81170809Sdelphij [ ${st_uid} -eq 1234 ] || die 82170809Sdelphij [ ${st_gid} -eq 5678 ] || die 83170809Sdelphij 84170809Sdelphij mkdir owngrpp || die 85170809Sdelphij echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp || die 86170809Sdelphij test_name "Changing a file's owner and group raises NOTE_ATTRIB on it" 87170809Sdelphij kqueue_check owngrpp NOTE_ATTRIB || die 88170809Sdelphij 89170809Sdelphij test_name "File mode can be changed" 90170809Sdelphij mkdir mode || die 91170809Sdelphij chmod 0000 mode || die 92170809Sdelphij eval $(stat -s mode) 93170809Sdelphij [ ${st_mode} -eq 40000 ] || die 94170809Sdelphij 95170809Sdelphij mkdir modeq || die 96170809Sdelphij echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq || die 97170809Sdelphij test_name "Updating a file's mode raises NOTE_ATTRIB on it" 98170809Sdelphij kqueue_check modeq NOTE_ATTRIB || die 99170809Sdelphij 100170809Sdelphij test_name "File times can be changed" 101170809Sdelphij mkdir times || die 102170809Sdelphij TZ=GMT touch -t 200501010101 times || die 103170809Sdelphij eval $(stat -s times) 104170809Sdelphij [ ${st_atime} = ${st_mtime} ] || die 105170809Sdelphij [ ${st_atime} = 1104541260 ] || die 106170809Sdelphij 107170809Sdelphij mkdir timesq || die 108170809Sdelphij echo 'touch timesq' | kqueue_monitor 1 timesq || die 109170809Sdelphij test_name "Updating a file's times raises NOTE_ATTRIB on it" 110170809Sdelphij kqueue_check timesq NOTE_ATTRIB || die 111170809Sdelphij 112170809Sdelphij test_unmount 113170809Sdelphij} 114170809Sdelphij 115170809Sdelphij. ${SUBRDIR}/h_funcs.subr 116