Convert the regress/sys/fs/tmpfs tests to the atf
This change converts all the existing regression tests in regress/sys/fs/tmpfs to the new framework provided by atf. As a side effect, this also moves all the tests programs in regress/sys/fs/tmpfs to tests/fs/tmpfs.
This commit is contained in:
parent
65926be28b
commit
9b7401e7cb
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.3 2007/11/12 15:13:58 jmmv Exp $
|
||||
# $NetBSD: mi,v 1.4 2007/11/12 15:18:07 jmmv Exp $
|
||||
./etc/mtree/set.tests tests-sys-root
|
||||
./usr/tests tests-base-tests
|
||||
./usr/tests/Atffile tests-base-tests
|
||||
@ -219,6 +219,38 @@
|
||||
./usr/tests/atf/units/t_text tests-atf-tests
|
||||
./usr/tests/atf/units/t_user tests-atf-tests
|
||||
./usr/tests/atf/units/t_utils tests-atf-tests
|
||||
./usr/tests/fs tests-fs-tests
|
||||
./usr/tests/fs/Atffile tests-fs-tests
|
||||
./usr/tests/fs/h_funcs.subr tests-fs-tests
|
||||
./usr/tests/fs/tmpfs tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/Atffile tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/h_funcs.subr tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/h_tools tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_create tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_devices tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_dots tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_exec tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_id_gen tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_link tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_mkdir tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_mknod tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_mount tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_pipes tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_read_write tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_readdir tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_remove tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_rename tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_rmdir tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_setattr tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_sizes tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_sockets tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_statvfs tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_symlink tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_times tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_trail_slash tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_truncate tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_vnd tests-fs-tests
|
||||
./usr/tests/fs/tmpfs/t_vnode_leak tests-fs-tests
|
||||
./usr/tests/util tests-util-tests
|
||||
./usr/tests/util/Atffile tests-util-tests
|
||||
./usr/tests/util/df tests-util-tests
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: NetBSD.dist,v 1.350 2007/11/12 15:13:58 jmmv Exp $
|
||||
# $NetBSD: NetBSD.dist,v 1.351 2007/11/12 15:18:07 jmmv Exp $
|
||||
# @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
|
||||
|
||||
# Do not customize this file as it may be overwritten on upgrades.
|
||||
@ -1088,6 +1088,8 @@
|
||||
./usr/tests/atf/test_programs
|
||||
./usr/tests/atf/tools
|
||||
./usr/tests/atf/units
|
||||
./usr/tests/fs
|
||||
./usr/tests/fs/tmpfs
|
||||
./usr/tests/util
|
||||
./usr/tests/util/df
|
||||
./usr/tests/util/ps
|
||||
|
@ -1,5 +1,5 @@
|
||||
# $NetBSD: Makefile,v 1.6 2006/09/21 01:27:32 reinoud Exp $
|
||||
# $NetBSD: Makefile,v 1.7 2007/11/12 15:18:07 jmmv Exp $
|
||||
|
||||
SUBDIR= mkdir getdents posix_fadvise tmpfs lseek
|
||||
SUBDIR= mkdir getdents posix_fadvise lseek
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -1,40 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.4 2006/11/09 15:25:37 jmmv Exp $
|
||||
|
||||
tests= t_mount
|
||||
tests+= t_statvfs
|
||||
tests+= t_mkdir
|
||||
tests+= t_vnode_leak
|
||||
tests+= t_setattr
|
||||
tests+= t_rmdir
|
||||
tests+= t_id_gen
|
||||
tests+= t_trail_slash
|
||||
tests+= t_dots
|
||||
tests+= t_create
|
||||
tests+= t_remove
|
||||
tests+= t_link
|
||||
tests+= t_rename
|
||||
tests+= t_read_write
|
||||
tests+= t_exec
|
||||
tests+= t_truncate
|
||||
tests+= t_sizes
|
||||
tests+= t_times
|
||||
tests+= t_symlink
|
||||
tests+= t_mknod
|
||||
tests+= t_devices
|
||||
tests+= t_pipes
|
||||
tests+= t_sockets
|
||||
tests+= t_readdir
|
||||
tests+= t_vnd
|
||||
|
||||
regress: ${tests}
|
||||
.for t in ${tests}
|
||||
@SUBRDIR=${.CURDIR} ${.CURDIR}/${t} ${TEST_ARGS}
|
||||
.endfor
|
||||
|
||||
PROG= h_tools
|
||||
NOMAN= # defined
|
||||
WARNS= 4
|
||||
|
||||
t_sizes t_sockets t_statvfs: h_tools
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,189 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: h_funcs.subr,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#
|
||||
# Helper functions for tests written in shell script.
|
||||
#
|
||||
|
||||
Prog_Name=${0##*/}
|
||||
Src_Dir=$(pwd)
|
||||
Unprived_User=
|
||||
Verbose=1
|
||||
Work_Dir=$(pwd)/tmp
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# die
|
||||
#
|
||||
# Called by tests when a command fails unexpectedly. Terminates
|
||||
# execution and tries to clean up the mount point.
|
||||
#
|
||||
die() {
|
||||
if [ -d ${Work_Dir} ]; then
|
||||
cd ${Src_Dir}
|
||||
umount ${Work_Dir}
|
||||
rmdir ${Work_Dir}
|
||||
fi
|
||||
[ ${Verbose} -eq 2 ] && err "Test ended unexpectedly"
|
||||
[ ${Verbose} -eq 1 ] && echo " failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# err message
|
||||
#
|
||||
# Shows the given error message and terminates the program.
|
||||
#
|
||||
err() {
|
||||
echo "${Prog_Name}: $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# test_mount [args]
|
||||
#
|
||||
# Mounts tmpfs over ${Work_Dir} and changes the current directory
|
||||
# to the mount point. Optional arguments may be passed to the
|
||||
# mount command.
|
||||
#
|
||||
test_mount() {
|
||||
mkdir ${Work_Dir} || die
|
||||
if [ $# -gt 0 ]; then
|
||||
mount -t tmpfs "$@" tmpfs ${Work_Dir} || die
|
||||
else
|
||||
mount -t tmpfs tmpfs ${Work_Dir} || die
|
||||
fi
|
||||
cd ${Work_Dir}
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# test_name message
|
||||
#
|
||||
# Prints a message about what a test is going to do.
|
||||
#
|
||||
test_name() {
|
||||
[ ${Verbose} -gt 1 ] && echo " $*..."
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# test_unmount
|
||||
#
|
||||
# Unmounts the file system mounted by test_mount.
|
||||
#
|
||||
test_unmount() {
|
||||
cd -
|
||||
umount ${Work_Dir} || die
|
||||
rmdir ${Work_Dir} || die
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# kqueue_monitor expected_nevents file1 [.. fileN]
|
||||
#
|
||||
# Monitors the commands given through stdin (one per line) using
|
||||
# kqueue and stores the events raised in a log that can be later
|
||||
# verified with kqueue_check.
|
||||
#
|
||||
kqueue_monitor() {
|
||||
nev=${1}; shift
|
||||
test_name "Running kqueue-monitored commands and expecting" \
|
||||
"${nev} events"
|
||||
${Src_Dir}/h_tools kqueue ${*} >kqueue.log || return 1
|
||||
got=$(wc -l kqueue.log | awk '{ print $1 }')
|
||||
test ${got} -eq ${nev}
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# kqueue_check file event
|
||||
#
|
||||
# Checks if kqueue raised the given event when monitoring the
|
||||
# given file.
|
||||
#
|
||||
kqueue_check() {
|
||||
grep "^${1} - ${2}$" kqueue.log >/dev/null
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
main() {
|
||||
local args
|
||||
|
||||
[ $(id -un) = root ] || err "Must be run as root"
|
||||
|
||||
args=$(getopt u:v:w: $*)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Usage: ${Prog_Name} [-u unprived_user] [-v level] " \
|
||||
"[-w root_dir]" 1>&2
|
||||
return 1
|
||||
fi
|
||||
set -- ${args}
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-u)
|
||||
Unprived_User="$2"; shift
|
||||
;;
|
||||
-v)
|
||||
Verbose="$2"; shift
|
||||
;;
|
||||
-w)
|
||||
Work_Dir="$2"; shift
|
||||
;;
|
||||
--)
|
||||
shift; break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ ${Verbose} -eq 1 ] && echo -n "${Prog_Name}:"
|
||||
[ ${Verbose} -eq 2 ] && echo "${Prog_Name}: Running tests"
|
||||
test_run
|
||||
[ ${Verbose} -eq 1 ] && echo " ok."
|
||||
[ ${Verbose} -eq 2 ] && echo "${Prog_Name}: All tests were successful"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
main "$@"
|
@ -1,96 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_create,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 create operation works.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "Files can be created"
|
||||
umask 022 || die
|
||||
test -f a && die
|
||||
touch a || die
|
||||
test -f a || die
|
||||
test_name "New files get proper attributes"
|
||||
eval $(stat -s . | sed -e 's|st_|dst_|g')
|
||||
eval $(stat -s a)
|
||||
test ${st_flags} -eq 0 || die
|
||||
test ${st_size} -eq 0 || die
|
||||
test ${st_uid} -eq $(id -u) || die
|
||||
test ${st_gid} -eq ${dst_gid} || die
|
||||
test ${st_mode} = 0100644 || die
|
||||
|
||||
if [ -n "${Unprived_User}" ]; then
|
||||
test_name "New files by users get proper attributes"
|
||||
|
||||
mkdir b c || die
|
||||
|
||||
chown ${Unprived_User}:0 b || die
|
||||
eval $(stat -s b)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 0 ] || die
|
||||
|
||||
chown ${Unprived_User}:100 c || die
|
||||
eval $(stat -s c)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 100 ] || die
|
||||
|
||||
su ${Unprived_User} -c 'touch b/a'
|
||||
eval $(stat -s b/a)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 0 ] || die
|
||||
|
||||
su ${Unprived_User} -c 'touch c/a'
|
||||
eval $(stat -s c/a)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 100 ] || die
|
||||
fi
|
||||
|
||||
mkdir dir || die
|
||||
echo 'touch dir/a' | kqueue_monitor 1 dir || die
|
||||
test_name "Creating a file raises NOTE_WRITE on the parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,106 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_link,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 link operation works.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "Link operation works"
|
||||
touch a || die
|
||||
touch z || die
|
||||
eval $(stat -s a | sed -e 's|st_|sta_|g')
|
||||
eval $(stat -s z | sed -e 's|st_|stz_|g')
|
||||
test ${sta_ino} != ${stz_ino} || die
|
||||
test ${sta_nlink} -eq 1 || die
|
||||
ln a b || die
|
||||
test_name "Link count is correct after links are created"
|
||||
eval $(stat -s a | sed -e 's|st_|sta_|g')
|
||||
eval $(stat -s b | sed -e 's|st_|stb_|g')
|
||||
test ${sta_ino} = ${stb_ino} || die
|
||||
test ${sta_nlink} -eq 2 || die
|
||||
test ${stb_nlink} -eq 2 || die
|
||||
test_name "Link count is correct after links are deleted"
|
||||
rm a || die
|
||||
eval $(stat -s b | sed -e 's|st_|stb_|g')
|
||||
test ${stb_nlink} -eq 1 || die
|
||||
rm b || die
|
||||
|
||||
test_name "Link operation works in subdirectories"
|
||||
touch a || die
|
||||
mkdir c || die
|
||||
ln a c/b || die
|
||||
test_name "Link count is correct after links are created"
|
||||
eval $(stat -s a | sed -e 's|st_|sta_|g')
|
||||
eval $(stat -s c/b | sed -e 's|st_|stb_|g')
|
||||
test ${sta_ino} = ${stb_ino} || die
|
||||
test ${sta_nlink} -eq 2 || die
|
||||
test ${stb_nlink} -eq 2 || die
|
||||
test_name "Link count is correct after links are deleted"
|
||||
rm a || die
|
||||
eval $(stat -s c/b | sed -e 's|st_|stb_|g')
|
||||
test ${stb_nlink} -eq 1 || die
|
||||
rm c/b || die
|
||||
rmdir c || die
|
||||
|
||||
mkdir dir || die
|
||||
touch dir/a || die
|
||||
echo 'ln dir/a dir/b' | kqueue_monitor 2 dir dir/a || die
|
||||
test_name "Creating a link raises NOTE_LINK on the source file"
|
||||
kqueue_check dir/a NOTE_LINK || die
|
||||
test_name "Creating a link raises NOTE_WRITE on the parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
|
||||
echo 'rm dir/a' | kqueue_monitor 2 dir dir/b || die
|
||||
# XXX According to the (short) kqueue(2) documentation, the following
|
||||
# should raise a NOTE_LINK but FFS raises a NOTE_DELETE...
|
||||
test_name "Deleting a link raises NOTE_LINK on one other link"
|
||||
kqueue_check dir/b NOTE_LINK || die
|
||||
test_name "Deleting a link raises NOTE_WRITE on the parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
rm dir/b || die
|
||||
rmdir dir || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,108 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_mkdir,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 mkdir works by creating some nested directories. It also
|
||||
# checks, in part, the lookup operation.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "Directories can be created"
|
||||
mkdir a
|
||||
test_name "Link count is updated after directory creation"
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_nlink} = 3 ] || die
|
||||
|
||||
test_name "Create many directories"
|
||||
for d in $(jot 100); do
|
||||
test -d ${d} && die
|
||||
mkdir ${d}
|
||||
test -d ${d} || die
|
||||
done
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_nlink} = 103 ] || die
|
||||
|
||||
test_name "Nested directories can be created"
|
||||
test -d a/b/c/d/e && die
|
||||
mkdir -p a/b/c/d/e || die
|
||||
test -d a/b/c/d/e || die
|
||||
|
||||
if [ -n "${Unprived_User}" ]; then
|
||||
test_name "New directories by users get proper attributes"
|
||||
mkdir b c || die
|
||||
|
||||
chown ${Unprived_User}:0 b || die
|
||||
eval $(stat -s b)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 0 ] || die
|
||||
|
||||
chown ${Unprived_User}:100 c || die
|
||||
eval $(stat -s c)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 100 ] || die
|
||||
|
||||
su ${Unprived_User} -c 'mkdir b/a'
|
||||
eval $(stat -s b/a)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 0 ] || die
|
||||
|
||||
su ${Unprived_User} -c 'mkdir c/a'
|
||||
eval $(stat -s c/a)
|
||||
[ ${st_uid} -eq $(id -u ${Unprived_User}) ] || die
|
||||
[ ${st_gid} -eq 100 ] || die
|
||||
fi
|
||||
|
||||
mkdir dir || die
|
||||
echo 'mkdir dir/a' | kqueue_monitor 2 dir || die
|
||||
test_name "Creating a directory raises NOTE_LINK on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_LINK || die
|
||||
test_name "Creating a directory raises NOTE_WRITE on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
rmdir dir/a || die
|
||||
rmdir dir || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,87 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_mknod,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 mknod operation works.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
umask 022 || die
|
||||
|
||||
test_name "Block devices can be created"
|
||||
mknod fd0a b 2 0 || die
|
||||
eval $(stat -s fd0a)
|
||||
[ ${st_mode} = 060644 ] || die
|
||||
[ ${st_rdev} -eq 512 ] || die
|
||||
|
||||
mkdir dir || die
|
||||
|
||||
echo 'mknod dir/fd0a b 2 0' | kqueue_monitor 1 dir || die
|
||||
test_name "Creating a block device raises NOTE_WRITE on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
|
||||
test_name "Character devices can be created"
|
||||
mknod null c 2 2 || die
|
||||
eval $(stat -s null)
|
||||
[ ${st_mode} = 020644 ] || die
|
||||
[ ${st_rdev} -eq 514 ] || die
|
||||
|
||||
echo 'mknod dir/null c 2 2' | kqueue_monitor 1 dir || die
|
||||
test_name "Creating a character device raises NOTE_WRITE on the" \
|
||||
"parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
|
||||
test_name "Named pipes can be created"
|
||||
mknod pipe p || die
|
||||
eval $(stat -s pipe)
|
||||
[ ${st_mode} = 010644 ] || die
|
||||
|
||||
echo 'mknod dir/pipe p' | kqueue_monitor 1 dir || die
|
||||
test_name "Creating a named pipe raises NOTE_WRITE on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,91 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_readdir,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 readdir operation works.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "Directory has '.' and '..' entries"
|
||||
/bin/ls -a | grep '^\.$' >/dev/null || die
|
||||
/bin/ls -a | grep '^\..$' >/dev/null || die
|
||||
|
||||
test_name "Creation of files of all possible types"
|
||||
mkdir dir || die
|
||||
touch reg || die
|
||||
ln -s reg lnk || die
|
||||
mknod blk b 0 0 || die
|
||||
mknod chr c 0 0 || die
|
||||
mknod fifo p || die
|
||||
${Src_Dir}/h_tools sockets sock || die
|
||||
|
||||
test_name "Read of directory"
|
||||
ls >/dev/null || die
|
||||
rm -rf * || die
|
||||
|
||||
# Catch a bug caused by incorrect invalidation of readdir caching
|
||||
# variables.
|
||||
test_name "Populate directory"
|
||||
touch $(jot 10) || die
|
||||
test_name "Clean it"
|
||||
rm * || die
|
||||
test_name "Repopulate directory"
|
||||
touch $(jot 20) || die
|
||||
test_name "Listing should return all entries"
|
||||
ls >/dev/null || die
|
||||
|
||||
test_name "Creation of many files"
|
||||
mkdir a || die
|
||||
for f in $(jot 500); do
|
||||
touch a/$f || die
|
||||
done
|
||||
|
||||
test_name "Removal of all files using a wildcard"
|
||||
rm a/* || die
|
||||
|
||||
test_name "Removal of should-be-empty directory"
|
||||
rmdir a || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,195 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_rename,v 1.7 2007/07/23 15:05:43 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 rename operation works (either by renaming entries or
|
||||
# by moving them).
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "'.' and '..' entries cannot be renamed"
|
||||
mkdir a || die
|
||||
mv a/. c 2>/dev/null && die
|
||||
mv a/.. c 2>/dev/null && die
|
||||
rmdir a || die
|
||||
|
||||
test_name "Cross device renames do not work"
|
||||
mkdir a || die
|
||||
${Src_Dir}/h_tools rename a /var/tmp/a >/dev/null 2>&1 && die
|
||||
rmdir a || die
|
||||
|
||||
test_name "Directories can be renamed"
|
||||
mkdir a || die
|
||||
mv a c || die
|
||||
test -d a && die
|
||||
test -d c || die
|
||||
rmdir c || die
|
||||
|
||||
test_name "The '..' entry is updated after moves"
|
||||
mkdir a || die
|
||||
mkdir b || die
|
||||
mv b a || die
|
||||
test -d a/b/../b || die
|
||||
test -d a/b/../../a || die
|
||||
eval $(stat -s a/b)
|
||||
[ ${st_nlink} = 2 ] || die
|
||||
eval $(stat -s a)
|
||||
[ ${st_nlink} = 3 ] || die
|
||||
rmdir a/b || die
|
||||
rmdir a || die
|
||||
|
||||
test_name "The '..' entry is correct after renames"
|
||||
mkdir a || die
|
||||
mkdir b || die
|
||||
mv b a || die
|
||||
mv a c || die
|
||||
test -d c/b/../b || die
|
||||
test -d c/b/../../c || die
|
||||
rmdir c/b || die
|
||||
rmdir c || die
|
||||
|
||||
test_name "The '..' entry is correct after multiple moves"
|
||||
mkdir a || die
|
||||
mkdir b || die
|
||||
mv b a || die
|
||||
mv a c || die
|
||||
mv c/b d || die
|
||||
test -d d/../c || die
|
||||
rmdir d || die
|
||||
rmdir c || die
|
||||
|
||||
test_name "Rename works if the target file exists"
|
||||
touch a || die
|
||||
touch b || die
|
||||
mv a b || die
|
||||
test -f a && die
|
||||
test -f b || die
|
||||
rm b
|
||||
|
||||
test_name "Rename a directory to a override an empty directory works"
|
||||
mkdir a || die
|
||||
touch a/c || die
|
||||
mkdir b || die
|
||||
${Src_Dir}/h_tools rename a b >/dev/null 2>&1 || die
|
||||
test -e a && die
|
||||
test -d b || die
|
||||
test -f b/c || die
|
||||
rm b/c
|
||||
rmdir b
|
||||
|
||||
test_name "Rename a directory to a override a non-empty directory fails"
|
||||
mkdir a || die
|
||||
touch a/c || die
|
||||
mkdir b || die
|
||||
touch b/d || die
|
||||
err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
|
||||
echo ${err} | grep 'Directory not empty' >/dev/null || die
|
||||
test -d a || die
|
||||
test -f a/c || die
|
||||
test -d b || die
|
||||
test -f b/d || die
|
||||
rm a/c
|
||||
rm b/d
|
||||
rmdir a
|
||||
rmdir b
|
||||
|
||||
test_name "Rename a directory to a override a file fails"
|
||||
mkdir a || die
|
||||
touch b || die
|
||||
err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
|
||||
echo ${err} | grep 'Not a directory' >/dev/null || die
|
||||
test -d a || die
|
||||
test -f b || die
|
||||
rmdir a
|
||||
rm b
|
||||
|
||||
test_name "Rename a file to a override a directory fails"
|
||||
touch a || die
|
||||
mkdir b || die
|
||||
err=$(${Src_Dir}/h_tools rename a b 2>&1) && die
|
||||
echo ${err} | grep 'Is a directory' >/dev/null || die
|
||||
test -f a || die
|
||||
test -d b || die
|
||||
rm a
|
||||
rmdir b
|
||||
|
||||
mkdir dir || die
|
||||
touch dir/a
|
||||
echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a || die
|
||||
test_name "Renaming a file raises NOTE_RENAME on the old file"
|
||||
kqueue_check dir/a NOTE_RENAME || die
|
||||
test_name "Renaming a file raises NOTE_WRITE on the parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
rm dir/b || die
|
||||
rmdir dir || die
|
||||
|
||||
mkdir dir || die
|
||||
touch dir/a
|
||||
touch dir/b
|
||||
echo 'mv dir/a dir/b' | kqueue_monitor 3 dir dir/a dir/b || die
|
||||
test_name "Renaming a file raises NOTE_RENAME on the old file"
|
||||
kqueue_check dir/a NOTE_RENAME || die
|
||||
test_name "Renaming a file raises NOTE_WRITE on the parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
test_name "Renaming a file raises NOTE_DELETE on the target file"
|
||||
kqueue_check dir/b NOTE_DELETE || die
|
||||
rm dir/b || die
|
||||
rmdir dir || die
|
||||
|
||||
mkdir dir1 || die
|
||||
mkdir dir2 || die
|
||||
touch dir1/a
|
||||
echo 'mv dir1/a dir2/a' | kqueue_monitor 3 dir1 dir1/a dir2 || die
|
||||
test_name "Moving a file raises NOTE_RENAME on the old file"
|
||||
kqueue_check dir1/a NOTE_RENAME || die
|
||||
test_name "Moving a file raises NOTE_WRITE on the source directory"
|
||||
kqueue_check dir1 NOTE_WRITE || die
|
||||
test_name "Moving a file raises NOTE_WRITE on the target directory"
|
||||
kqueue_check dir2 NOTE_WRITE || die
|
||||
rm dir2/a || die
|
||||
rmdir dir1 || die
|
||||
rmdir dir2 || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,112 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_rmdir,v 1.6 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 rmdir works by creating and removing directories. Also
|
||||
# checks multiple error conditions.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "The mount point cannot be removed"
|
||||
rmdir 2>/dev/null && die
|
||||
|
||||
test_name "Non-existing directories cannot be removed"
|
||||
rmdir non-existent 2>/dev/null && die
|
||||
|
||||
test_name "Removal of a single directory works"
|
||||
mkdir a || die
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_nlink} = 3 ] || die
|
||||
rmdir a || die
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_nlink} = 2 ] || die
|
||||
|
||||
test_name "Removal of nested directories works"
|
||||
mkdir -p a/b/c || die
|
||||
rmdir a/b/c || die
|
||||
rmdir a/b || die
|
||||
rmdir a || die
|
||||
|
||||
test_name "'.' and '..' directories cannot be removed"
|
||||
mkdir a || die
|
||||
rmdir a/. 2>/dev/null && die
|
||||
rmdir a/.. 2>/dev/null && die
|
||||
rmdir a || die
|
||||
|
||||
test_name "Non-empty directories cannot be removed"
|
||||
mkdir a || die
|
||||
mkdir a/b || die
|
||||
mkdir a/c || die
|
||||
rmdir a 2>/dev/null && die
|
||||
rmdir a/b || die
|
||||
rmdir a/c || die
|
||||
rmdir a || die
|
||||
|
||||
test_name "Root directory has two links after all removes"
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_nlink} = 2 ] || die
|
||||
|
||||
test_name "Removal of current directory"
|
||||
mkdir a || die
|
||||
# Catch a bug that would panic the system when accessing the
|
||||
# current directory after being deleted: vop_open cannot assume
|
||||
# that open files are still linked to a directory.
|
||||
( cd a && rmdir ../a && ls >/dev/null 2>&1 ) && die
|
||||
test -e a && die
|
||||
|
||||
mkdir dir || die
|
||||
mkdir dir/a || die
|
||||
echo 'rmdir dir/a' | kqueue_monitor 3 dir dir/a || die
|
||||
test_name "Deleting a directory raises NOTE_DELETE on it"
|
||||
kqueue_check dir/a NOTE_DELETE || die
|
||||
test_name "Deleting a directory raises NOTE_LINK on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_LINK || die
|
||||
test_name "Deleting a directory raises NOTE_WRITE on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
rmdir dir || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,113 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_setattr,v 1.6 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "File owner can be changed on its own"
|
||||
mkdir own || die
|
||||
eval $(stat -s own | sed -e 's|st_|ost_|g')
|
||||
chown 1234 own || die
|
||||
eval $(stat -s own)
|
||||
[ ${st_uid} -eq 1234 ] || die
|
||||
[ ${st_gid} -eq ${ost_gid} ] || die
|
||||
|
||||
mkdir ownq || die
|
||||
echo 'chown 1234 ownq' | kqueue_monitor 1 ownq || die
|
||||
test_name "Changing a file's owner raises NOTE_ATTRIB on it"
|
||||
kqueue_check ownq NOTE_ATTRIB || die
|
||||
|
||||
test_name "File group can be changed on its own"
|
||||
mkdir grp || die
|
||||
eval $(stat -s grp | sed -e 's|st_|ost_|g')
|
||||
chgrp 5678 grp || die
|
||||
eval $(stat -s grp)
|
||||
[ ${st_uid} -eq ${ost_uid} ] || die
|
||||
[ ${st_gid} -eq 5678 ] || die
|
||||
|
||||
mkdir grpq || die
|
||||
echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq || die
|
||||
test_name "Changing a file's group raises NOTE_ATTRIB on it"
|
||||
kqueue_check grpq NOTE_ATTRIB || die
|
||||
|
||||
test_name "File owner and group can be changed at once"
|
||||
mkdir owngrp || die
|
||||
chown 1234:5678 owngrp || die
|
||||
eval $(stat -s owngrp)
|
||||
[ ${st_uid} -eq 1234 ] || die
|
||||
[ ${st_gid} -eq 5678 ] || die
|
||||
|
||||
mkdir owngrpp || die
|
||||
echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp || die
|
||||
test_name "Changing a file's owner and group raises NOTE_ATTRIB on it"
|
||||
kqueue_check owngrpp NOTE_ATTRIB || die
|
||||
|
||||
test_name "File mode can be changed"
|
||||
mkdir mode || die
|
||||
chmod 0000 mode || die
|
||||
eval $(stat -s mode)
|
||||
[ ${st_mode} -eq 40000 ] || die
|
||||
|
||||
mkdir modeq || die
|
||||
echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq || die
|
||||
test_name "Updating a file's mode raises NOTE_ATTRIB on it"
|
||||
kqueue_check modeq NOTE_ATTRIB || die
|
||||
|
||||
test_name "File times can be changed"
|
||||
mkdir times || die
|
||||
TZ=GMT touch -t 200501010101 times || die
|
||||
eval $(stat -s times)
|
||||
[ ${st_atime} = ${st_mtime} ] || die
|
||||
[ ${st_atime} = 1104541260 ] || die
|
||||
|
||||
mkdir timesq || die
|
||||
echo 'touch timesq' | kqueue_monitor 1 timesq || die
|
||||
test_name "Updating a file's times raises NOTE_ATTRIB on it"
|
||||
kqueue_check timesq NOTE_ATTRIB || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,97 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_sizes,v 1.6 2007/03/11 10:09:17 pooka Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 file system controls memory usage correctly.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount -o -s10M
|
||||
|
||||
pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
|
||||
|
||||
test_name "Get status of clean filesystem"
|
||||
eval $(${Src_Dir}/h_tools statvfs . | sed -e 's|^f_|cf_|')
|
||||
cf_bused=$((${cf_blocks} - ${cf_bfree}))
|
||||
|
||||
test_name "Creation of small file"
|
||||
echo a >a || die
|
||||
test_name "statvfs(2) reports correct block accounting"
|
||||
eval $(${Src_Dir}/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -gt 1 ] || die
|
||||
rm a || die
|
||||
|
||||
test_name "Creation of big file"
|
||||
dd if=/dev/zero of=a bs=1m count=5 >/dev/null 2>&1 || die
|
||||
test_name "statvfs(2) reports correct block accounting"
|
||||
eval $(${Src_Dir}/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -ne ${cf_bused} ] || die
|
||||
[ ${f_bused} -gt $((5 * 1024 * 1024 / ${pagesize})) ] || die
|
||||
of_bused=${f_bused}
|
||||
rm a || die
|
||||
eval $(${Src_Dir}/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -lt ${of_bused} ] || die
|
||||
|
||||
test_name "Creation of big file that overflows the filesystem"
|
||||
of_bused=${f_bused}
|
||||
dd if=/dev/zero of=a bs=1m count=15 >/dev/null 2>&1 && die
|
||||
rm a || die
|
||||
test_name "statvfs(2) reports correct block accounting"
|
||||
eval $(${Src_Dir}/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -ge ${of_bused} -a ${f_bused} -le $((${of_bused} + 1)) ] \
|
||||
|| die
|
||||
|
||||
test_name "Write to middle of a file does not change size"
|
||||
dd if=/dev/zero of=a bs=1024 count=10 >/dev/null 2>&1 || die
|
||||
sync
|
||||
dd if=/dev/zero of=a bs=1024 conv=notrunc seek=1 count=1 \
|
||||
>/dev/null 2>&1 || die
|
||||
sync
|
||||
eval $(stat -s a)
|
||||
[ ${st_size} -eq 10240 ] || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,112 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_times,v 1.6 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 node times are properly handled.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
|
||||
test_name "Creation of empty file"
|
||||
touch a || die
|
||||
eval $(stat -s a | sed -e 's|st_|ost_|g') || die
|
||||
[ ${ost_birthtime} -eq ${ost_atime} ] || die
|
||||
[ ${ost_birthtime} -eq ${ost_ctime} ] || die
|
||||
[ ${ost_birthtime} -eq ${ost_mtime} ] || die
|
||||
|
||||
test_name "Read of empty file"
|
||||
sleep 1
|
||||
cat a >/dev/null || die
|
||||
eval $(stat -s a) || die
|
||||
[ ${st_atime} -gt ${ost_atime} ] || die
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || die
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || die
|
||||
|
||||
test_name "Write to (and extension of) empty file"
|
||||
sleep 1
|
||||
echo foo >a || die
|
||||
eval $(stat -s a) || die
|
||||
[ ${st_atime} -gt ${ost_atime} ] || die
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || die
|
||||
[ ${st_mtime} -gt ${ost_mtime} ] || die
|
||||
|
||||
test_name "Creation of non-empty file"
|
||||
echo foo >b || die
|
||||
eval $(stat -s b | sed -e 's|st_|ost_|g') || die
|
||||
|
||||
test_name "Read of non-empty file"
|
||||
sleep 1
|
||||
cat b >/dev/null || die
|
||||
eval $(stat -s b) || die
|
||||
[ ${st_atime} -gt ${ost_atime} ] || die
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || die
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || die
|
||||
|
||||
test_name "Creation of non-empty file"
|
||||
echo foo >c || die
|
||||
eval $(stat -s c | sed -e 's|st_|ost_|g') || die
|
||||
|
||||
test_name "New link to non-empty file"
|
||||
sleep 1
|
||||
ln c d || die
|
||||
eval $(stat -s c) || die
|
||||
[ ${st_atime} -eq ${ost_atime} ] || die
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || die
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || die
|
||||
|
||||
test_name "File renaming does not change times"
|
||||
mkdir e || die
|
||||
echo foo >e/a || die
|
||||
eval $(stat -s e | sed -e 's|st_|dost_|g') || die
|
||||
eval $(stat -s e/a | sed -e 's|st_|ost_|g') || die
|
||||
sleep 1
|
||||
mv e/a e/b || die
|
||||
eval $(stat -s e | sed -e 's|st_|dst_|g') || die
|
||||
eval $(stat -s e/b) || die
|
||||
[ ${st_atime} -eq ${ost_atime} ] || die
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || die
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || die
|
||||
[ ${dst_mtime} -gt ${dost_mtime} ] || die
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
@ -1,8 +1,8 @@
|
||||
# $NetBSD: Makefile,v 1.3 2007/11/12 15:13:59 jmmv Exp $
|
||||
# $NetBSD: Makefile,v 1.4 2007/11/12 15:18:18 jmmv Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR= atf util
|
||||
SUBDIR= atf fs util
|
||||
|
||||
.include <bsd.test.mk>
|
||||
.include <bsd.subdir.mk>
|
||||
|
5
tests/fs/Atffile
Normal file
5
tests/fs/Atffile
Normal file
@ -0,0 +1,5 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = "NetBSD"
|
||||
|
||||
tp-glob: *
|
11
tests/fs/Makefile
Normal file
11
tests/fs/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# $NetBSD: Makefile,v 1.1 2007/11/12 15:18:19 jmmv Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR= tmpfs
|
||||
|
||||
FILES= h_funcs.subr
|
||||
FILESDIR= ${TESTSDIR}
|
||||
|
||||
.include <bsd.test.mk>
|
||||
.include <bsd.subdir.mk>
|
48
regress/sys/fs/tmpfs/t_sockets → tests/fs/h_funcs.subr
Executable file → Normal file
48
regress/sys/fs/tmpfs/t_sockets → tests/fs/h_funcs.subr
Executable file → Normal file
@ -1,14 +1,10 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_sockets,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
# $NetBSD: h_funcs.subr,v 1.1 2007/11/12 15:18:20 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -39,23 +35,31 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that sockets can be created using socket/bind.
|
||||
# require_fs name
|
||||
#
|
||||
# Checks that the given file system is built into the kernel and
|
||||
# that its corresponding mount(8) utility is available. Otherwise
|
||||
# skips the test.
|
||||
#
|
||||
require_fs() {
|
||||
local name
|
||||
name="${1}"
|
||||
|
||||
test_run() {
|
||||
test_mount
|
||||
atf_require_prog sysctl
|
||||
set -- $(sysctl -n vfs.generic.fstypes)
|
||||
found=no
|
||||
while [ ${#} -gt 1 ]; do
|
||||
if [ ${1} = ${name} ]; then
|
||||
found=yes
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
[ ${found} = yes ] || \
|
||||
atf_skip "The kernel does not include support the " \
|
||||
"\`${name}' file system"
|
||||
|
||||
test_name "Sockets can be created"
|
||||
${Src_Dir}/h_tools sockets a
|
||||
rm a || die
|
||||
|
||||
mkdir dir || die
|
||||
echo "${Src_Dir}/h_tools sockets dir/a" | kqueue_monitor 1 dir || die
|
||||
test_name "Creating a socket raises NOTE_WRITE on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
|
||||
test_unmount
|
||||
atf_require_prog mount
|
||||
atf_require_prog mount_${name}
|
||||
atf_require_prog umount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
29
tests/fs/tmpfs/Atffile
Normal file
29
tests/fs/tmpfs/Atffile
Normal file
@ -0,0 +1,29 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = "NetBSD"
|
||||
|
||||
tp: t_mount
|
||||
tp: t_statvfs
|
||||
tp: t_mkdir
|
||||
tp: t_vnode_leak
|
||||
tp: t_setattr
|
||||
tp: t_rmdir
|
||||
tp: t_id_gen
|
||||
tp: t_trail_slash
|
||||
tp: t_dots
|
||||
tp: t_create
|
||||
tp: t_remove
|
||||
tp: t_link
|
||||
tp: t_rename
|
||||
tp: t_read_write
|
||||
tp: t_exec
|
||||
tp: t_truncate
|
||||
tp: t_sizes
|
||||
tp: t_times
|
||||
tp: t_symlink
|
||||
tp: t_mknod
|
||||
tp: t_devices
|
||||
tp: t_pipes
|
||||
tp: t_sockets
|
||||
tp: t_readdir
|
||||
tp: t_vnd
|
37
tests/fs/tmpfs/Makefile
Normal file
37
tests/fs/tmpfs/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
# $NetBSD: Makefile,v 1.1 2007/11/12 15:18:20 jmmv Exp $
|
||||
|
||||
TESTS_SH= t_create
|
||||
TESTS_SH+= t_devices
|
||||
TESTS_SH+= t_dots
|
||||
TESTS_SH+= t_exec
|
||||
TESTS_SH+= t_id_gen
|
||||
TESTS_SH+= t_link
|
||||
TESTS_SH+= t_mkdir
|
||||
TESTS_SH+= t_mknod
|
||||
TESTS_SH+= t_mount
|
||||
TESTS_SH+= t_pipes
|
||||
TESTS_SH+= t_read_write
|
||||
TESTS_SH+= t_readdir
|
||||
TESTS_SH+= t_remove
|
||||
TESTS_SH+= t_rename
|
||||
TESTS_SH+= t_rmdir
|
||||
TESTS_SH+= t_setattr
|
||||
TESTS_SH+= t_sizes
|
||||
TESTS_SH+= t_sockets
|
||||
TESTS_SH+= t_statvfs
|
||||
TESTS_SH+= t_symlink
|
||||
TESTS_SH+= t_times
|
||||
TESTS_SH+= t_trail_slash
|
||||
TESTS_SH+= t_truncate
|
||||
TESTS_SH+= t_vnd
|
||||
TESTS_SH+= t_vnode_leak
|
||||
|
||||
FILES= h_funcs.subr
|
||||
FILESDIR= ${TESTSDIR}
|
||||
|
||||
PROGS= h_tools
|
||||
SRCS.h_tools= h_tools.c
|
||||
MAN.h_tools= # empty
|
||||
BINDIR.h_tools= ${TESTSDIR}
|
||||
|
||||
.include <bsd.test.mk>
|
17
tests/fs/tmpfs/README
Normal file
17
tests/fs/tmpfs/README
Normal file
@ -0,0 +1,17 @@
|
||||
The tests in this directory where written at the same time tmpfs was
|
||||
developed. This is why, if you follow the order of tests in the Atffile,
|
||||
you will notice that they start checking the most basic things and end
|
||||
checking the less common ones. Furthermore, tests try not to use features
|
||||
tested by further tests in the lists.
|
||||
|
||||
However, the above is not the most appropriate testing procedure when you
|
||||
have a working file system because some separation in test programs does
|
||||
not make sense afterwards.
|
||||
|
||||
Many of the tests here are applicable to any file system. They should be
|
||||
refactored to be reusable on any mounted file system, which could also
|
||||
remove the need to do the mount/unmount steps in each and every test case.
|
||||
|
||||
Possibly take a look at the file system tests in FreeBSD. They seem to be
|
||||
much more complete, even though they are written in Perl and therefore not
|
||||
directly usable.
|
105
regress/sys/fs/tmpfs/t_mount → tests/fs/tmpfs/h_funcs.subr
Executable file → Normal file
105
regress/sys/fs/tmpfs/t_mount → tests/fs/tmpfs/h_funcs.subr
Executable file → Normal file
@ -1,14 +1,10 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: t_mount,v 1.8 2007/07/24 11:29:16 jmmv Exp $
|
||||
# $NetBSD: h_funcs.subr,v 1.1 2007/11/12 15:18:21 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,47 +34,68 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
Mount_Point=
|
||||
|
||||
#
|
||||
# Verifies that an execution of mount and umount works correctly without
|
||||
# causing errors and that the root node gets correct attributes.
|
||||
# Also verifies command line parsing from mount_tmpfs.
|
||||
# test_mount [args]
|
||||
#
|
||||
# Mounts tmpfs over ${Mount_Point} and changes the current directory
|
||||
# to the mount point. Optional arguments may be passed to the
|
||||
# mount command.
|
||||
#
|
||||
test_mount() {
|
||||
require_fs tmpfs
|
||||
|
||||
test_run() {
|
||||
test_name "File-system can be mounted"
|
||||
test_mount
|
||||
test_name "Root directory has two links"
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_nlink} = 2 ] || die
|
||||
test_name "File-system can be unmounted"
|
||||
test_unmount
|
||||
|
||||
test_name "File-system mount options work"
|
||||
test_mount -o ro
|
||||
mount | grep ${Work_Dir} | grep -q read-only || die
|
||||
test_unmount
|
||||
|
||||
test_name "Root directory attributes are set correctly"
|
||||
test_mount -o -u1000 -o -g100 -o -m755
|
||||
eval $(stat -s ${Work_Dir})
|
||||
[ ${st_uid} = 1000 ] || die
|
||||
[ ${st_gid} = 100 ] || die
|
||||
[ ${st_mode} = 040755 ] || die
|
||||
test_unmount
|
||||
|
||||
test_name "Negative values are correctly handled"
|
||||
test_mount -o "-s -10"
|
||||
test_unmount
|
||||
|
||||
test_name "Extremely large values are correctly handled"
|
||||
test_mount -o -s9223372036854775807
|
||||
test_unmount
|
||||
mkdir -p ${Work_Dir}
|
||||
mount -t tmpfs -o -s9223372036854775808 tmpfs ${Work_Dir} \
|
||||
2>/dev/null && die
|
||||
mount -t tmpfs -o -s9223372036854775808g tmpfs ${Work_Dir} \
|
||||
2>/dev/null && die
|
||||
rmdir ${Work_Dir}
|
||||
Mount_Point=$(pwd)/mntpt
|
||||
atf_check "mkdir ${Mount_Point}" 0 null null
|
||||
if [ $# -gt 0 ]; then
|
||||
atf_check "mount -t tmpfs $* tmpfs ${Mount_Point}" \
|
||||
0 null null
|
||||
else
|
||||
atf_check "mount -t tmpfs tmpfs ${Mount_Point}" \
|
||||
0 null null
|
||||
fi
|
||||
cd ${Mount_Point}
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
#
|
||||
# test_unmount
|
||||
#
|
||||
# Unmounts the file system mounted by test_mount.
|
||||
#
|
||||
test_unmount() {
|
||||
cd - >/dev/null
|
||||
atf_check "umount ${Mount_Point}" 0 null null
|
||||
atf_check "rmdir ${Mount_Point}" 0 null null
|
||||
Mount_Point=
|
||||
}
|
||||
|
||||
#
|
||||
# kqueue_monitor expected_nevents file1 [.. fileN]
|
||||
#
|
||||
# Monitors the commands given through stdin (one per line) using
|
||||
# kqueue and stores the events raised in a log that can be later
|
||||
# verified with kqueue_check.
|
||||
#
|
||||
kqueue_monitor() {
|
||||
nev=${1}; shift
|
||||
echo "Running kqueue-monitored commands and expecting" \
|
||||
"${nev} events"
|
||||
$(atf_get_srcdir)/h_tools kqueue ${*} >kqueue.log || \
|
||||
atf_fail "Could not launch kqueue monitor"
|
||||
got=$(wc -l kqueue.log | awk '{ print $1 }')
|
||||
test ${got} -eq ${nev} || \
|
||||
atf_fail "Got ${got} events but expected ${nev}"
|
||||
}
|
||||
|
||||
#
|
||||
# kqueue_check file event
|
||||
#
|
||||
# Checks if kqueue raised the given event when monitoring the
|
||||
# given file.
|
||||
#
|
||||
kqueue_check() {
|
||||
echo "Checking if ${1} received ${2}"
|
||||
grep "^${1} - ${2}$" kqueue.log >/dev/null || \
|
||||
atf_fail "${1} did not receive ${2}"
|
||||
}
|
@ -1,13 +1,9 @@
|
||||
/* $NetBSD: h_tools.c,v 1.8 2007/07/23 15:05:43 jmmv Exp $ */
|
||||
/* $NetBSD: h_tools.c,v 1.1 2007/11/12 15:18:21 jmmv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
* 2005 program.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
130
tests/fs/tmpfs/t_create.sh
Normal file
130
tests/fs/tmpfs/t_create.sh
Normal file
@ -0,0 +1,130 @@
|
||||
# $NetBSD: t_create.sh,v 1.1 2007/11/12 15:18:21 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 create operation works.
|
||||
#
|
||||
|
||||
atf_test_case create
|
||||
create_head() {
|
||||
atf_set "descr" "Verifies that files can be created"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
create_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'test -f a' 1 null null
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'test -f a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case attrs
|
||||
attrs_head() {
|
||||
atf_set "descr" "Verifies that a new file gets the correct" \
|
||||
"attributes"
|
||||
atf_set "require.config" "unprivileged-user"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
attrs_body() {
|
||||
# Allow the unprivileged user to access the work directory.
|
||||
chmod 711 .
|
||||
|
||||
test_mount
|
||||
|
||||
umask 022
|
||||
atf_check 'test -f a' 1 null null
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'test -f a' 0 null null
|
||||
|
||||
eval $(stat -s . | sed -e 's|st_|dst_|g')
|
||||
eval $(stat -s a)
|
||||
test ${st_flags} -eq 0 || atf_fail "Incorrect flags"
|
||||
test ${st_size} -eq 0 || atf_fail "Incorrect size"
|
||||
test ${st_uid} -eq $(id -u) || atf_fail "Incorrect uid"
|
||||
test ${st_gid} -eq ${dst_gid} || atf_fail "Incorrect gid"
|
||||
test ${st_mode} = 0100644 || atf_fail "Incorrect mode"
|
||||
|
||||
user=$(atf_config_get unprivileged-user)
|
||||
|
||||
atf_check 'mkdir b c' 0 null null
|
||||
|
||||
atf_check "chown ${user}:0 b" 0 null null
|
||||
eval $(stat -s b)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
|
||||
|
||||
atf_check "chown ${user}:100 c" 0 null null
|
||||
eval $(stat -s c)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
|
||||
|
||||
su ${user} -c 'touch b/a'
|
||||
eval $(stat -s b/a)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
|
||||
|
||||
su ${user} -c 'touch c/a'
|
||||
eval $(stat -s c/a)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Verifies that creating a file raises the correct" \
|
||||
"kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo 'touch dir/a' | kqueue_monitor 1 dir
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case create
|
||||
atf_add_test_case attrs
|
||||
atf_add_test_case kqueue
|
||||
}
|
46
regress/sys/fs/tmpfs/t_devices → tests/fs/tmpfs/t_devices.sh
Executable file → Normal file
46
regress/sys/fs/tmpfs/t_devices → tests/fs/tmpfs/t_devices.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_devices.sh,v 1.1 2007/11/12 15:18:22 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_devices,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,28 +32,36 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that special devices created inside tmpfs work.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Tests that special devices work"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
umask 022 || die
|
||||
umask 022
|
||||
|
||||
test_name "Creation of the std devices"
|
||||
/dev/MAKEDEV std || die
|
||||
atf_check '/dev/MAKEDEV std' 0 ignore ignore
|
||||
atf_check 'test -e zero' 0 null null
|
||||
atf_check 'test -e null' 0 null null
|
||||
|
||||
test_name "Read from the 'zero' character device"
|
||||
dd if=zero of=a bs=10k count=1 >/dev/null 2>&1 || die
|
||||
[ $(md5 a | cut -d ' ' -f 4) = 1276481102f218c981e0324180bafd9f ] || die
|
||||
echo "Reading from the 'zero' character device"
|
||||
atf_check 'dd if=zero of=a bs=10k count=1' 0 ignore ignore
|
||||
[ $(md5 a | cut -d ' ' -f 4) = 1276481102f218c981e0324180bafd9f ] || \
|
||||
atf_fail "Data read is invalid"
|
||||
|
||||
test_name "Write to the 'null' device"
|
||||
echo "Writing to the 'null' device"
|
||||
echo foo >null
|
||||
eval $(stat -s null)
|
||||
[ ${st_size} -eq 0 ] || die
|
||||
[ ${st_size} -eq 0 ] || atf_fail "Invalid size for device"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
}
|
74
tests/fs/tmpfs/t_dots.sh
Normal file
74
tests/fs/tmpfs/t_dots.sh
Normal file
@ -0,0 +1,74 @@
|
||||
# $NetBSD: t_dots.sh,v 1.1 2007/11/12 15:18:22 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
atf_test_case topdir
|
||||
topdir_head() {
|
||||
atf_set "descr" "Verifies that looking up '.' and '..' in" \
|
||||
"top-level directories works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
topdir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'test -d ./a' 0 null null
|
||||
atf_check 'test -d a/../a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case nesteddir
|
||||
nesteddir_head() {
|
||||
atf_set "descr" "Verifies that looking up '.' and '..' in" \
|
||||
"top-level directories works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
nesteddir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mkdir a/b' 0 null null
|
||||
atf_check 'test -d a/b/../b' 0 null null
|
||||
atf_check 'test -d a/b/../../a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case topdir
|
||||
atf_add_test_case nesteddir
|
||||
}
|
41
regress/sys/fs/tmpfs/t_exec → tests/fs/tmpfs/t_exec.sh
Executable file → Normal file
41
regress/sys/fs/tmpfs/t_exec → tests/fs/tmpfs/t_exec.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_exec.sh,v 1.1 2007/11/12 15:18:22 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_exec,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,23 +32,28 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that binary files can be executed from within the file system
|
||||
# (i.e., whether getpages works).
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Verifies that binary files can be executed from" \
|
||||
"within the file system (i.e., whether getpages" \
|
||||
"works)"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Copy of existing binary program"
|
||||
cp /bin/cp . || die
|
||||
test_name "Data written is correct"
|
||||
atf_check 'cp /bin/cp .' 0 null null
|
||||
echo "Verifying copied file"
|
||||
[ $(md5 cp | cut -d ' ' -f 4) = $(md5 /bin/cp | cut -d ' ' -f 4) ] || \
|
||||
die
|
||||
test_name "Execution of binary program"
|
||||
./cp cp foo || die
|
||||
atf_file "New binary file does not match original"
|
||||
atf_check './cp cp foo' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
}
|
62
regress/sys/fs/tmpfs/t_id_gen → tests/fs/tmpfs/t_id_gen.sh
Executable file → Normal file
62
regress/sys/fs/tmpfs/t_id_gen → tests/fs/tmpfs/t_id_gen.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_id_gen.sh,v 1.1 2007/11/12 15:18:23 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_id_gen,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,34 +32,40 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that node identifiers and generation numbers are assigned
|
||||
# correctly.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case main
|
||||
main_head() {
|
||||
atf_set "descr" "Verifies that node identifiers and generation" \
|
||||
"numbers are assigned correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
main_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Creation of directory"
|
||||
mkdir a || die
|
||||
test_name "Node ID should be 3"
|
||||
eval $(stat -s a | sed -e 's|st_|ost_|g') || die
|
||||
ofhsum=$(${Src_Dir}/h_tools getfh a | md5) || die
|
||||
[ ${ost_ino} -eq 3 ] || die
|
||||
echo "Creating directory with node number = 3"
|
||||
atf_check 'mkdir a' 0 null null
|
||||
eval $(stat -s a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
ofhsum=$($(atf_get_srcdir)/h_tools getfh a | md5) || \
|
||||
atf_fail "Failed to calculate file handle"
|
||||
[ ${ost_ino} -eq 3 ] || atf_fail "Node number is not 3"
|
||||
|
||||
test_name "Deletion of directory"
|
||||
rmdir a || die
|
||||
echo "Deleting the directory"
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_name "Creation of directory (reuse node)"
|
||||
mkdir b || die
|
||||
test_name "Node ID should be 3"
|
||||
eval $(stat -s b) || die
|
||||
fhsum=$(${Src_Dir}/h_tools getfh b | md5) || die
|
||||
[ ${st_ino} -eq 3 ] || die
|
||||
test_name "File handle is different (thanks to generation)"
|
||||
[ ${ofhsum} != ${fhsum} ] || die
|
||||
echo "Creating another directory to reuse node number 3"
|
||||
atf_check 'mkdir b' 0 null null
|
||||
eval $(stat -s b) || atf_fail "stat failed"
|
||||
fhsum=$($(atf_get_srcdir)/h_tools getfh b | md5) || \
|
||||
atf_fail "Failed to calculate file handle"
|
||||
[ ${st_ino} -eq 3 ] || atf_fail "Node number is not 3"
|
||||
echo "Checking if file handle is different"
|
||||
[ ${ofhsum} != ${fhsum} ] || atf_fail "Handles are not different"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case main
|
||||
}
|
136
tests/fs/tmpfs/t_link.sh
Normal file
136
tests/fs/tmpfs/t_link.sh
Normal file
@ -0,0 +1,136 @@
|
||||
# $NetBSD: t_link.sh,v 1.1 2007/11/12 15:18:23 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 link operation works.
|
||||
#
|
||||
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Verifies that the link operation works on files" \
|
||||
"at the top directory"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'touch z' 0 null null
|
||||
eval $(stat -s a | sed -e 's|st_|sta_|g')
|
||||
eval $(stat -s z | sed -e 's|st_|stz_|g')
|
||||
test ${sta_ino} != ${stz_ino} || \
|
||||
atf_fail "Node numbers are not different"
|
||||
test ${sta_nlink} -eq 1 || atf_fail "Number of links is incorrect"
|
||||
atf_check 'ln a b' 0 null null
|
||||
|
||||
echo "Checking if link count is correct after links are created"
|
||||
eval $(stat -s a | sed -e 's|st_|sta_|g')
|
||||
eval $(stat -s b | sed -e 's|st_|stb_|g')
|
||||
test ${sta_ino} = ${stb_ino} || atf_fail "Node number changed"
|
||||
test ${sta_nlink} -eq 2 || atf_fail "Link count is incorrect"
|
||||
test ${stb_nlink} -eq 2 || atf_fail "Link count is incorrect"
|
||||
|
||||
echo "Checking if link count is correct after links are deleted"
|
||||
atf_check 'rm a' 0 null null
|
||||
eval $(stat -s b | sed -e 's|st_|stb_|g')
|
||||
test ${stb_nlink} -eq 1 || atf_fail "Link count is incorrect"
|
||||
atf_check 'rm b' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case subdirs
|
||||
subdirs_head() {
|
||||
atf_set "descr" "Verifies that the link operation works if used" \
|
||||
"in subdirectories"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
subdirs_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'mkdir c' 0 null null
|
||||
atf_check 'ln a c/b' 0 null null
|
||||
|
||||
echo "Checking if link count is correct after links are created"
|
||||
eval $(stat -s a | sed -e 's|st_|sta_|g')
|
||||
eval $(stat -s c/b | sed -e 's|st_|stb_|g')
|
||||
test ${sta_ino} = ${stb_ino} || atf_fail "Node number changed"
|
||||
test ${sta_nlink} -eq 2 || atf_fail "Link count is incorrect"
|
||||
test ${stb_nlink} -eq 2 || atf_fail "Link count is incorrect"
|
||||
|
||||
echo "Checking if link count is correct after links are deleted"
|
||||
atf_check 'rm a' 0 null null
|
||||
eval $(stat -s c/b | sed -e 's|st_|stb_|g')
|
||||
test ${stb_nlink} -eq 1 || atf_fail "Link count is incorrect"
|
||||
atf_check 'rm c/b' 0 null null
|
||||
atf_check 'rmdir c' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Verifies that creating a link raises the correct" \
|
||||
"kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
atf_check 'touch dir/a' 0 null null
|
||||
echo 'ln dir/a dir/b' | kqueue_monitor 2 dir dir/a
|
||||
kqueue_check dir/a NOTE_LINK
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
echo 'rm dir/a' | kqueue_monitor 2 dir dir/b
|
||||
# XXX According to the (short) kqueue(2) documentation, the following
|
||||
# should raise a NOTE_LINK but FFS raises a NOTE_DELETE...
|
||||
kqueue_check dir/b NOTE_LINK
|
||||
kqueue_check dir NOTE_WRITE
|
||||
atf_check 'rm dir/b' 0 null null
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
atf_add_test_case subdirs
|
||||
atf_add_test_case kqueue
|
||||
}
|
167
tests/fs/tmpfs/t_mkdir.sh
Normal file
167
tests/fs/tmpfs/t_mkdir.sh
Normal file
@ -0,0 +1,167 @@
|
||||
# $NetBSD: t_mkdir.sh,v 1.1 2007/11/12 15:18:23 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 mkdir works by creating some nested directories. It also
|
||||
# checks, in part, the lookup operation.
|
||||
#
|
||||
|
||||
atf_test_case single
|
||||
single_head() {
|
||||
atf_set "descr" "Creates a single directory and checks the" \
|
||||
"mount point's hard link count"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
single_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'test -d a' 1 null null
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'test -d a' 0 null null
|
||||
test -d a
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_nlink} = 3 ] || atf_fail "Link count is not 3"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case many
|
||||
many_head() {
|
||||
atf_set "descr" "Creates multiple directories and checks the" \
|
||||
"mount point's hard link count"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
many_body() {
|
||||
test_mount
|
||||
|
||||
for d in $(jot 100); do
|
||||
atf_check "test -d ${d}" 1 null null
|
||||
atf_check "mkdir ${d}" 0 null null
|
||||
atf_check "test -d ${d}" 0 null null
|
||||
done
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_nlink} = 102 ] || atf_fail "Link count is not 102"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case nested
|
||||
nested_head() {
|
||||
atf_set "descr" "Checks if nested directories can be created"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
nested_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'test -d a/b/c/d/e' 1 null null
|
||||
atf_check 'mkdir -p a/b/c/d/e' 0 null null
|
||||
atf_check 'test -d a/b/c/d/e' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case attrs
|
||||
attrs_head() {
|
||||
atf_set "descr" "Checks that new directories get the proper" \
|
||||
"attributes (owner and group)"
|
||||
atf_set "require.config" "unprivileged-user"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
attrs_body() {
|
||||
# Allow the unprivileged user to access the work directory.
|
||||
chmod 711 .
|
||||
|
||||
test_mount
|
||||
|
||||
user=$(atf_config_get unprivileged-user)
|
||||
|
||||
atf_check 'mkdir b c' 0 null null
|
||||
|
||||
atf_check "chown ${user}:0 b" 0 null null
|
||||
eval $(stat -s b)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
|
||||
|
||||
atf_check "chown ${user}:100 c" 0 null null
|
||||
eval $(stat -s c)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
|
||||
|
||||
su ${user} -c 'mkdir b/a'
|
||||
eval $(stat -s b/a)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 0 ] || atf_fail "Incorrect group"
|
||||
|
||||
su ${user} -c 'mkdir c/a'
|
||||
eval $(stat -s c/a)
|
||||
[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail "Incorrect owner"
|
||||
[ ${st_gid} -eq 100 ] || atf_fail "Incorrect group"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Creates a directory and checks the kqueue events" \
|
||||
"raised"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo 'mkdir dir/a' | kqueue_monitor 2 dir
|
||||
|
||||
# Creating a directory raises NOTE_LINK on the parent directory
|
||||
kqueue_check dir NOTE_LINK
|
||||
|
||||
# Creating a directory raises NOTE_WRITE on the parent directory
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
atf_check 'rmdir dir/a' 0 null null
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case single
|
||||
atf_add_test_case many
|
||||
atf_add_test_case nested
|
||||
atf_add_test_case attrs
|
||||
atf_add_test_case kqueue
|
||||
}
|
150
tests/fs/tmpfs/t_mknod.sh
Normal file
150
tests/fs/tmpfs/t_mknod.sh
Normal file
@ -0,0 +1,150 @@
|
||||
# $NetBSD: t_mknod.sh,v 1.1 2007/11/12 15:18:24 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 mknod operation works.
|
||||
#
|
||||
|
||||
atf_test_case block
|
||||
block_head() {
|
||||
atf_set "descr" "Tests that block devices can be created"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
block_body() {
|
||||
test_mount
|
||||
umask 022
|
||||
|
||||
atf_check 'mknod fd0a b 2 0' 0 null null
|
||||
eval $(stat -s fd0a)
|
||||
[ ${st_mode} = 060644 ] || atf_fail "Invalid mode"
|
||||
[ ${st_rdev} -eq 512 ] || atf_fail "Invalid device"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case block_kqueue
|
||||
block_kqueue_head() {
|
||||
atf_set "descr" "Tests that creating a block device raises the" \
|
||||
"appropriate kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
block_kqueue_body() {
|
||||
test_mount
|
||||
umask 022
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo 'mknod dir/fd0a b 2 0' | kqueue_monitor 1 dir
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case char
|
||||
char_head() {
|
||||
atf_set "descr" "Tests that character devices can be created"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
char_body() {
|
||||
test_mount
|
||||
umask 022
|
||||
|
||||
atf_check 'mknod null c 2 2' 0 null null
|
||||
eval $(stat -s null)
|
||||
[ ${st_mode} = 020644 ] || atf_fail "Invalid mode"
|
||||
[ ${st_rdev} -eq 514 ] || atf_fail "Invalid device"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case char_kqueue
|
||||
char_kqueue_head() {
|
||||
atf_set "descr" "Tests that creating a character device raises the" \
|
||||
"appropriate kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
char_kqueue_body() {
|
||||
test_mount
|
||||
umask 022
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo 'mknod dir/null c 2 2' | kqueue_monitor 1 dir
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case pipe
|
||||
pipe_head() {
|
||||
atf_set "descr" "Tests that named pipes can be created"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
pipe_body() {
|
||||
test_mount
|
||||
umask 022
|
||||
|
||||
atf_check 'mknod pipe p' 0 null null
|
||||
eval $(stat -s pipe)
|
||||
[ ${st_mode} = 010644 ] || atf_fail "Invalid mode"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case pipe_kqueue
|
||||
pipe_kqueue_head() {
|
||||
atf_set "descr" "Tests that creating a named pipe raises the" \
|
||||
"appropriate kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
pipe_kqueue_body() {
|
||||
test_mount
|
||||
umask 022
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo 'mknod dir/pipe p' | kqueue_monitor 1 dir
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case block
|
||||
atf_add_test_case block_kqueue
|
||||
atf_add_test_case char
|
||||
atf_add_test_case char_kqueue
|
||||
atf_add_test_case pipe
|
||||
atf_add_test_case pipe_kqueue
|
||||
}
|
130
tests/fs/tmpfs/t_mount.sh
Normal file
130
tests/fs/tmpfs/t_mount.sh
Normal file
@ -0,0 +1,130 @@
|
||||
# $NetBSD: t_mount.sh,v 1.1 2007/11/12 15:18:24 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 an execution of mount and umount works correctly without
|
||||
# causing errors and that the root node gets correct attributes.
|
||||
# Also verifies command line parsing from mount_tmpfs.
|
||||
#
|
||||
|
||||
atf_test_case plain
|
||||
plain_head() {
|
||||
atf_set "descr" "Tests a mount and unmount without any options"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
plain_body() {
|
||||
test_mount
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case links
|
||||
links_head() {
|
||||
atf_set "descr" "Tests that the mount point has two hard links"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
links_body() {
|
||||
test_mount
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_nlink} = 2 ] || \
|
||||
atf_fail "Root directory does not have two hard links"
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case options
|
||||
options_head() {
|
||||
atf_set "descr" "Tests the read-only mount option"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
options_body() {
|
||||
test_mount -o ro
|
||||
mount | grep ${Mount_Point} | grep -q read-only || \
|
||||
atf_fail "read-only option (ro) does not work"
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case attrs
|
||||
attrs_head() {
|
||||
atf_set "descr" "Tests that root directory attributes are set" \
|
||||
"correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
attrs_body() {
|
||||
test_mount -o -u1000 -o -g100 -o -m755
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_uid} = 1000 ] || atf_fail "uid is incorrect"
|
||||
[ ${st_gid} = 100 ] || atf_fail "gid is incorrect"
|
||||
[ ${st_mode} = 040755 ] || atf_fail "mode is incorrect"
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case negative
|
||||
negative_head() {
|
||||
atf_set "descr" "Tests that negative values passed to to -s are" \
|
||||
"handled correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
negative_body() {
|
||||
mkdir tmp
|
||||
test_mount -o -s-10
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case large
|
||||
large_head() {
|
||||
atf_set "descr" "Tests that extremely long values passed to -s" \
|
||||
"are handled correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
large_body() {
|
||||
test_mount -o -s9223372036854775807
|
||||
test_unmount
|
||||
|
||||
mkdir tmp
|
||||
atf_check "mount -t tmpfs -o -s9223372036854775808 tmpfs \
|
||||
tmp" 1 null ignore
|
||||
atf_check "mount -t tmpfs -o -s9223372036854775808g tmpfs \
|
||||
tmp" 1 null ignore
|
||||
rmdir tmp
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case plain
|
||||
atf_add_test_case options
|
||||
atf_add_test_case attrs
|
||||
atf_add_test_case negative
|
||||
atf_add_test_case large
|
||||
}
|
37
regress/sys/fs/tmpfs/t_pipes → tests/fs/tmpfs/t_pipes.sh
Executable file → Normal file
37
regress/sys/fs/tmpfs/t_pipes → tests/fs/tmpfs/t_pipes.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_pipes.sh,v 1.1 2007/11/12 15:18:24 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_pipes,v 1.5 2006/12/07 10:00:39 pooka Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,23 +32,28 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that pipes created inside tmpfs work.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Verifies that pipes work"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
umask 022 || die
|
||||
umask 022
|
||||
|
||||
test_name "Creation of named pipe"
|
||||
mknod pipe p || die
|
||||
atf_check 'mknod pipe p' 0 null null
|
||||
|
||||
test_name "Writing to pipe and waiting for response"
|
||||
echo "Writing to pipe and waiting for response"
|
||||
echo -n foo >pipe &
|
||||
[ "$(cat pipe)" = foo ] || die
|
||||
[ "$(cat pipe)" = foo ] || atf_fail "Received data is incorrect"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
}
|
84
regress/sys/fs/tmpfs/t_read_write → tests/fs/tmpfs/t_read_write.sh
Executable file → Normal file
84
regress/sys/fs/tmpfs/t_read_write → tests/fs/tmpfs/t_read_write.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_read_write.sh,v 1.1 2007/11/12 15:18:25 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_read_write,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -42,38 +36,58 @@
|
||||
# Verifies that the read and write operations work.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Checks that file removal works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Write to new file works"
|
||||
echo foo >a || die
|
||||
test_name "Data written is correct"
|
||||
[ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || die
|
||||
echo "Testing write to a small file"
|
||||
echo foo >a || atf_fail "Failed to write to file"
|
||||
[ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
|
||||
atf_fail "Invalid file contents"
|
||||
|
||||
test_name "Append to existing file works"
|
||||
echo bar >>a || die
|
||||
test_name "Data written is correct"
|
||||
[ $(md5 a | cut -d ' ' -f 4) = f47c75614087a8dd938ba4acff252494 ] || die
|
||||
echo "Testing appending to a small file"
|
||||
echo bar >>a || atf_fail "Failed to append data to file"
|
||||
[ $(md5 a | cut -d ' ' -f 4) = f47c75614087a8dd938ba4acff252494 ] || \
|
||||
atf_fail "Invalid file contents"
|
||||
|
||||
test_name "Write to long file (bigger than a page) works"
|
||||
jot 10000 >b || die
|
||||
test_name "Data written is correct"
|
||||
[ $(md5 b | cut -d ' ' -f 4) = 72d4ff27a28afbc066d5804999d5a504 ] || die
|
||||
|
||||
dd if=/dev/zero of=c bs=1k count=10 >/dev/null 2>&1 || die
|
||||
echo 'dd if=/dev/zero of=c seek=2 bs=1k count=1 conv=notrunc' \
|
||||
'>/dev/null 2>&1' | kqueue_monitor 1 c || die
|
||||
test_name "Writing to a file raises NOTE_WRITE"
|
||||
kqueue_check c NOTE_WRITE || die
|
||||
|
||||
echo foo >d
|
||||
echo 'echo bar >>d' | kqueue_monitor 2 d || die
|
||||
test_name "Appending to a file raises NOTE_EXTEND"
|
||||
kqueue_check d NOTE_EXTEND || die
|
||||
test_name "Appending to a file raises NOTE_WRITE"
|
||||
kqueue_check d NOTE_WRITE || die
|
||||
echo "Testing write to a big file (bigger than a page)"
|
||||
jot 10000 >b || atf_fail "Failed to create a big file"
|
||||
[ $(md5 b | cut -d ' ' -f 4) = 72d4ff27a28afbc066d5804999d5a504 ] || \
|
||||
atf_fail "Invalid file contents"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Checks that writing to a file raises the" \
|
||||
"appropriate kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'dd if=/dev/zero of=c bs=1k count=10' 0 ignore ignore
|
||||
echo 'dd if=/dev/zero of=c seek=2 bs=1k count=1 conv=notrunc' \
|
||||
'>/dev/null 2>&1' | kqueue_monitor 1 c
|
||||
kqueue_check c NOTE_WRITE
|
||||
|
||||
echo foo >d
|
||||
echo 'echo bar >>d' | kqueue_monitor 2 d
|
||||
kqueue_check d NOTE_EXTEND
|
||||
kqueue_check d NOTE_WRITE
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
atf_add_test_case kqueue
|
||||
}
|
122
tests/fs/tmpfs/t_readdir.sh
Normal file
122
tests/fs/tmpfs/t_readdir.sh
Normal file
@ -0,0 +1,122 @@
|
||||
# $NetBSD: t_readdir.sh,v 1.1 2007/11/12 15:18:25 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 readdir operation works.
|
||||
#
|
||||
|
||||
atf_test_case dots
|
||||
dots_head() {
|
||||
atf_set "descr" "Verifies that readdir returns the '.' and '..'" \
|
||||
"entries"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dots_body() {
|
||||
test_mount
|
||||
|
||||
atf_check '/bin/ls -a' 0 stdout null
|
||||
atf_check "grep '^\.$' ../stdout" 0 ignore null
|
||||
atf_check "grep '^\..$' ../stdout" 0 ignore null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case types
|
||||
types_head() {
|
||||
atf_set "descr" "Verifies that readdir works for all different" \
|
||||
"file types"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
types_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
atf_check 'touch reg' 0 null null
|
||||
atf_check 'ln -s reg lnk' 0 null null
|
||||
atf_check 'mknod blk b 0 0' 0 null null
|
||||
atf_check 'mknod chr c 0 0' 0 null null
|
||||
atf_check 'mknod fifo p' 0 null null
|
||||
atf_check "$(atf_get_srcdir)/h_tools sockets sock" 0 null null
|
||||
|
||||
atf_check 'ls' 0 ignore null
|
||||
atf_check 'rm -rf *' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case caching
|
||||
caching_head() {
|
||||
atf_set "descr" "Catch a bug caused by incorrect invalidation of" \
|
||||
"readdir caching variables"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
caching_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch $(jot 10)' 0 null null
|
||||
atf_check 'rm *' 0 null null
|
||||
atf_check 'touch $(jot 20)' 0 null null
|
||||
atf_check 'ls >/dev/null' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case many
|
||||
many_head() {
|
||||
atf_set "descr" "Verifies that readdir works with many files"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
many_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
echo "Creating 500 files"
|
||||
for f in $(jot 500); do
|
||||
touch a/$f
|
||||
done
|
||||
atf_check 'rm a/*' 0 null null
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case dots
|
||||
atf_add_test_case types
|
||||
atf_add_test_case caching
|
||||
atf_add_test_case many
|
||||
}
|
113
regress/sys/fs/tmpfs/t_remove → tests/fs/tmpfs/t_remove.sh
Executable file → Normal file
113
regress/sys/fs/tmpfs/t_remove → tests/fs/tmpfs/t_remove.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_remove.sh,v 1.1 2007/11/12 15:18:25 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_remove,v 1.8 2007/01/02 11:04:10 pooka Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -42,39 +36,82 @@
|
||||
# Verifies that the remove operation works.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case single
|
||||
single_head() {
|
||||
atf_set "descr" "Checks that file removal works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
single_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Files can be removed"
|
||||
test -f a && die
|
||||
touch a || die
|
||||
test -f a || die
|
||||
rm a || die
|
||||
test -f a && die
|
||||
|
||||
test_name "Files with uchg flags cannot be removed"
|
||||
touch a || die
|
||||
chflags uchg a || die
|
||||
rm -f a 2>/dev/null && die
|
||||
chflags nouchg a || die
|
||||
rm a || die
|
||||
test -f a && die
|
||||
|
||||
test_name "The node . cannot be unlinked"
|
||||
mkdir a || die
|
||||
unlink a/. 2>/dev/null && die
|
||||
rmdir a
|
||||
|
||||
mkdir dir || die
|
||||
touch dir/a || die
|
||||
echo 'rm dir/a' | kqueue_monitor 2 dir dir/a || die
|
||||
test_name "Deleting a file raises NOTE_DELETE on it"
|
||||
kqueue_check dir/a NOTE_DELETE || die
|
||||
test_name "Deleting a file raises NOTE_WRITE on the parent directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
rmdir dir || die
|
||||
atf_check 'test -f a' 1 null null
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'test -f a' 0 null null
|
||||
atf_check 'rm a' 0 null null
|
||||
atf_check 'test -f a' 1 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_test_case uchg
|
||||
uchg_head() {
|
||||
atf_set "descr" "Checks that files with the uchg flag set cannot" \
|
||||
"be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
uchg_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'chflags uchg a' 0 null null
|
||||
atf_check 'rm -f a' 1 null ignore
|
||||
atf_check 'chflags nouchg a' 0 null null
|
||||
atf_check 'rm a' 0 null null
|
||||
atf_check 'test -f a' 1 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dot
|
||||
dot_head() {
|
||||
atf_set "descr" "Checks that '.' cannot be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dot_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'unlink a/.' 1 null ignore
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Removes a file and checks the kqueue events" \
|
||||
"raised"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
atf_check 'touch dir/a' 0 null null
|
||||
echo 'rm dir/a' | kqueue_monitor 2 dir dir/a
|
||||
kqueue_check dir/a NOTE_DELETE
|
||||
kqueue_check dir NOTE_WRITE
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case single
|
||||
atf_add_test_case uchg
|
||||
atf_add_test_case dot
|
||||
atf_add_test_case kqueue
|
||||
}
|
281
tests/fs/tmpfs/t_rename.sh
Normal file
281
tests/fs/tmpfs/t_rename.sh
Normal file
@ -0,0 +1,281 @@
|
||||
# $NetBSD: t_rename.sh,v 1.1 2007/11/12 15:18:25 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 rename operation works (either by renaming entries or
|
||||
# by moving them).
|
||||
#
|
||||
|
||||
atf_test_case dots
|
||||
dots_head() {
|
||||
atf_set "descr" "Tests that '.' and '..' cannot be renamed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dots_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mv a/. c' 1 null ignore
|
||||
atf_check 'mv a/.. c' 1 null ignore
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case crossdev
|
||||
crossdev_head() {
|
||||
atf_set "descr" "Tests that cross-device renames do not work"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
crossdev_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check '$(atf_get_srcdir)/h_tools rename a /var/tmp/a' \
|
||||
1 null stderr
|
||||
atf_check 'grep "Cross-device link" ../stderr' 0 ignore null
|
||||
atf_check 'test -d a' 0 null null
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Tests that basic renames work"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mv a c' 0 null null
|
||||
atf_check 'test -d a' 1 null null
|
||||
atf_check 'test -d c' 0 null null
|
||||
atf_check 'rmdir c' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dotdot
|
||||
dotdot_head() {
|
||||
atf_set "descr" "Tests that the '..' entry is properly updated" \
|
||||
"during moves"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dotdot_body() {
|
||||
test_mount
|
||||
|
||||
echo "Checking if the '..' entry is updated after moves"
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mkdir b' 0 null null
|
||||
atf_check 'mv b a' 0 null null
|
||||
atf_check 'test -d a/b/../b' 0 null null
|
||||
atf_check 'test -d a/b/../../a' 0 null null
|
||||
eval $(stat -s a/b)
|
||||
[ ${st_nlink} = 2 ] || atf_fail "Incorrect number of links"
|
||||
eval $(stat -s a)
|
||||
[ ${st_nlink} = 3 ] || atf_fail "Incorrect number of links"
|
||||
atf_check 'rmdir a/b' 0 null null
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
echo "Checking if the '..' entry is correct after renames"
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mkdir b' 0 null null
|
||||
atf_check 'mv b a' 0 null null
|
||||
atf_check 'mv a c' 0 null null
|
||||
atf_check 'test -d c/b/../b' 0 null null
|
||||
atf_check 'test -d c/b/../../c' 0 null null
|
||||
atf_check 'rmdir c/b' 0 null null
|
||||
atf_check 'rmdir c' 0 null null
|
||||
|
||||
echo "Checking if the '..' entry is correct after multiple moves"
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mkdir b' 0 null null
|
||||
atf_check 'mv b a' 0 null null
|
||||
atf_check 'mv a c' 0 null null
|
||||
atf_check 'mv c/b d' 0 null null
|
||||
atf_check 'test -d d/../c' 0 null null
|
||||
atf_check 'rmdir d' 0 null null
|
||||
atf_check 'rmdir c' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dir_to_emptydir
|
||||
dir_to_emptydir_head() {
|
||||
atf_set "descr" "Tests that renaming a directory to override an" \
|
||||
"empty directory works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dir_to_emptydir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'touch a/c' 0 null null
|
||||
atf_check 'mkdir b' 0 null null
|
||||
atf_check '$(atf_get_srcdir)/h_tools rename a b' 0 null null
|
||||
atf_check 'test -e a' 1 null null
|
||||
atf_check 'test -d b' 0 null null
|
||||
atf_check 'test -f b/c' 0 null null
|
||||
rm b/c
|
||||
rmdir b
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dir_to_fulldir
|
||||
dir_to_fulldir_head() {
|
||||
atf_set "descr" "Tests that renaming a directory to override a" \
|
||||
"non-empty directory fails"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dir_to_fulldir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'touch a/c' 0 null null
|
||||
atf_check 'mkdir b' 0 null null
|
||||
atf_check 'touch b/d' 0 null null
|
||||
atf_check '$(atf_get_srcdir)/h_tools rename a b' 1 null stderr
|
||||
atf_check 'grep "Directory not empty" ../stderr' 0 ignore null
|
||||
atf_check 'test -d a' 0 null null
|
||||
atf_check 'test -f a/c' 0 null null
|
||||
atf_check 'test -d b' 0 null null
|
||||
atf_check 'test -f b/d' 0 null null
|
||||
rm a/c
|
||||
rm b/d
|
||||
rmdir a
|
||||
rmdir b
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dir_to_file
|
||||
dir_to_file_head() {
|
||||
atf_set "descr" "Tests that renaming a directory to override a" \
|
||||
"file fails"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dir_to_file_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'touch b' 0 null null
|
||||
atf_check '$(atf_get_srcdir)/h_tools rename a b' 1 null stderr
|
||||
atf_check 'grep "Not a directory" ../stderr' 0 ignore null
|
||||
atf_check 'test -d a' 0 null null
|
||||
atf_check 'test -f b' 0 null null
|
||||
rmdir a
|
||||
rm b
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case file_to_dir
|
||||
file_to_dir_head() {
|
||||
atf_set "descr" "Tests that renaming a file to override a" \
|
||||
"directory fails"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
file_to_dir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'mkdir b' 0 null null
|
||||
atf_check '$(atf_get_srcdir)/h_tools rename a b' 1 null stderr
|
||||
atf_check 'grep "Is a directory" ../stderr' 0 ignore null
|
||||
atf_check 'test -f a' 0 null null
|
||||
atf_check 'test -d b' 0 null null
|
||||
rm a
|
||||
rmdir b
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Tests that moving and renaming files raise the" \
|
||||
"correct kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
atf_check 'touch dir/a' 0 null null
|
||||
echo 'mv dir/a dir/b' | kqueue_monitor 2 dir dir/a
|
||||
kqueue_check dir/a NOTE_RENAME
|
||||
kqueue_check dir NOTE_WRITE
|
||||
atf_check 'rm dir/b' 0 null null
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
atf_check 'touch dir/a' 0 null null
|
||||
atf_check 'touch dir/b' 0 null null
|
||||
echo 'mv dir/a dir/b' | kqueue_monitor 3 dir dir/a dir/b
|
||||
kqueue_check dir/a NOTE_RENAME
|
||||
kqueue_check dir NOTE_WRITE
|
||||
kqueue_check dir/b NOTE_DELETE
|
||||
atf_check 'rm dir/b' 0 null null
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
atf_check 'mkdir dir1' 0 null null
|
||||
atf_check 'mkdir dir2' 0 null null
|
||||
atf_check 'touch dir1/a' 0 null null
|
||||
echo 'mv dir1/a dir2/a' | kqueue_monitor 3 dir1 dir1/a dir2
|
||||
kqueue_check dir1/a NOTE_RENAME
|
||||
kqueue_check dir1 NOTE_WRITE
|
||||
kqueue_check dir2 NOTE_WRITE
|
||||
atf_check 'rm dir2/a' 0 null null
|
||||
atf_check 'rmdir dir1' 0 null null
|
||||
atf_check 'rmdir dir2' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case dots
|
||||
atf_add_test_case crossdev
|
||||
atf_add_test_case basic
|
||||
atf_add_test_case dotdot
|
||||
atf_add_test_case dir_to_emptydir
|
||||
atf_add_test_case dir_to_fulldir
|
||||
atf_add_test_case dir_to_file
|
||||
atf_add_test_case file_to_dir
|
||||
atf_add_test_case kqueue
|
||||
}
|
211
tests/fs/tmpfs/t_rmdir.sh
Normal file
211
tests/fs/tmpfs/t_rmdir.sh
Normal file
@ -0,0 +1,211 @@
|
||||
# $NetBSD: t_rmdir.sh,v 1.1 2007/11/12 15:18:26 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 rmdir works by creating and removing directories. Also
|
||||
# checks multiple error conditions.
|
||||
#
|
||||
|
||||
atf_test_case mntpt
|
||||
mntpt_head() {
|
||||
atf_set "descr" "Checks that the mount point cannot be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
mntpt_body() {
|
||||
test_mount
|
||||
|
||||
atf_check "rmdir ${Mount_Point}" 1 null ignore
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case non_existent
|
||||
non_existent_head() {
|
||||
atf_set "descr" "Checks that non-existent directories cannot" \
|
||||
"be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
non_existent_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'rmdir non-existent' 1 null ignore
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case single
|
||||
single_head() {
|
||||
atf_set "descr" "Checks that removing a single directory works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
single_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_nlink} = 3 ] || \
|
||||
atf_fail "Incorrect number of links after creation"
|
||||
atf_check 'rmdir a' 0 null null
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_nlink} = 2 ] || \
|
||||
atf_fail "Incorrect number of links after removal"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case nested
|
||||
nested_head() {
|
||||
atf_set "descr" "Checks that removing nested directories works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
nested_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir -p a/b/c' 0 null null
|
||||
atf_check 'rmdir a/b/c' 0 null null
|
||||
atf_check 'rmdir a/b' 0 null null
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dots
|
||||
dots_head() {
|
||||
atf_set "descr" "Checks that '.' and '..' cannot be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dots_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'rmdir a/.' 1 null ignore
|
||||
atf_check 'rmdir a/..' 1 null ignore
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case non_empty
|
||||
non_empty_head() {
|
||||
atf_set "descr" "Checks that non-empty directories cannot be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
non_empty_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mkdir a/b' 0 null null
|
||||
atf_check 'mkdir a/c' 0 null null
|
||||
atf_check 'rmdir a' 1 null ignore
|
||||
atf_check 'rmdir a/b' 0 null null
|
||||
atf_check 'rmdir a/c' 0 null null
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case links
|
||||
links_head() {
|
||||
atf_set "descr" "Checks the root directory's links after removals"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
links_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
atf_check 'mkdir a/b' 0 null null
|
||||
atf_check 'mkdir c' 0 null null
|
||||
|
||||
atf_check 'rmdir c' 0 null null
|
||||
atf_check 'rmdir a/b' 0 null null
|
||||
atf_check 'rmdir a' 0 null null
|
||||
|
||||
eval $(stat -s ${Mount_Point})
|
||||
[ ${st_nlink} = 2 ] || atf_fail "Incorrect number of links"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case curdir
|
||||
curdir_head() {
|
||||
atf_set "descr" "Checks that the current directory cannot be removed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
curdir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir a' 0 null null
|
||||
# Catch a bug that would panic the system when accessing the
|
||||
# current directory after being deleted: vop_open cannot assume
|
||||
# that open files are still linked to a directory.
|
||||
atf_check '( cd a && rmdir ../a && ls )' 1 null ignore
|
||||
atf_check 'test -e a' 1 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Checks that removing a directory raises the" \
|
||||
"correct kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
atf_check 'mkdir dir/a' 0 null null
|
||||
echo 'rmdir dir/a' | kqueue_monitor 3 dir dir/a
|
||||
kqueue_check dir/a NOTE_DELETE
|
||||
kqueue_check dir NOTE_LINK
|
||||
kqueue_check dir NOTE_WRITE
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case mntpt
|
||||
atf_add_test_case non_existent
|
||||
atf_add_test_case single
|
||||
atf_add_test_case nested
|
||||
atf_add_test_case dots
|
||||
atf_add_test_case non_empty
|
||||
atf_add_test_case links
|
||||
atf_add_test_case curdir
|
||||
atf_add_test_case kqueue
|
||||
}
|
222
tests/fs/tmpfs/t_setattr.sh
Normal file
222
tests/fs/tmpfs/t_setattr.sh
Normal file
@ -0,0 +1,222 @@
|
||||
# $NetBSD: t_setattr.sh,v 1.1 2007/11/12 15:18:26 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 'mkdir own' 0 null null
|
||||
eval $(stat -s own | sed -e 's|st_|ost_|g')
|
||||
atf_check 'chown 1234 own' 0 null null
|
||||
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_check 'mkdir ownq' 0 null null
|
||||
echo 'chown 1234 ownq' | kqueue_monitor 1 ownq
|
||||
kqueue_check ownq NOTE_ATTRIB
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
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_check 'mkdir grp' 0 null null
|
||||
eval $(stat -s grp | sed -e 's|st_|ost_|g')
|
||||
atf_check 'chgrp 5678 grp' 0 null null
|
||||
eval $(stat -s grp)
|
||||
[ ${st_uid} -eq ${ost_uid} ] || atf_fail "uid was modified"
|
||||
[ ${st_gid} -eq 5678 ] || atf_fail "gid was not set"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case chgrp_kqueue
|
||||
chgrp_kqueue_head() {
|
||||
atf_set "descr" "Tests that changing the file group raises" \
|
||||
"NOTE_ATTRIB on it"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
chgrp_kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir grpq' 0 null null
|
||||
echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq
|
||||
kqueue_check grpq NOTE_ATTRIB
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
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_check 'mkdir owngrp' 0 null null
|
||||
atf_check 'chown 1234:5678 owngrp' 0 null null
|
||||
eval $(stat -s owngrp)
|
||||
[ ${st_uid} -eq 1234 ] || atf_fail "uid was not modified"
|
||||
[ ${st_gid} -eq 5678 ] || atf_fail "gid was not modified"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case chowngrp_kqueue
|
||||
chowngrp_kqueue_head() {
|
||||
atf_set "descr" "Tests that changing the file owner and group" \
|
||||
"raises NOTE_ATTRIB on it"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
chowngrp_kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir owngrpp' 0 null null
|
||||
echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp
|
||||
kqueue_check owngrpp NOTE_ATTRIB
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case chmod
|
||||
chmod_head() {
|
||||
atf_set "descr" "Tests that the file mode can be changed"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
chmod_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir mode' 0 null null
|
||||
atf_check 'chmod 0000 mode' 0 null null
|
||||
eval $(stat -s mode)
|
||||
[ ${st_mode} -eq 40000 ] || af_fail "mode was not set"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case chmod_kqueue
|
||||
chmod_kqueue_head() {
|
||||
atf_set "descr" "Tests that changing the file mode raises" \
|
||||
"NOTE_ATTRIB on it"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
chmod_kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir modeq' 0 null null
|
||||
echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq
|
||||
kqueue_check modeq NOTE_ATTRIB
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
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 'mkdir times' 0 null null
|
||||
atf_check 'TZ=GMT touch -t 200501010101 times' 0 null null
|
||||
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
|
||||
|
||||
atf_check 'mkdir timesq' 0 null null
|
||||
echo 'touch timesq' | kqueue_monitor 1 timesq
|
||||
kqueue_check timesq NOTE_ATTRIB
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case chown
|
||||
atf_add_test_case chown_kqueue
|
||||
atf_add_test_case chgrp
|
||||
atf_add_test_case chgrp_kqueue
|
||||
atf_add_test_case chowngrp
|
||||
atf_add_test_case chowngrp_kqueue
|
||||
atf_add_test_case chmod
|
||||
atf_add_test_case chmod_kqueue
|
||||
atf_add_test_case chtimes
|
||||
atf_add_test_case chtimes_kqueue
|
||||
}
|
135
tests/fs/tmpfs/t_sizes.sh
Normal file
135
tests/fs/tmpfs/t_sizes.sh
Normal file
@ -0,0 +1,135 @@
|
||||
# $NetBSD: t_sizes.sh,v 1.1 2007/11/12 15:18:26 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 file system controls memory usage correctly.
|
||||
#
|
||||
|
||||
atf_test_case small
|
||||
small_head() {
|
||||
atf_set "descr" "Checks the status after creating a small file"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
small_body() {
|
||||
test_mount -o -s10M
|
||||
|
||||
echo a >a || atf_fail "Could not create file"
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -gt 1 ] || atf_fail "Incorrect bused count"
|
||||
atf_check 'rm a' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case big
|
||||
big_head() {
|
||||
atf_set "descr" "Checks the status after creating a big file"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
big_body() {
|
||||
test_mount -o -s10M
|
||||
|
||||
pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs . | sed -e 's|^f_|cf_|')
|
||||
cf_bused=$((${cf_blocks} - ${cf_bfree}))
|
||||
|
||||
atf_check 'dd if=/dev/zero of=a bs=1m count=5' 0 ignore ignore
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -ne ${cf_bused} ] || atf_fail "bused did not change"
|
||||
[ ${f_bused} -gt $((5 * 1024 * 1024 / ${pagesize})) ] || \
|
||||
atf_fail "bused too big"
|
||||
of_bused=${f_bused}
|
||||
atf_check 'rm a' 0 null null
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -lt ${of_bused} ] || \
|
||||
atf_fail "bused was not correctly restored"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case overflow
|
||||
overflow_head() {
|
||||
atf_set "descr" "Checks the status after creating a big file that" \
|
||||
"overflows the file system limits"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
overflow_body() {
|
||||
test_mount -o -s10M
|
||||
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'rm a' 0 null null
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs .)
|
||||
of_bused=$((${f_blocks} - ${f_bfree}))
|
||||
atf_check 'dd if=/dev/zero of=a bs=1m count=15' 1 ignore ignore
|
||||
atf_check 'rm a' 0 null null
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs .)
|
||||
f_bused=$((${f_blocks} - ${f_bfree}))
|
||||
[ ${f_bused} -ge ${of_bused} -a ${f_bused} -le $((${of_bused} + 1)) ] \
|
||||
|| atf_fail "Incorrect bused"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case overwrite
|
||||
overwrite_head() {
|
||||
atf_set "descr" "Checks that writing to the middle of a file" \
|
||||
"does not change its size"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
overwrite_body() {
|
||||
test_mount -o -s10M
|
||||
|
||||
atf_check 'dd if=/dev/zero of=a bs=1024 count=10' 0 ignore ignore
|
||||
sync
|
||||
atf_check 'dd if=/dev/zero of=a bs=1024 conv=notrunc seek=1 count=1' \
|
||||
0 ignore ignore
|
||||
sync
|
||||
eval $(stat -s a)
|
||||
[ ${st_size} -eq 10240 ] || atf_fail "Incorrect file size"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case small
|
||||
atf_add_test_case big
|
||||
atf_add_test_case overflow
|
||||
atf_add_test_case overwrite
|
||||
}
|
42
regress/sys/fs/tmpfs/t_dots → tests/fs/tmpfs/t_sockets.sh
Executable file → Normal file
42
regress/sys/fs/tmpfs/t_dots → tests/fs/tmpfs/t_sockets.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_sockets.sh,v 1.1 2007/11/12 15:18:27 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_dots,v 1.4 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,24 +32,28 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that '.' and '..' lookups work.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Verifies that sockets can be created using" \
|
||||
"socket/bind"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
test_name "'.' and '..' entries of a directory work."
|
||||
mkdir a
|
||||
test -d ./a || die
|
||||
test -d a/../a || die
|
||||
atf_check '$(atf_get_srcdir)/h_tools sockets a' 0 null null
|
||||
atf_check 'rm a' 0 null null
|
||||
|
||||
test_name "'.' and '..' entries of nested directories work."
|
||||
mkdir a/b
|
||||
test -d a/b/../b || die
|
||||
test -d a/b/../../a || die
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo "$(atf_get_srcdir)/h_tools sockets dir/a" | kqueue_monitor 1 dir
|
||||
kqueue_check dir NOTE_WRITE
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
}
|
36
regress/sys/fs/tmpfs/t_statvfs → tests/fs/tmpfs/t_statvfs.sh
Executable file → Normal file
36
regress/sys/fs/tmpfs/t_statvfs → tests/fs/tmpfs/t_statvfs.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_statvfs.sh,v 1.1 2007/11/12 15:18:27 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_statvfs,v 1.4 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -43,18 +37,30 @@
|
||||
# correct values) over a tmpfs mount point.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case values
|
||||
values_head() {
|
||||
atf_set "descr" "Tests that statvfs(2) returns correct values"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
values_body() {
|
||||
test_mount -o -s10M
|
||||
|
||||
test_name "statvfs(2) returns correct values"
|
||||
pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
|
||||
eval $(${Src_Dir}/h_tools statvfs .)
|
||||
[ ${pagesize} -eq ${f_bsize} ] || die
|
||||
[ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || die
|
||||
eval $($(atf_get_srcdir)/h_tools statvfs .)
|
||||
[ ${pagesize} -eq ${f_bsize} ] || \
|
||||
atf_fail "Invalid bsize"
|
||||
[ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || \
|
||||
atf_file "bsize * blocks too small"
|
||||
[ $((${f_bsize} * ${f_blocks})) -le \
|
||||
$((10 * 1024 * 1024 + ${pagesize})) ] || die
|
||||
$((10 * 1024 * 1024 + ${pagesize})) ] || \
|
||||
atf_fail "bsize * blocks too big"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case values
|
||||
}
|
121
regress/sys/fs/tmpfs/t_symlink → tests/fs/tmpfs/t_symlink.sh
Executable file → Normal file
121
regress/sys/fs/tmpfs/t_symlink → tests/fs/tmpfs/t_symlink.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_symlink.sh,v 1.1 2007/11/12 15:18:27 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_symlink,v 1.6 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -42,45 +36,86 @@
|
||||
# Verifies that the symlink and readlink operations work.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case file
|
||||
file_head() {
|
||||
atf_set "descr" "Tests that symlinks to files work"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
file_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Creation of an empty file"
|
||||
touch a || die
|
||||
test_name "Creation of a symlink pointing to it"
|
||||
ln -s a b || die
|
||||
test_name "Symlink points to correct file"
|
||||
[ $(md5 b | cut -d ' ' -f 4) = d41d8cd98f00b204e9800998ecf8427e ] || die
|
||||
atf_check 'touch a' 0 null null
|
||||
atf_check 'ln -s a b' 0 null null
|
||||
[ $(md5 b | cut -d ' ' -f 4) = d41d8cd98f00b204e9800998ecf8427e ] || \
|
||||
atf_fail "Symlink points to an incorrect file"
|
||||
|
||||
test_name "Changing original file"
|
||||
echo foo >a || die
|
||||
test_name "Symlink reflects the changes"
|
||||
[ $(md5 b | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || die
|
||||
|
||||
test_name "Creation of symlink to a known system file"
|
||||
ln -s /bin/cp cp || die
|
||||
test_name "Trying to see if it works"
|
||||
./cp b c || die
|
||||
[ -f c ] || die
|
||||
|
||||
test_name "Symlinking directories works"
|
||||
mkdir d || die
|
||||
[ -f d/foo ] && die
|
||||
[ -f e/foo ] && die
|
||||
ln -s d e || die
|
||||
touch d/foo || die
|
||||
[ -f d/foo ] || die
|
||||
[ -f e/foo ] || die
|
||||
|
||||
mkdir dir || die
|
||||
echo 'ln -s non-existent dir/a' | kqueue_monitor 1 dir || die
|
||||
test_name "Creating a symlink raises NOTE_WRITE on the parent" \
|
||||
"directory"
|
||||
kqueue_check dir NOTE_WRITE || die
|
||||
rm dir/a || die
|
||||
rmdir dir || die
|
||||
atf_check 'echo foo >a' 0 null null
|
||||
[ $(md5 b | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
|
||||
atf_fail "Symlink points to an incorrect file"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_test_case exec
|
||||
exec_head() {
|
||||
atf_set "descr" "Tests symlinking to a known system binary and" \
|
||||
"executing it through the symlink"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
exec_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch b' 0 null null
|
||||
atf_check 'ln -s /bin/cp cp' 0 null null
|
||||
atf_check './cp b c' 0 null null
|
||||
atf_check 'test -f c' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case dir
|
||||
dir_head() {
|
||||
atf_set "descr" "Tests that symlinks to directories work"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
dir_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir d' 0 null null
|
||||
atf_check 'test -f d/foo' 1 null null
|
||||
atf_check 'test -f e/foo' 1 null null
|
||||
atf_check 'ln -s d e' 0 null null
|
||||
atf_check 'touch d/foo' 0 null null
|
||||
atf_check 'test -f d/foo' 0 null null
|
||||
atf_check 'test -f e/foo' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Tests that creating a symlink raises the" \
|
||||
"appropriate kqueue events"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
kqueue_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir dir' 0 null null
|
||||
echo 'ln -s non-existent dir/a' | kqueue_monitor 1 dir
|
||||
kqueue_check dir NOTE_WRITE
|
||||
atf_check 'rm dir/a' 0 null null
|
||||
atf_check 'rmdir dir' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case file
|
||||
atf_add_test_case exec
|
||||
atf_add_test_case dir
|
||||
atf_add_test_case kqueue
|
||||
}
|
148
tests/fs/tmpfs/t_times.sh
Normal file
148
tests/fs/tmpfs/t_times.sh
Normal file
@ -0,0 +1,148 @@
|
||||
# $NetBSD: t_times.sh,v 1.1 2007/11/12 15:18:28 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006, 2007 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.
|
||||
# 3. All advertising materials mentioning features or use of this software
|
||||
# must display the following acknowledgement:
|
||||
# This product includes software developed by the NetBSD
|
||||
# Foundation, Inc. and its contributors.
|
||||
# 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# 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 node times are properly handled.
|
||||
#
|
||||
|
||||
atf_test_case empty
|
||||
empty_head() {
|
||||
atf_set "descr" "Tests that creating an empty file and later" \
|
||||
"manipulating it updates times correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
empty_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'touch a' 0 null null
|
||||
eval $(stat -s a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
[ ${ost_birthtime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${ost_birthtime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${ost_birthtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
sleep 1
|
||||
atf_check 'cat a' 0 ignore null
|
||||
eval $(stat -s a) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
sleep 1
|
||||
echo foo >a || atf_fail "Write failed"
|
||||
eval $(stat -s a) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -gt ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case non_empty
|
||||
non_empty_head() {
|
||||
atf_set "descr" "Tests that creating a non-empty file and later" \
|
||||
"manipulating it updates times correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
non_empty_body() {
|
||||
test_mount
|
||||
|
||||
echo foo >b || atf_fail "Non-empty creation failed"
|
||||
eval $(stat -s b | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
|
||||
sleep 1
|
||||
atf_check 'cat b' 0 ignore null
|
||||
eval $(stat -s b) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case link
|
||||
link_head() {
|
||||
atf_set "descr" "Tests that linking to an existing file updates" \
|
||||
"times correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
link_body() {
|
||||
test_mount
|
||||
|
||||
echo foo >c || atf_fail "Non-empty creation failed"
|
||||
eval $(stat -s c | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
|
||||
sleep 1
|
||||
atf_check 'ln c d' 0 null null
|
||||
eval $(stat -s c) || atf_fail "stat failed"
|
||||
[ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case rename
|
||||
rename_head() {
|
||||
atf_set "descr" "Tests that renaming an existing file updates" \
|
||||
"times correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
rename_body() {
|
||||
test_mount
|
||||
|
||||
atf_check 'mkdir e' 0 null null
|
||||
echo foo >e/a || atf_fail "Creation failed"
|
||||
eval $(stat -s e | sed -e 's|st_|dost_|g') || atf_fail "stat failed"
|
||||
eval $(stat -s e/a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
sleep 1
|
||||
atf_check 'mv e/a e/b' 0 null null
|
||||
eval $(stat -s e | sed -e 's|st_|dst_|g') || atf_fail "stat failed"
|
||||
eval $(stat -s e/b) || atf_fail "stat failed"
|
||||
[ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
[ ${dst_mtime} -gt ${dost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case empty
|
||||
atf_add_test_case non_empty
|
||||
atf_add_test_case link
|
||||
atf_add_test_case rename
|
||||
}
|
42
regress/sys/fs/tmpfs/t_trail_slash → tests/fs/tmpfs/t_trail_slash.sh
Executable file → Normal file
42
regress/sys/fs/tmpfs/t_trail_slash → tests/fs/tmpfs/t_trail_slash.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_trail_slash.sh,v 1.1 2007/11/12 15:18:28 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_trail_slash,v 1.4 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,22 +32,28 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that trailing slashes are not stored in directory names and that
|
||||
# they do not cause crashes.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case main
|
||||
main_head() {
|
||||
atf_set "descr" "Verifies that trailing slashes are not stored" \
|
||||
"in directory names and that they do not cause" \
|
||||
"crashes"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
main_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Trailing slashes are not taken into account"
|
||||
mkdir a/ || die
|
||||
touch a/b || die
|
||||
[ -f a/b ] || die
|
||||
rm a/b || die
|
||||
rmdir a/ || die
|
||||
atf_check 'mkdir a/' 0 null null
|
||||
atf_check 'touch a/b' 0 null null
|
||||
atf_check 'test -f a/b' 0 null null
|
||||
atf_check 'rm a/b' 0 null null
|
||||
atf_check 'rmdir a/' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case main
|
||||
}
|
47
regress/sys/fs/tmpfs/t_truncate → tests/fs/tmpfs/t_truncate.sh
Executable file → Normal file
47
regress/sys/fs/tmpfs/t_truncate → tests/fs/tmpfs/t_truncate.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_truncate.sh,v 1.1 2007/11/12 15:18:28 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_truncate,v 1.4 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,25 +32,32 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that the truncate operations work.
|
||||
#
|
||||
|
||||
test_run() {
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Verifies that the truncate operation works"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Write to new file works"
|
||||
jot 10000 >a || die
|
||||
test_name "Truncate the file to smaller size works"
|
||||
echo foo >a || die
|
||||
[ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || die
|
||||
echo "Creating big file"
|
||||
jot 10000 >a || atf_fail "Failed to create big file"
|
||||
echo "Trunctaing the file to a smaller size"
|
||||
echo foo >a || atf_fail "Failed to truncate file to a smaller size"
|
||||
[ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \
|
||||
echo "Truncated file is incorrect"
|
||||
|
||||
test_name "Truncate to zero size"
|
||||
>a || die
|
||||
test_name "Truncate to zero size, second try"
|
||||
>a || die
|
||||
echo "Truncating to zero bytes"
|
||||
>a || atf_fail "Failed to truncate to 0"
|
||||
echo "Truncating to zero bytes, second try"
|
||||
>a || atf_fail "Failed to re-truncate to 0"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
}
|
69
regress/sys/fs/tmpfs/t_vnd → tests/fs/tmpfs/t_vnd.sh
Executable file → Normal file
69
regress/sys/fs/tmpfs/t_vnd → tests/fs/tmpfs/t_vnd.sh
Executable file → Normal file
@ -1,13 +1,7 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_vnd.sh,v 1.1 2007/11/12 15:18:28 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_vnd,v 1.1 2006/11/09 15:25:37 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -41,50 +35,47 @@
|
||||
# Verifies that vnd works with files stored in tmpfs.
|
||||
#
|
||||
|
||||
die_mounted() {
|
||||
umount mnt
|
||||
die_configured
|
||||
atf_test_case basic
|
||||
basic_head() {
|
||||
atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
|
||||
die_configured() {
|
||||
vnconfig -u /dev/vnd3
|
||||
die
|
||||
}
|
||||
|
||||
test_run() {
|
||||
basic_body() {
|
||||
test_mount
|
||||
|
||||
test_name "Creation of disk image"
|
||||
dd if=/dev/zero of=disk.img bs=1m count=10 >/dev/null 2>&1 || die
|
||||
atf_check 'dd if=/dev/zero of=disk.img bs=1m count=10' 0 ignore ignore
|
||||
atf_check 'vnconfig /dev/vnd3 disk.img' 0 null null
|
||||
|
||||
test_name "Configuration of vnd"
|
||||
vnconfig /dev/vnd3 disk.img || die
|
||||
atf_check 'newfs /dev/rvnd3a' 0 ignore ignore
|
||||
|
||||
test_name "Formatting of disk image"
|
||||
newfs /dev/rvnd3a >/dev/null 2>&1 || die_configured
|
||||
atf_check 'mkdir mnt' 0 null null
|
||||
atf_check 'mount /dev/vnd3a mnt' 0 null null
|
||||
|
||||
test_name "Mounting of disk image"
|
||||
mkdir mnt || die
|
||||
mount /dev/vnd3a mnt || die_configured
|
||||
|
||||
test_name "Creation of several files"
|
||||
echo "Creating test files"
|
||||
for f in $(jot 100); do
|
||||
jot 1000 >mnt/$f || die_mounted
|
||||
jot 1000 >mnt/${f} || atf_fail "Failed to create file ${f}"
|
||||
done
|
||||
|
||||
test_name "Verification of created files"
|
||||
echo "Verifying created files"
|
||||
for f in $(jot 100); do
|
||||
[ $(md5 mnt/$f | cut -d ' ' -f 4) = \
|
||||
53d025127ae99ab79e8502aae2d9bea6 ] || die_mounted
|
||||
[ $(md5 mnt/${f} | cut -d ' ' -f 4) = \
|
||||
53d025127ae99ab79e8502aae2d9bea6 ] || \
|
||||
atf_fail "Invalid checksum for file ${f}"
|
||||
done
|
||||
|
||||
test_name "Unmounting of disk image"
|
||||
umount mnt || die_configured
|
||||
|
||||
test_name "Deconfiguration of vnd"
|
||||
vnconfig -u /dev/vnd3 || die
|
||||
atf_check 'umount mnt' 0 null null
|
||||
atf_check 'vnconfig -u /dev/vnd3' 0 null null
|
||||
|
||||
test_unmount
|
||||
}
|
||||
basic_cleanup() {
|
||||
umount mnt 2>/dev/null 1>&2
|
||||
vnconfig -u /dev/vnd3 2>/dev/null 1>&2
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case basic
|
||||
}
|
48
regress/sys/fs/tmpfs/t_vnode_leak → tests/fs/tmpfs/t_vnode_leak.sh
Executable file → Normal file
48
regress/sys/fs/tmpfs/t_vnode_leak → tests/fs/tmpfs/t_vnode_leak.sh
Executable file → Normal file
@ -1,14 +1,8 @@
|
||||
#!/bin/sh
|
||||
# $NetBSD: t_vnode_leak.sh,v 1.1 2007/11/12 15:18:29 jmmv Exp $
|
||||
#
|
||||
# $NetBSD: t_vnode_leak,v 1.5 2006/11/09 16:20:06 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
||||
# 2005 program.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
@ -38,24 +32,36 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Verifies that vnodes are not leaked and that their reclaim operation works
|
||||
# as expected: i.e., when all free vnodes are exhausted, unused ones have to
|
||||
# be recycled, which is what the reclaim operation does.
|
||||
#
|
||||
atf_test_case main
|
||||
main_head() {
|
||||
atf_set "descr" "Verifies that vnodes are not leaked and that" \
|
||||
"their reclaim operation works as expected: i.e.," \
|
||||
"when all free vnodes are exhausted, unused ones" \
|
||||
"have to be recycled, which is what the reclaim" \
|
||||
"operation does."
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
main_body() {
|
||||
echo "Lowering kern.maxvnodes to 2000"
|
||||
sysctl kern.maxvnodes | awk '{ print $3; }' >oldvnodes
|
||||
atf_check 'sysctl -w kern.maxvnodes=2000' 0 ignore null
|
||||
|
||||
test_run() {
|
||||
oldvnodes=$(sysctl kern.maxvnodes | awk '{ print $3; }')
|
||||
sysctl -w kern.maxvnodes=2000 >/dev/null || die
|
||||
|
||||
test_name "vnodes are properly reclaimed"
|
||||
test_mount -o -s$(((4000 + 2) * 4096))
|
||||
echo "Creating 4000 directories"
|
||||
for f in $(jot 4000); do
|
||||
mkdir ${f}
|
||||
done
|
||||
test_unmount
|
||||
|
||||
sysctl -w kern.maxvnodes=${oldvnodes} >/dev/null || die
|
||||
}
|
||||
main_cleanup() {
|
||||
oldvnodes=$(cat oldvnodes)
|
||||
echo "Restoring kern.maxvnodes to ${oldvnodes}"
|
||||
sysctl -w kern.maxvnodes=${oldvnodes}
|
||||
}
|
||||
|
||||
. ${SUBRDIR}/h_funcs.subr
|
||||
atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/../h_funcs.subr
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case main
|
||||
}
|
Loading…
Reference in New Issue
Block a user