diff options
author | ngie <ngie@FreeBSD.org> | 2014-12-05 11:44:18 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2014-12-05 11:44:18 +0000 |
commit | 2ceba1b1340a12cfe78aa2589bb0bba87f7b33d9 (patch) | |
tree | e08795fd1d98cb1be488d6510c6b57e60398f2fa /contrib/pjdfstest/tests/truncate | |
parent | f88754a36c36675f66d041b57d0da1b2ea102c62 (diff) | |
download | FreeBSD-src-2ceba1b1340a12cfe78aa2589bb0bba87f7b33d9.zip FreeBSD-src-2ceba1b1340a12cfe78aa2589bb0bba87f7b33d9.tar.gz |
MFC r272057,r272083,r272084,r272087,r274016:
r272057:
Import pjdfstest from ^/vendor/pjdfstest/abf03c3a47745d4521b0e4aa141317553ca48f91
- Remove tools/regression/pjdfstest
- Add upgrade directions for contrib/pjdfstest
- Add a note to UPDATING for the move (the reachover Makefiles are coming
soon)
Functional differences:
- ftruncate testcases are added from upstream (github)
Non-functional differences:
- The copyright for the project has been updated to 2012
- pjd's contact information has been updated
Discussed with: -testing, jmmv, pjd
Sponsored by: EMC / Isilon Storage Division
r272083:
Expect ELOOP on Darwin/Linux with "O_NOFOLLOW was specified and the target is a
symbolic link" case. Assume EMLINK on the rest of the OSes (FreeBSD, Solaris,
etc)
Sponsored by: EMC / Isilon Storage Division
r272084:
Fix the executed testplan count
Sponsored by: EMC / Isilon Storage Division
r272087:
Increase the memory disk size in the following testcases to avoid mount
failures, which would cause cascade failures in the rest of the test
run:
link/15.t, open/19.t, mkdir/11.t, mkfifo/11.t, symlink/11.t
Fail quickly in all of the testcases if mdconfig, mount, umount, etc
fails to avoid issues similar to this in the future
Submitted by: Casey Peel <cpeel@isilon.com>
Sponsored by: EMC / Isilon Storage Division
r274016:
Integrate pjdfstest test suite execution into kyua
pjdfstest execution is opt-in and must be done as root due to some of the
assumptions made by the test suite and lack of error checking in the non-root
case
A description of how to execute pjdfstest with kyua is provided in
share/pjdfstest/README
Phabric: D824 (an earlier prototype patch)
Relnotes: yes
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/pjdfstest/tests/truncate')
-rw-r--r-- | contrib/pjdfstest/tests/truncate/00.t | 51 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/01.t | 18 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/02.t | 18 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/03.t | 22 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/04.t | 17 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/05.t | 32 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/06.t | 24 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/07.t | 19 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/08.t | 78 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/09.t | 15 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/10.t | 32 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/11.t | 18 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/12.t | 27 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/13.t | 16 | ||||
-rw-r--r-- | contrib/pjdfstest/tests/truncate/14.t | 12 |
15 files changed, 399 insertions, 0 deletions
diff --git a/contrib/pjdfstest/tests/truncate/00.t b/contrib/pjdfstest/tests/truncate/00.t new file mode 100644 index 0000000..6a77a8f --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/00.t @@ -0,0 +1,51 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate descrease/increase file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +expect 0 create ${n0} 0644 +expect 0 truncate ${n0} 1234567 +expect 1234567 lstat ${n0} size +expect 0 truncate ${n0} 567 +expect 567 lstat ${n0} size +expect 0 unlink ${n0} + +dd if=/dev/random of=${n0} bs=12345 count=1 >/dev/null 2>&1 +expect 0 truncate ${n0} 23456 +expect 23456 lstat ${n0} size +expect 0 truncate ${n0} 1 +expect 1 lstat ${n0} size +expect 0 unlink ${n0} + +# successful truncate(2) updates ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 truncate ${n0} 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +# unsuccessful truncate(2) does not update ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 truncate ${n0} 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/truncate/01.t b/contrib/pjdfstest/tests/truncate/01.t new file mode 100644 index 0000000..a8e95ac --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR truncate ${n0}/${n1}/test 123 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/02.t b/contrib/pjdfstest/tests/truncate/02.t new file mode 100644 index 0000000..83de38d --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/02.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect 123 stat ${nx} size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 diff --git a/contrib/pjdfstest/tests/truncate/03.t b/contrib/pjdfstest/tests/truncate/03.t new file mode 100644 index 0000000..41e9862 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/03.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect regular,123 stat ${nx} type,size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/truncate/04.t b/contrib/pjdfstest/tests/truncate/04.t new file mode 100644 index 0000000..cd1cfc6 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT truncate ${n0}/${n1}/test 123 +expect ENOENT truncate ${n0}/${n1} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/05.t b/contrib/pjdfstest/tests/truncate/05.t new file mode 100644 index 0000000..f128815 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/05.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..15" + +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 truncate ${n1}/${n2} 123 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 0 chmod ${n1} 0755 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 1234 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/06.t b/contrib/pjdfstest/tests/truncate/06.t new file mode 100644 index 0000000..1ce516f --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/06.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES if the named file is not writable by the user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 create ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 chown ${n1} 65534 65534 +expect 0 chmod ${n1} 0444 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 unlink ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/07.t b/contrib/pjdfstest/tests/truncate/07.t new file mode 100644 index 0000000..44f87e7 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP truncate ${n0}/test 123 +expect ELOOP truncate ${n1}/test 123 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/truncate/08.t b/contrib/pjdfstest/tests/truncate/08.t new file mode 100644 index 0000000..6f205ef --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/08.t @@ -0,0 +1,78 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EPERM if the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..22" + ;; +FreeBSD:UFS) + echo "1..44" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM truncate ${n0} 123 +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect EPERM truncate ${n0} 123 +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/truncate/09.t b/contrib/pjdfstest/tests/truncate/09.t new file mode 100644 index 0000000..d7e082d --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/09.t @@ -0,0 +1,15 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EISDIR if the named file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +expect EISDIR truncate ${n0} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/10.t b/contrib/pjdfstest/tests/truncate/10.t new file mode 100644 index 0000000..ced3583 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/10.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 truncate ${n0}/${n1} 123 +expect 123 stat ${n0}/${n1} size +mount -ur /dev/md${n} +expect EROFS truncate ${n0}/${n1} 1234 +expect 123 stat ${n0}/${n1} size +mount -uw /dev/md${n} +expect 0 truncate ${n0}/${n1} 1234 +expect 1234 stat ${n0}/${n1} size +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/11.t b/contrib/pjdfstest/tests/truncate/11.t new file mode 100644 index 0000000..b00d7b8 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/11.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ETXTBSY the file is a pure procedure (shared text) file that is being executed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..2" + +n0=`namegen` + +cp -pf `which sleep` ${n0} +./${n0} 3 & +expect ETXTBSY truncate ${n0} 123 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/12.t b/contrib/pjdfstest/tests/truncate/12.t new file mode 100644 index 0000000..1825456 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/12.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFBIG or EINVAL if the length argument was greater than the maximum file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 create ${n0} 0644 +r=`${fstest} truncate ${n0} 999999999999999 2>/dev/null` +case "${r}" in +EFBIG|EINVAL) + expect 0 stat ${n0} size + ;; +0) + expect 999999999999999 stat ${n0} size + ;; +*) + echo "not ok ${ntest}" + ntest=`expr ${ntest} + 1` + ;; +esac +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/13.t b/contrib/pjdfstest/tests/truncate/13.t new file mode 100644 index 0000000..7c9f0d4 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/13.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EINVAL if the length argument was less than 0" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EINVAL -- truncate ${n0} -1 +expect EINVAL -- truncate ${n0} -999999 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/14.t b/contrib/pjdfstest/tests/truncate/14.t new file mode 100644 index 0000000..a238771 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/14.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT truncate NULL 123 +expect EFAULT truncate DEADCODE 123 |