FSTests Archive on lore.kernel.org
 help / color / Atom feed
* Re: [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE
  2020-01-29  8:58 ` [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE Omar Sandoval
@ 2020-01-29  7:02   ` Zorro Lang
  2020-02-23 14:46   ` Eryu Guan
  1 sibling, 0 replies; 3+ messages in thread
From: Zorro Lang @ 2020-01-29  7:02 UTC (permalink / raw)
  To: Omar Sandoval; +Cc: linux-fsdevel, fstests

On Tue, Jan 28, 2020 at 03:18:56PM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---

I think you'd better to send this patch to/cc fstests@vger.kernel.org to
get review or merge.

Thanks,
Zorro

>  common/rc             |  2 +-
>  tests/generic/593     | 97 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/593.out |  6 +++
>  tests/generic/group   |  1 +
>  4 files changed, 105 insertions(+), 1 deletion(-)
>  create mode 100755 tests/generic/593
>  create mode 100644 tests/generic/593.out
> 
> diff --git a/common/rc b/common/rc
> index eeac1355..257f65a1 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2172,7 +2172,7 @@ _require_xfs_io_command()
>  		;;
>  	"flink")
>  		local testlink=$TEST_DIR/$$.link.xfs_io
> -		testio=`$XFS_IO_PROG -F -f -c "flink $testlink" $testfile 2>&1`
> +		testio=`$XFS_IO_PROG -F -f -c "flink $param $testlink" $testfile 2>&1`
>  		rm -f $testlink > /dev/null 2>&1
>  		;;
>  	"-T")
> diff --git a/tests/generic/593 b/tests/generic/593
> new file mode 100755
> index 00000000..8a9fee02
> --- /dev/null
> +++ b/tests/generic/593
> @@ -0,0 +1,97 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Facebook.  All Rights Reserved.
> +#
> +# FS QA Test 593
> +#
> +# Smoke test linkat() with AT_LINK_REPLACE.
> +#
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +_supported_fs generic
> +_supported_os Linux
> +_require_test
> +_require_xfs_io_command "-T"
> +_require_xfs_io_command "flink" "-f"
> +
> +same_file() {
> +	[[ "$(stat -c '%d %i' "$1")" = "$(stat -c '%d %i' "$2")" ]]
> +}
> +
> +touch "$TEST_DIR/$seq.src"
> +touch "$TEST_DIR/$seq.tgt"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" ||
> +	echo "Target was not replaced"
> +
> +# Linking to the same file should be a noop.
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.src" "$TEST_DIR/$seq.src"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" || echo "Target changed?"
> +
> +# Should work with O_TMPFILE.
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" -T "$TEST_DIR"
> +stat -c '%h' "$TEST_DIR/$seq.tgt"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" &&
> +	echo "Target was not replaced"
> +
> +# It's okay if the target doesn't exist.
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt2" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt2" ||
> +	echo "Target was not created"
> +
> +# Can't replace directories.
> +mkdir "$TEST_DIR/$seq.dir"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.dir" "$TEST_DIR/$seq.src"
> +cd "$TEST_DIR/$seq.dir"
> +$XFS_IO_PROG -c "flink -f ." "$TEST_DIR/$seq.src"
> +$XFS_IO_PROG -c "flink -f .." "$TEST_DIR/$seq.src"
> +cd - &> /dev/null
> +
> +# Can't replace local mount points.
> +touch "$TEST_DIR/$seq.mnt"
> +$MOUNT_PROG --bind "$TEST_DIR/$seq.mnt" "$TEST_DIR/$seq.mnt"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.mnt" "$TEST_DIR/$seq.src"
> +
> +# Can replace mount points in other namespaces, though.
> +unshare -m \
> +	bash -c "$UMOUNT_PROG $TEST_DIR/$seq.mnt; $XFS_IO_PROG -c \"flink -f $TEST_DIR/$seq.mnt\" $TEST_DIR/$seq.src"
> +if $UMOUNT_PROG "$TEST_DIR/$seq.mnt" &> /dev/null; then
> +	echo "Mount point was not detached"
> +fi
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.mnt" ||
> +	echo "Mount point was not replaced"
> +
> +# Should replace symlinks, not follow them.
> +touch "$TEST_DIR/$seq.symtgt"
> +ln -s "$TEST_DIR/$seq.symtgt" "$TEST_DIR/$seq.sym"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.sym" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.sym" ||
> +	echo "Symlink was not replaced"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.symtgt" &&
> +	echo "Symlink target was replaced"
> +
> +rm -rf "$TEST_DIR/$seq."*
> +
> +status=0
> +exit
> diff --git a/tests/generic/593.out b/tests/generic/593.out
> new file mode 100644
> index 00000000..834c34bf
> --- /dev/null
> +++ b/tests/generic/593.out
> @@ -0,0 +1,6 @@
> +QA output created by 593
> +1
> +flink: Is a directory
> +flink: Is a directory
> +flink: Is a directory
> +flink: Device or resource busy
> diff --git a/tests/generic/group b/tests/generic/group
> index 6fe62505..0a87efca 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -595,3 +595,4 @@
>  590 auto prealloc preallocrw
>  591 auto quick rw pipe splice
>  592 auto quick encrypt
> +593 auto quick hardlink
> -- 
> 2.25.0
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE
       [not found] <cover.1580251857.git.osandov@fb.com>
@ 2020-01-29  8:58 ` Omar Sandoval
  2020-01-29  7:02   ` Zorro Lang
  2020-02-23 14:46   ` Eryu Guan
  0 siblings, 2 replies; 3+ messages in thread
From: Omar Sandoval @ 2020-01-29  8:58 UTC (permalink / raw)
  To: linux-fsdevel, Al Viro
  Cc: kernel-team, linux-api, David Howells, Amir Goldstein, Xi Wang, fstests

From: Omar Sandoval <osandov@fb.com>

Cc: fstests@vger.kernel.org
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 common/rc             |  2 +-
 tests/generic/593     | 97 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/593.out |  6 +++
 tests/generic/group   |  1 +
 4 files changed, 105 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/593
 create mode 100644 tests/generic/593.out

diff --git a/common/rc b/common/rc
index eeac1355..257f65a1 100644
--- a/common/rc
+++ b/common/rc
@@ -2172,7 +2172,7 @@ _require_xfs_io_command()
 		;;
 	"flink")
 		local testlink=$TEST_DIR/$$.link.xfs_io
-		testio=`$XFS_IO_PROG -F -f -c "flink $testlink" $testfile 2>&1`
+		testio=`$XFS_IO_PROG -F -f -c "flink $param $testlink" $testfile 2>&1`
 		rm -f $testlink > /dev/null 2>&1
 		;;
 	"-T")
diff --git a/tests/generic/593 b/tests/generic/593
new file mode 100755
index 00000000..8a9fee02
--- /dev/null
+++ b/tests/generic/593
@@ -0,0 +1,97 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Facebook.  All Rights Reserved.
+#
+# FS QA Test 593
+#
+# Smoke test linkat() with AT_LINK_REPLACE.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_xfs_io_command "-T"
+_require_xfs_io_command "flink" "-f"
+
+same_file() {
+	[[ "$(stat -c '%d %i' "$1")" = "$(stat -c '%d %i' "$2")" ]]
+}
+
+touch "$TEST_DIR/$seq.src"
+touch "$TEST_DIR/$seq.tgt"
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" "$TEST_DIR/$seq.src"
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" ||
+	echo "Target was not replaced"
+
+# Linking to the same file should be a noop.
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.src" "$TEST_DIR/$seq.src"
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" "$TEST_DIR/$seq.src"
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" || echo "Target changed?"
+
+# Should work with O_TMPFILE.
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" -T "$TEST_DIR"
+stat -c '%h' "$TEST_DIR/$seq.tgt"
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" &&
+	echo "Target was not replaced"
+
+# It's okay if the target doesn't exist.
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt2" "$TEST_DIR/$seq.src"
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt2" ||
+	echo "Target was not created"
+
+# Can't replace directories.
+mkdir "$TEST_DIR/$seq.dir"
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.dir" "$TEST_DIR/$seq.src"
+cd "$TEST_DIR/$seq.dir"
+$XFS_IO_PROG -c "flink -f ." "$TEST_DIR/$seq.src"
+$XFS_IO_PROG -c "flink -f .." "$TEST_DIR/$seq.src"
+cd - &> /dev/null
+
+# Can't replace local mount points.
+touch "$TEST_DIR/$seq.mnt"
+$MOUNT_PROG --bind "$TEST_DIR/$seq.mnt" "$TEST_DIR/$seq.mnt"
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.mnt" "$TEST_DIR/$seq.src"
+
+# Can replace mount points in other namespaces, though.
+unshare -m \
+	bash -c "$UMOUNT_PROG $TEST_DIR/$seq.mnt; $XFS_IO_PROG -c \"flink -f $TEST_DIR/$seq.mnt\" $TEST_DIR/$seq.src"
+if $UMOUNT_PROG "$TEST_DIR/$seq.mnt" &> /dev/null; then
+	echo "Mount point was not detached"
+fi
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.mnt" ||
+	echo "Mount point was not replaced"
+
+# Should replace symlinks, not follow them.
+touch "$TEST_DIR/$seq.symtgt"
+ln -s "$TEST_DIR/$seq.symtgt" "$TEST_DIR/$seq.sym"
+$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.sym" "$TEST_DIR/$seq.src"
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.sym" ||
+	echo "Symlink was not replaced"
+same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.symtgt" &&
+	echo "Symlink target was replaced"
+
+rm -rf "$TEST_DIR/$seq."*
+
+status=0
+exit
diff --git a/tests/generic/593.out b/tests/generic/593.out
new file mode 100644
index 00000000..834c34bf
--- /dev/null
+++ b/tests/generic/593.out
@@ -0,0 +1,6 @@
+QA output created by 593
+1
+flink: Is a directory
+flink: Is a directory
+flink: Is a directory
+flink: Device or resource busy
diff --git a/tests/generic/group b/tests/generic/group
index 6fe62505..0a87efca 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -595,3 +595,4 @@
 590 auto prealloc preallocrw
 591 auto quick rw pipe splice
 592 auto quick encrypt
+593 auto quick hardlink
-- 
2.25.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE
  2020-01-29  8:58 ` [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE Omar Sandoval
  2020-01-29  7:02   ` Zorro Lang
@ 2020-02-23 14:46   ` Eryu Guan
  1 sibling, 0 replies; 3+ messages in thread
From: Eryu Guan @ 2020-02-23 14:46 UTC (permalink / raw)
  To: Omar Sandoval
  Cc: linux-fsdevel, Al Viro, kernel-team, linux-api, David Howells,
	Amir Goldstein, Xi Wang, fstests

On Wed, Jan 29, 2020 at 12:58:27AM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
> 
> Cc: fstests@vger.kernel.org
> Signed-off-by: Omar Sandoval <osandov@fb.com>

Looks fine overall, would you please provide more info about this
AT_LINK_REPLACE flag? e.g. what's the expected behavior, what's current
status (merged in kernel or still pending?), reference the related
commits if already merged.

> ---
>  common/rc             |  2 +-
>  tests/generic/593     | 97 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/593.out |  6 +++
>  tests/generic/group   |  1 +
>  4 files changed, 105 insertions(+), 1 deletion(-)
>  create mode 100755 tests/generic/593
>  create mode 100644 tests/generic/593.out
> 
> diff --git a/common/rc b/common/rc
> index eeac1355..257f65a1 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2172,7 +2172,7 @@ _require_xfs_io_command()
>  		;;
>  	"flink")
>  		local testlink=$TEST_DIR/$$.link.xfs_io
> -		testio=`$XFS_IO_PROG -F -f -c "flink $testlink" $testfile 2>&1`
> +		testio=`$XFS_IO_PROG -F -f -c "flink $param $testlink" $testfile 2>&1`
>  		rm -f $testlink > /dev/null 2>&1
>  		;;
>  	"-T")
> diff --git a/tests/generic/593 b/tests/generic/593
> new file mode 100755
> index 00000000..8a9fee02
> --- /dev/null
> +++ b/tests/generic/593
> @@ -0,0 +1,97 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Facebook.  All Rights Reserved.
> +#
> +# FS QA Test 593
> +#
> +# Smoke test linkat() with AT_LINK_REPLACE.
> +#
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +_supported_fs generic
> +_supported_os Linux
> +_require_test
> +_require_xfs_io_command "-T"
> +_require_xfs_io_command "flink" "-f"
> +
> +same_file() {
> +	[[ "$(stat -c '%d %i' "$1")" = "$(stat -c '%d %i' "$2")" ]]
> +}
> +
> +touch "$TEST_DIR/$seq.src"
> +touch "$TEST_DIR/$seq.tgt"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" ||
> +	echo "Target was not replaced"
> +
> +# Linking to the same file should be a noop.
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.src" "$TEST_DIR/$seq.src"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" || echo "Target changed?"
> +
> +# Should work with O_TMPFILE.
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt" -T "$TEST_DIR"
> +stat -c '%h' "$TEST_DIR/$seq.tgt"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt" &&
> +	echo "Target was not replaced"
> +
> +# It's okay if the target doesn't exist.
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.tgt2" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.tgt2" ||
> +	echo "Target was not created"
> +
> +# Can't replace directories.
> +mkdir "$TEST_DIR/$seq.dir"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.dir" "$TEST_DIR/$seq.src"
> +cd "$TEST_DIR/$seq.dir"
> +$XFS_IO_PROG -c "flink -f ." "$TEST_DIR/$seq.src"
> +$XFS_IO_PROG -c "flink -f .." "$TEST_DIR/$seq.src"
> +cd - &> /dev/null
> +
> +# Can't replace local mount points.
> +touch "$TEST_DIR/$seq.mnt"
> +$MOUNT_PROG --bind "$TEST_DIR/$seq.mnt" "$TEST_DIR/$seq.mnt"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.mnt" "$TEST_DIR/$seq.src"
> +
> +# Can replace mount points in other namespaces, though.
> +unshare -m \

Better to define an UNSHARE_PROG in common/config and require it in this
test, then use $UNSHARE_PROG here.

Thanks,
Eryu

> +	bash -c "$UMOUNT_PROG $TEST_DIR/$seq.mnt; $XFS_IO_PROG -c \"flink -f $TEST_DIR/$seq.mnt\" $TEST_DIR/$seq.src"
> +if $UMOUNT_PROG "$TEST_DIR/$seq.mnt" &> /dev/null; then
> +	echo "Mount point was not detached"
> +fi
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.mnt" ||
> +	echo "Mount point was not replaced"
> +
> +# Should replace symlinks, not follow them.
> +touch "$TEST_DIR/$seq.symtgt"
> +ln -s "$TEST_DIR/$seq.symtgt" "$TEST_DIR/$seq.sym"
> +$XFS_IO_PROG -c "flink -f $TEST_DIR/$seq.sym" "$TEST_DIR/$seq.src"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.sym" ||
> +	echo "Symlink was not replaced"
> +same_file "$TEST_DIR/$seq.src" "$TEST_DIR/$seq.symtgt" &&
> +	echo "Symlink target was replaced"
> +
> +rm -rf "$TEST_DIR/$seq."*
> +
> +status=0
> +exit
> diff --git a/tests/generic/593.out b/tests/generic/593.out
> new file mode 100644
> index 00000000..834c34bf
> --- /dev/null
> +++ b/tests/generic/593.out
> @@ -0,0 +1,6 @@
> +QA output created by 593
> +1
> +flink: Is a directory
> +flink: Is a directory
> +flink: Is a directory
> +flink: Device or resource busy
> diff --git a/tests/generic/group b/tests/generic/group
> index 6fe62505..0a87efca 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -595,3 +595,4 @@
>  590 auto prealloc preallocrw
>  591 auto quick rw pipe splice
>  592 auto quick encrypt
> +593 auto quick hardlink
> -- 
> 2.25.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1580251857.git.osandov@fb.com>
2020-01-29  8:58 ` [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE Omar Sandoval
2020-01-29  7:02   ` Zorro Lang
2020-02-23 14:46   ` Eryu Guan

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git