All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: viro@ZenIV.linux.org.uk, torvalds@linux-foundation.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	bfields@fieldses.org, hch@infradead.org,
	akpm@linux-foundation.org, dhowells@redhat.com, zab@redhat.com,
	jack@suse.cz, luto@amacapital.net, mszeredi@suse.cz
Subject: Re: xfstest for renameat2 system call (was: [PATCH 00/13] cross rename v4)
Date: Tue, 8 Apr 2014 11:23:22 +1000	[thread overview]
Message-ID: <20140408012322.GA22917@dastard> (raw)
In-Reply-To: <20140319135706.GA24182@tucsk.piliscsaba.szeredi.hu>

On Wed, Mar 19, 2014 at 02:57:06PM +0100, Miklos Szeredi wrote:
> Hi Dave,
> 
> On Mon, Feb 17, 2014 at 07:19:11PM +1100, Dave Chinner wrote:
> > On Wed, Feb 12, 2014 at 06:18:52PM +0100, Miklos Szeredi wrote:
> > > On Tue, Feb 11, 2014 at 05:01:41PM +0100, Miklos Szeredi wrote:
> > > > On Mon, Feb 10, 2014 at 09:51:45PM +1100, Dave Chinner wrote:
> > > 
> > > > > Miklos, can you please write an xfstest for this new API? That way
> > > > > we can verify that the behaviour is as documented, and we can ensure
> > > > > that when we implement it on other filesystems it works exactly the
> > > > > same on all filesystems?
> > > 
> > > This is a standalone testprog, but I guess it's trivial to integrate into
> > > xfstests.
> > 
> > Same problem with integrating any standalone test program into
> > xfstests - we end up with a standalone pass/fail test instead of a
> > bunch of components we can reuse and refactor for other tests.  But
> > we can work around that for the moment.
> > 
> > [ FWIW, the normal way to write an xfstest like this is to write a
> > small helper program that just does the renameat2() syscall (we
> > often use xfs_io to provide this) and everything is just shell
> > scripts to drive the helper program in the necessary way. We don't
> > directly check that mode, size, destination of a file is correct -
> > just stat(1) on the expected destinations is sufficient to capture
> > this information. stdout is captured by the test harness and used to match
> > against a golden output. If the match fails, the test fails.
> > 
> > This would allow us to use the same test infrastructure for testing
> > a coreutils binary that implemented renameat2 when that comes
> > along... ]
> 
> Okay, here's a patch for xfstests implementing the above.
> 
> The renameat2 patches aren't merged yet, but I hope they will be in the 3.15
> cycle.  Until then this is just an RFC.

Hi Miklos,

Is renameat2 likely to be merged this cycle? If so, can you resubmit
this series to xfs@oss.sgi.com as a patch per test? Some other
comments are below.

> index 0000000..e235c4c
> --- /dev/null
> +++ b/common/renameat2
> @@ -0,0 +1,128 @@
> +######
> +#
> +# renameat2 helpers
....

tab indents (8 spaces), please.

.....
> +_rename_tests()
> +{
> +    flags=$1
> +
> +    #same directory renames
> +    _rename_tests_source_dest $tmp/src $tmp/dst     "samedir "
> +
> +    #cross directory renames
> +    mkdir $tmp/x $tmp/y
> +    _rename_tests_source_dest $tmp/x/src $tmp/y/dst "crossdir"
> +    rmdir $tmp/x $tmp/y
> +}

The way you are using $tmp in these tests is wrong. $tmp is used by
the test harness for temporary files that we don't want to impact
the running of a test. Hence using $tmp as the location for the test
is incorrect. You should pass the test directory into this function

_rename_tests()
{
	local testdir=$1
	local flags=$2

	#same directory renames
	_rename_tests_source_dest $testdir/src $testdir/dst "samedir "

	#cross directory renames
	mkdir $testdir/x $testdir/y
	_rename_tests_source_dest $testdir/x/src $testdir/y/dst "crossdir"
	rmdir $testdir/x $testdir/y
}

> diff --git a/tests/generic/323 b/tests/generic/323
> new file mode 100755
> index 0000000..1f17246
> --- /dev/null
> +++ b/tests/generic/323
> @@ -0,0 +1,56 @@
> +#! /bin/bash
> +# FS QA Test No. 323

FS QA Test No. generic/323

> +#
> +# Check renameat2 syscall without flags
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2014 Miklos Szeredi.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=$TEST_DIR/$$

The reason this is wrong is that there is no guarantee that
$TEST_DIR is defined here or that it remains mounted throughout the
test. Lots of internal functions rely on $tmp always being there and
anything written there can always be found, and we can unmount
TEST_DIR in the middle of tests.  Hence:

tmp=/tmp/$$

is the usual location for $tmp.

> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/renameat2
> +
> +_supported_fs generic
> +_supported_os Linux
> +
> +_requires_renameat2
> +
> +# real QA test starts here
> +
> +mkdir $tmp
> +_rename_tests
> +rmdir $tmp

rename_dir=$TEST_DIR/$$
mkdir -p $rename_dir
_rename_tests $rename_dir
rmdir $rename_dir

The other tests need the same fixes, but otherwise they look OK.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2014-04-08  1:23 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 16:48 [PATCH 00/13] cross rename v4 Miklos Szeredi
2014-02-07 16:48 ` [PATCH 01/13] vfs: add d_is_dir() Miklos Szeredi
2014-02-07 17:36   ` J. Bruce Fields
2014-02-07 19:30     ` David Howells
2014-02-07 16:49 ` [PATCH 02/13] vfs: rename: move d_move() up Miklos Szeredi
2014-02-07 16:49 ` [PATCH 03/13] vfs: rename: use common code for dir and non-dir Miklos Szeredi
2014-02-07 16:49 ` [PATCH 04/13] vfs: add renameat2 syscall Miklos Szeredi
2014-02-07 16:49 ` [PATCH 05/13] vfs: add RENAME_NOREPLACE flag Miklos Szeredi
2014-02-07 16:49 ` [PATCH 06/13] security: add flags to rename hooks Miklos Szeredi
2014-02-07 16:49 ` [PATCH 07/13] vfs: lock_two_nondirectories: allow directory args Miklos Szeredi
2014-02-07 21:16   ` J. Bruce Fields
2014-02-11 15:32     ` Miklos Szeredi
2014-02-07 16:49 ` [PATCH 08/13] vfs: add cross-rename Miklos Szeredi
2014-02-07 22:40   ` J. Bruce Fields
2014-02-11 15:55     ` Miklos Szeredi
2014-02-07 16:49 ` [PATCH 09/13] ext4: rename: create ext4_renament structure for local vars Miklos Szeredi
2014-02-07 16:49 ` [PATCH 10/13] ext4: rename: move EMLINK check up Miklos Szeredi
2014-02-07 16:49 ` [PATCH 11/13] ext4: rename: split out helper functions Miklos Szeredi
2014-02-07 16:49 ` [PATCH 12/13] ext4: add cross rename support Miklos Szeredi
2014-02-11 21:23   ` Jan Kara
2014-02-07 16:49 ` [PATCH 13/13] vfs: merge rename2 into rename Miklos Szeredi
2014-02-07 22:46 ` [PATCH 00/13] cross rename v4 J. Bruce Fields
2014-02-11 15:57   ` Miklos Szeredi
2014-02-13 19:32     ` J. Bruce Fields
2014-02-10 10:51 ` Dave Chinner
2014-02-11 16:01   ` Miklos Szeredi
2014-02-12 17:18     ` Miklos Szeredi
2014-02-17  8:19       ` Dave Chinner
2014-02-17 18:04         ` Theodore Ts'o
2014-03-19 13:57         ` xfstest for renameat2 system call (was: [PATCH 00/13] cross rename v4) Miklos Szeredi
2014-04-08  1:23           ` Dave Chinner [this message]
2014-02-13 15:54 ` [PATCH 00/13] cross rename v4 David Howells
2014-02-13 16:25   ` Miklos Szeredi
2014-02-13 16:42     ` David Howells
2014-02-13 17:28       ` Miklos Szeredi
2014-02-13 18:21         ` Andy Lutomirski
2014-02-13 18:29         ` Linus Torvalds
2014-02-13 18:56           ` Miklos Szeredi
2014-02-13 19:20             ` Linus Torvalds
2014-02-13 19:02           ` David Howells
2014-02-13 19:32             ` Linus Torvalds
2014-02-13 20:17               ` Eric W. Biederman
2014-02-13 20:28               ` Miklos Szeredi
2014-02-24 17:12                 ` Miklos Szeredi
2014-02-24 17:49                   ` Linus Torvalds
2014-02-25  4:07                   ` J. R. Okajima
2014-02-26 15:15                   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140408012322.GA22917@dastard \
    --to=david@fromorbit.com \
    --cc=akpm@linux-foundation.org \
    --cc=bfields@fieldses.org \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@suse.cz \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=zab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.