[PATCH 2/3] generic: add a basic O_TMPFILE test

Dave Chinner david at fromorbit.com
Thu Mar 13 06:16:30 CDT 2014


On Thu, Mar 13, 2014 at 03:13:04AM -0700, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>  tests/generic/004     |   70 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/004.out |    6 +++++
>  tests/generic/group   |    1 +
>  3 files changed, 77 insertions(+)
>  create mode 100755 tests/generic/004
>  create mode 100644 tests/generic/004.out
> 
> diff --git a/tests/generic/004 b/tests/generic/004
> new file mode 100755
> index 0000000..c653530
> --- /dev/null
> +++ b/tests/generic/004
> @@ -0,0 +1,70 @@
> +#! /bin/bash
> +# FS QA Test No. 004
> +#
> +# Test O_TMPFILE opens

it also tests linking a tmpfile...

> +testfile="${TEST_DIR}/tst-tmpfile-flink"
> +
> +# test creating a r/w tmpfile, do I/O and link it into the namespace
> +$XFS_IO_PROG -T \
> +	-c "pwrite 0 4096" \
> +	-c "pread 0 4096" \
> +	-c "flink ${testfile}" \
> +	${TEST_DIR} | _filter_xfs_io
> +
> +if [ ! -f "${testfile}" ]; then
> +    echo "failed to link testfile into place"
> +    exit 1
> +fi
> +
> +rm -f ${tmpfile}

You could just replace the  check for the $testfile existing and
then the removal with:

rm $testfile

because if it doesn't exist that will thrown an ENOENT error like:

rm: cannot remove "foo": No such file or directory

And that will fail the test. There's also no reason to exit if there
is an error, because the rest of the test does not depend on
$testfile being removed. The golden output comparison will then
cause the test to fail...

Cheers,

Dave.
-- 
Dave Chinner
david at fromorbit.com



More information about the xfs mailing list