xfs
[Top] [All Lists]

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

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 2/3] generic: add a basic O_TMPFILE test
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 13 Mar 2014 22:16:30 +1100
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20140313101433.445012299@xxxxxxxxxxxxxxxxxxxxxx>
References: <20140313101302.996355155@xxxxxxxxxxxxxxxxxxxxxx> <20140313101433.445012299@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Thu, Mar 13, 2014 at 03:13:04AM -0700, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  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@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>