Commit 9a56205f authored by Enji Cooper's avatar Enji Cooper
Browse files

Add vendor import for pjdfstest

This vendor import code was obtained from
https://github.com/pjd/pjdfstest/commit/abf03c3a47745d4521b0e4aa141317553ca48f91

Approved by: rpaulo (mentor)
Phabric: D743
Sponsored by: EMC / Isilon Storage Division
parents
$FreeBSD: head/tools/regression/pjdfstest/LICENSE 211354 2010-08-15 21:29:03Z pjd $
License for all regression tests available with pjdfstest:
Copyright (c) 2006-2012 Pawel Jakub Dawidek <pawel@dawidek.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
# $FreeBSD$
PROG= pjdfstest
${PROG}: ${PROG}.c
@OSTYPE=`uname`; \
CFLAGS=-D__OS_$${OSTYPE}__; \
if [ $$OSTYPE = "FreeBSD" ]; then \
CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS -DHAS_CHFLAGSAT -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL -DHAS_BINDAT -DHAS_CONNECTAT -DHAS_LPATHCONF"; \
elif [ $$OSTYPE = "SunOS" ]; then \
CFLAGS="$$CFLAGS -DHAS_TRUNCATE64 -DHAS_STAT64"; \
CFLAGS="$$CFLAGS -lsocket"; \
elif [ $$OSTYPE = "Darwin" ]; then \
CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS"; \
elif [ $$OSTYPE == "Linux" ]; then \
CFLAGS="$$CFLAGS -D_GNU_SOURCE"; \
else \
echo "Unsupported operating system: ${OSTYPE}."; \
exit 1; \
fi; \
cmd="gcc -Wall $$CFLAGS ${PROG}.c -o ${PROG}"; \
echo $$cmd; \
$$cmd
clean:
rm -f ${PROG}
$FreeBSD: head/tools/regression/pjdfstest/README 211354 2010-08-15 21:29:03Z pjd $
Few notes on how to use pjdfstest in short steps:
# cd pjdfstest
# vi tests/conf
Change 'fs' to file system type you want to test (UFS or ZFS).
# vi Makefile
You need to manually tweak few things by editing CFLAGS lines
at the top of the file.
# make
It will compile pjdfstest utility which is used by regression tests.
# cd /path/to/file/system/you/want/to/test/
# prove -r /path/to/pjdfstest/tests
That's all. Enjoy.
Currently supported operating systems: FreeBSD, Solaris.
Currently supported file system types: UFS, ZFS.
--
Pawel Jakub Dawidek <pawel@dawidek.net>
This diff is collapsed.
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags changes flags"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:UFS)
allflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE"
systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
echo "1..742"
;;
FreeBSD:ZFS)
allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP"
systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
echo "1..482"
;;
*)
quick_exit
;;
esac
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
for type in regular dir fifo block char socket; do
create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 chflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
expect 0 chflags ${n0} ${userflags}
expect ${userflags} stat ${n0} flags
expect 0 chflags ${n0} ${systemflags}
expect ${systemflags} stat ${n0} flags
expect 0 chflags ${n0} none
expect none stat ${n0} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 lchflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
expect 0 lchflags ${n0} ${userflags}
expect ${userflags} stat ${n0} flags
expect 0 lchflags ${n0} ${systemflags}
expect ${systemflags} stat ${n0} flags
expect 0 lchflags ${n0} none
expect none stat ${n0} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
expect 0 create ${n0} 0644
expect 0 symlink ${n0} ${n1}
expect none stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} ${allflags}
expect ${allflags} stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} ${userflags}
expect ${userflags} stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} ${systemflags}
expect ${systemflags} stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} none
expect none stat ${n1} flags
expect none lstat ${n1} flags
expect 0 unlink ${n1}
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 symlink ${n0} ${n1}
expect none stat ${n1} flags
expect none lstat ${n1} flags
expect 0 lchflags ${n1} ${allflags}
expect ${allflags} lstat ${n1} flags
expect none stat ${n1} flags
expect 0 lchflags ${n1} ${userflags}
expect ${userflags} lstat ${n1} flags
expect none stat ${n1} flags
expect 0 lchflags ${n1} ${systemflags}
expect ${systemflags} lstat ${n1} flags
expect none stat ${n1} flags
expect 0 lchflags ${n1} none
expect none lstat ${n1} flags
expect none stat ${n1} flags
expect 0 unlink ${n1}
expect 0 unlink ${n0}
# successful chflags(2) updates ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 chflags ${n0} ${flag}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 lchflags ${n0} ${flag}
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -lt $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
# unsuccessful chflags(2) does not update ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EPERM -u 65534 chflags ${n0} ${flag}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect EPERM -u 65534 lchflags ${n0} ${flag}
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -eq $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
cd ${cdir}
expect 0 rmdir ${n2}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/01.t 211474 2010-08-18 22:06:43Z pjd $
desc="chflags returns ENOTDIR if a component of the path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..17"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
for type in regular fifo block char socket; do
create_file ${type} ${n0}/${n1}
expect ENOTDIR chflags ${n0}/${n1}/test SF_IMMUTABLE
expect 0 unlink ${n0}/${n1}
done
expect 0 rmdir ${n0}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..12"
nx=`namegen_max`
nxx="${nx}x"
expect 0 create ${nx} 0644
expect 0 chflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 chflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE
expect 0 create ${nx} 0644
expect 0 lchflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 lchflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..12"
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 create ${nx} 0644
expect 0 chflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 chflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE
expect 0 create ${nx} 0644
expect 0 lchflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 lchflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE
rm -rf "${nx%%/*}"
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..4"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT chflags ${n0}/${n1}/test SF_IMMUTABLE
expect ENOENT chflags ${n0}/${n1} SF_IMMUTABLE
expect 0 rmdir ${n0}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..16"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP
expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP
expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/06.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ELOOP if too many symbolic links were encountered in translating the pathname"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..6"
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP chflags ${n0}/test SF_IMMUTABLE
expect ELOOP chflags ${n1}/test SF_IMMUTABLE
expect 0 unlink ${n0}
expect 0 unlink ${n1}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..93"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
expect none stat ${n1} flags
expect 0 chown ${n1} 65534 65534
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
expect none stat ${n1} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
expect none lstat ${n1} flags
expect 0 lchown ${n1} 65534 65534
expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
expect none lstat ${n1} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
cd ${cdir}
expect 0 rmdir ${n0}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..249"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 chflags ${n1} ${flag}
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
done
expect 0 chflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 lchflags ${n1} ${flag}
expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
done
expect 0 lchflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
cd ${cdir}
expect 0 rmdir ${n0}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and securelevel is greater than 0"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..327"
n0=`namegen`
n1=`namegen`
n2=`namegen`
old=`sysctl -n security.jail.chflags_allowed`
sysctl security.jail.chflags_allowed=1 >/dev/null
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 chflags ${n1} ${flag}
jexpect 1 `pwd` EPERM chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
done
expect 0 chflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 lchflags ${n1} ${flag}
jexpect 1 `pwd` EPERM lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
jexpect 1 `pwd` EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
jexpect 1 `pwd` EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
done
expect 0 lchflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
sysctl security.jail.chflags_allowed=${old} >/dev/null
cd ${cdir}
expect 0 rmdir ${n0}
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $