More tests, especially for lchown(2).

This commit is contained in:
pjd 2010-08-17 06:08:09 +00:00
parent 8eb397b4ca
commit 407c718f42
6 changed files with 54 additions and 13 deletions

View File

@ -6,7 +6,7 @@ desc="chown returns ENOTDIR if a component of the path prefix is not a directory
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..5"
echo "1..6"
n0=`namegen`
n1=`namegen`
@ -14,5 +14,6 @@ n1=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n0}/${n1} 0644
expect ENOTDIR chown ${n0}/${n1}/test 65534 65534
expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -6,12 +6,18 @@ desc="chown returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..4"
echo "1..9"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT chown ${n0}/${n1}/test 65534 65534
expect ENOENT chown ${n0}/${n1} 65534 65534
expect ENOENT lchown ${n0}/${n1}/test 65534 65534
expect ENOENT lchown ${n0}/${n1} 65534 65534
expect 0 symlink ${n2} ${n0}/${n1}
expect ENOENT chown ${n0}/${n1} 65534 65534
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -6,7 +6,7 @@ desc="chown returns EACCES when search permission is denied for a component of t
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..15"
echo "1..18"
n0=`namegen`
n1=`namegen`
@ -22,11 +22,14 @@ expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65533
expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534
expect EACCES -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65534
expect 0 chmod ${n1} 0755
expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534
expect 65534,65534 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65533
expect 65534,65533 -u 65534 -g 65533 stat ${n1}/${n2} uid,gid
expect 0 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -6,14 +6,18 @@ desc="chown returns ELOOP if too many symbolic links were encountered in transla
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..6"
echo "1..10"
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP chown ${n0} 65534 65534
expect ELOOP chown ${n1} 65534 65534
expect ELOOP chown ${n0}/test 65534 65534
expect ELOOP chown ${n1}/test 65534 65534
expect ELOOP lchown ${n0}/test 65534 65534
expect ELOOP lchown ${n1}/test 65534 65534
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@ -6,23 +6,48 @@ desc="chown returns EPERM if the operation would change the ownership, but the e
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..11"
echo "1..132"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`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
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}/${n2} 65534 65534
expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533
expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534
expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533
expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533
expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3}
expect EPERM -u 65534 -g 65534 chown ${n1}/${n3} 65533 65533
expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65534 65534
expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65533 65533
expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n3} -1 65533
expect 0 unlink ${n1}/${n3}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}/${n2}
else
expect 0 unlink ${n1}/${n2}
fi
fi
create_file ${type} ${n1}/${n2} 65534 65534
expect EPERM -u 65534 -g 65534 lchown ${n1}/${n2} 65533 65533
expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65534 65534
expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65533 65533
expect EPERM -u 65534 -g 65534 -- lchown ${n1}/${n2} -1 65533
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}/${n2}
else
expect 0 unlink ${n1}/${n2}
fi
done
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -6,7 +6,9 @@ desc="chown returns EFAULT if the path argument points outside the process's all
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..2"
echo "1..4"
expect EFAULT chown NULL 65534 65534
expect EFAULT chown DEADCODE 65534 65534
expect EFAULT lchown NULL 65534 65534
expect EFAULT lchown DEADCODE 65534 65534