fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET 0/2] fstests: test xfs_db directory navigation
@ 2021-03-23  4:20 Darrick J. Wong
  2021-03-23  4:20 ` [PATCH 1/2] xfs: test the xfs_db path command Darrick J. Wong
  2021-03-23  4:20 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
  0 siblings, 2 replies; 12+ messages in thread
From: Darrick J. Wong @ 2021-03-23  4:20 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

Hi all,

Here are functional tests for a couple of xfs_db tests to improve the
usability of xfs_db by enabling users to navigate to inodes by path and
to list the contents of directories.

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything.  Enjoy!
Comments and questions are, as always, welcome.

--D

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=xfs_db-directory-navigation

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=xfs_db-directory-navigation
---
 tests/xfs/917     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/917.out |   19 +++++++++
 tests/xfs/918     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/918.out |   27 +++++++++++++
 tests/xfs/group   |    2 +
 5 files changed, 255 insertions(+)
 create mode 100755 tests/xfs/917
 create mode 100644 tests/xfs/917.out
 create mode 100755 tests/xfs/918
 create mode 100644 tests/xfs/918.out


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

* [PATCH 1/2] xfs: test the xfs_db path command
  2021-03-23  4:20 [PATCHSET 0/2] fstests: test xfs_db directory navigation Darrick J. Wong
@ 2021-03-23  4:20 ` Darrick J. Wong
  2021-03-25  9:33   ` Chandan Babu R
  2021-03-23  4:20 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
  1 sibling, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2021-03-23  4:20 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

From: Darrick J. Wong <djwong@kernel.org>

Add a new test to make sure the xfs_db path command works the way the
author thinks it should.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/917     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/917.out |   19 ++++++++++
 tests/xfs/group   |    1 +
 3 files changed, 118 insertions(+)
 create mode 100755 tests/xfs/917
 create mode 100644 tests/xfs/917.out


diff --git a/tests/xfs/917 b/tests/xfs/917
new file mode 100755
index 00000000..bf21b290
--- /dev/null
+++ b/tests/xfs/917
@@ -0,0 +1,98 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 917
+#
+# Make sure the xfs_db path command works the way the author thinks it does.
+# This means that it can navigate to random inodes, fails on paths that don't
+# resolve.
+#
+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
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_db_command "path"
+_require_scratch
+
+echo "Format filesystem and populate"
+_scratch_mkfs > $seqres.full
+_scratch_mount >> $seqres.full
+
+mkdir $SCRATCH_MNT/a
+mkdir $SCRATCH_MNT/a/b
+$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
+ln -s -f c $SCRATCH_MNT/a/d
+mknod $SCRATCH_MNT/a/e b 8 0
+ln -s -f b $SCRATCH_MNT/a/f
+
+_scratch_unmount
+
+echo "Check xfs_db path on directories"
+_scratch_xfs_db -c 'path /a' -c print | grep -q 'sfdir.*count.* 5$' || \
+	echo "Did not find directory /a"
+
+_scratch_xfs_db -c 'path /a/b' -c print | grep -q sfdir || \
+	echo "Did not find empty sf directory /a/b"
+
+echo "Check xfs_db path on files"
+_scratch_xfs_db -c 'path /a/c' -c print | grep -q 'core.size.*61' || \
+	echo "Did not find 61-byte file /a/c"
+
+echo "Check xfs_db path on file symlinks"
+_scratch_xfs_db -c 'path /a/d' -c print | grep -q symlink || \
+	echo "Did not find symlink /a/d"
+
+echo "Check xfs_db path on bdevs"
+_scratch_xfs_db -c 'path /a/e' -c print | grep -q 'format.*dev' || \
+	echo "Did not find bdev /a/e"
+
+echo "Check xfs_db path on dir symlinks"
+_scratch_xfs_db -c 'path /a/f' -c print | grep -q symlink || \
+	echo "Did not find symlink /a/f"
+
+echo "Check nonexistent path"
+_scratch_xfs_db -c 'path /does/not/exist'
+
+echo "Check xfs_db path on file path with multiple slashes"
+_scratch_xfs_db -c 'path /a////////c' -c print | grep -q 'core.size.*61' || \
+	echo "Did not find 61-byte file /a////////c"
+
+echo "Check xfs_db path on file path going in and out of /a to get to /a/c"
+_scratch_xfs_db -c 'path /a/.././a/.././a/c' -c print | grep -q 'core.size.*61' || \
+	echo "Did not find 61-byte file /a/.././a/.././a/c"
+
+echo "Check xfs_db path on file path going above the root to get to /a/c"
+_scratch_xfs_db -c 'path /../../../a/c' -c print | grep -q 'core.size.*61' || \
+	echo "Did not find 61-byte file  /../../../a/c"
+
+echo "Check xfs_db path on file path going to then above the root to get to /a/c"
+_scratch_xfs_db -c 'path /a/../../../a/c' -c print | grep -q 'core.size.*61' || \
+	echo "Did not find 61-byte file  /a/../../../a/c"
+
+echo "Check xfs_db path component that isn't a directory"
+_scratch_xfs_db -c 'path /a/c/b' -c print
+
+echo "Check xfs_db path on a dot-dot applied to a non-directory"
+_scratch_xfs_db -c 'path /a/c/../b' -c print
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/917.out b/tests/xfs/917.out
new file mode 100644
index 00000000..7c613c3d
--- /dev/null
+++ b/tests/xfs/917.out
@@ -0,0 +1,19 @@
+QA output created by 917
+Format filesystem and populate
+Check xfs_db path on directories
+Check xfs_db path on files
+Check xfs_db path on file symlinks
+Check xfs_db path on bdevs
+Check xfs_db path on dir symlinks
+Check nonexistent path
+/does/not/exist: No such file or directory
+Check xfs_db path on file path with multiple slashes
+Check xfs_db path on file path going in and out of /a to get to /a/c
+Check xfs_db path on file path going above the root to get to /a/c
+Check xfs_db path on file path going to then above the root to get to /a/c
+Check xfs_db path component that isn't a directory
+/a/c/b: Not a directory
+no current type
+Check xfs_db path on a dot-dot applied to a non-directory
+/a/c/../b: Not a directory
+no current type
diff --git a/tests/xfs/group b/tests/xfs/group
index eebe7dde..daa56787 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -517,3 +517,4 @@
 538 auto stress
 759 auto quick rw realtime
 760 auto quick rw realtime collapse insert unshare zero prealloc
+917 auto quick db


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

* [PATCH 2/2] xfs: test the xfs_db ls command
  2021-03-23  4:20 [PATCHSET 0/2] fstests: test xfs_db directory navigation Darrick J. Wong
  2021-03-23  4:20 ` [PATCH 1/2] xfs: test the xfs_db path command Darrick J. Wong
@ 2021-03-23  4:20 ` Darrick J. Wong
  2021-03-25 10:08   ` Chandan Babu R
  2021-03-25 16:36   ` [PATCH v1.1 " Darrick J. Wong
  1 sibling, 2 replies; 12+ messages in thread
From: Darrick J. Wong @ 2021-03-23  4:20 UTC (permalink / raw)
  To: djwong, guaneryu; +Cc: linux-xfs, fstests, guan

From: Darrick J. Wong <djwong@kernel.org>

Make sure that the xfs_db ls command works the way the author thinks it
does.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/918     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/918.out |   27 +++++++++++++
 tests/xfs/group   |    1 
 3 files changed, 137 insertions(+)
 create mode 100755 tests/xfs/918
 create mode 100644 tests/xfs/918.out


diff --git a/tests/xfs/918 b/tests/xfs/918
new file mode 100755
index 00000000..7211df92
--- /dev/null
+++ b/tests/xfs/918
@@ -0,0 +1,109 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 918
+#
+# Make sure the xfs_db ls command works the way the author thinks it does.
+# This means that we can list the current directory, list an arbitrary path,
+# and we can't list things that aren't directories.
+#
+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
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_db_command "path"
+_require_xfs_db_command "ls"
+_require_scratch
+
+echo "Format filesystem and populate"
+_scratch_mkfs > $seqres.full
+_scratch_mount >> $seqres.full
+
+$XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
+	_notrun "filesystem does not support ftype"
+
+filter_ls() {
+	awk '
+BEGIN { cookie = 0; }
+{
+	if (cookie == 0)
+		cookie = $1;
+	printf("+%d %s %s %s %s %s\n", $1 - cookie, $2, $3, $4, $5, $6);
+	cookie = $1;
+}' | \
+	sed	-e "s/ $root_ino directory / root directory /g" \
+		-e "s/ $a_ino directory / a_ino directory /g" \
+		-e "s/ $b_ino directory / b_ino directory /g" \
+		-e "s/ $c_ino regular / c_ino regular /g" \
+		-e "s/ $d_ino symlink / d_ino symlink /g" \
+		-e "s/ $e_ino blkdev / e_ino blkdev /g" \
+		-e "s/ $f_ino chardev / f_ino chardev /g" \
+		-e "s/ $g_ino fifo / g_ino fifo /g" \
+		-e "s/ $big0_ino regular / big0_ino regular /g" \
+		-e "s/ $big1_ino regular / big1_ino regular /g" \
+		-e "s/ $h_ino regular / g_ino regular /g"
+}
+
+mkdir $SCRATCH_MNT/a
+mkdir $SCRATCH_MNT/a/b
+$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
+ln -s -f b $SCRATCH_MNT/a/d
+mknod $SCRATCH_MNT/a/e b 0 0
+mknod $SCRATCH_MNT/a/f c 0 0
+mknod $SCRATCH_MNT/a/g p
+touch $SCRATCH_MNT/a/averylongnameforadirectorysothatwecanpushthecookieforward
+touch $SCRATCH_MNT/a/andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
+touch $SCRATCH_MNT/a/h
+
+root_ino=$(stat -c '%i' $SCRATCH_MNT)
+a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
+b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
+c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
+d_ino=$(stat -c '%i' $SCRATCH_MNT/a/d)
+e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
+f_ino=$(stat -c '%i' $SCRATCH_MNT/a/f)
+g_ino=$(stat -c '%i' $SCRATCH_MNT/a/g)
+big0_ino=$(stat -c '%i' $SCRATCH_MNT/a/avery*)
+big1_ino=$(stat -c '%i' $SCRATCH_MNT/a/andma*)
+h_ino=$(stat -c '%i' $SCRATCH_MNT/a/h)
+
+_scratch_unmount
+
+echo "Manually navigate to root dir then list"
+_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls > /tmp/fuck0
+cat /tmp/fuck0 | filter_ls > /tmp/fuck1
+_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls
+
+echo "Use path to navigate to root dir then list"
+_scratch_xfs_db -c 'path /' -c ls | filter_ls
+
+echo "Use path to navigate to /a then list"
+_scratch_xfs_db -c 'path /a' -c ls | filter_ls
+
+echo "Use path to navigate to /a/b then list"
+_scratch_xfs_db -c 'path /a/b' -c ls | filter_ls
+
+echo "Use path to navigate to /a/c (non-dir) then list"
+_scratch_xfs_db -c 'path /a/c' -c ls
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/918.out b/tests/xfs/918.out
new file mode 100644
index 00000000..62d43c8a
--- /dev/null
+++ b/tests/xfs/918.out
@@ -0,0 +1,27 @@
+QA output created by 918
+Format filesystem and populate
+Manually navigate to root dir then list
++0 root directory 0x0000002e 1 .
++2 root directory 0x0000172e 2 ..
++2 a_ino directory 0x00000061 1 a
+Use path to navigate to root dir then list
++0 root directory 0x0000002e 1 .
++2 root directory 0x0000172e 2 ..
++2 a_ino directory 0x00000061 1 a
+Use path to navigate to /a then list
++0 a_ino directory 0x0000002e 1 .
++2 root directory 0x0000172e 2 ..
++2 b_ino directory 0x00000062 1 b
++2 c_ino regular 0x00000063 1 c
++2 d_ino symlink 0x00000064 1 d
++2 e_ino blkdev 0x00000065 1 e
++2 f_ino chardev 0x00000066 1 f
++2 g_ino fifo 0x00000067 1 g
++2 big0_ino regular 0xc7457cba 57 averylongnameforadirectorysothatwecanpushthecookieforward
++9 big1_ino regular 0xeefd9237 57 andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
++9 g_ino regular 0x00000068 1 h
+Use path to navigate to /a/b then list
++0 b_ino directory 0x0000002e 1 .
++2 a_ino directory 0x0000172e 2 ..
+Use path to navigate to /a/c (non-dir) then list
+Not a directory
diff --git a/tests/xfs/group b/tests/xfs/group
index daa56787..45628739 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -518,3 +518,4 @@
 759 auto quick rw realtime
 760 auto quick rw realtime collapse insert unshare zero prealloc
 917 auto quick db
+918 auto quick db


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

* Re: [PATCH 1/2] xfs: test the xfs_db path command
  2021-03-23  4:20 ` [PATCH 1/2] xfs: test the xfs_db path command Darrick J. Wong
@ 2021-03-25  9:33   ` Chandan Babu R
  2021-03-25 16:33     ` Darrick J. Wong
  0 siblings, 1 reply; 12+ messages in thread
From: Chandan Babu R @ 2021-03-25  9:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On 23 Mar 2021 at 09:50, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Add a new test to make sure the xfs_db path command works the way the
> author thinks it should.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  tests/xfs/917     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/917.out |   19 ++++++++++
>  tests/xfs/group   |    1 +
>  3 files changed, 118 insertions(+)
>  create mode 100755 tests/xfs/917
>  create mode 100644 tests/xfs/917.out
>
>
> diff --git a/tests/xfs/917 b/tests/xfs/917
> new file mode 100755
> index 00000000..bf21b290
> --- /dev/null
> +++ b/tests/xfs/917
> @@ -0,0 +1,98 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 917
> +#
> +# Make sure the xfs_db path command works the way the author thinks it does.
> +# This means that it can navigate to random inodes, fails on paths that don't
> +# resolve.
> +#
> +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
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_xfs_db_command "path"
> +_require_scratch
> +
> +echo "Format filesystem and populate"
> +_scratch_mkfs > $seqres.full
> +_scratch_mount >> $seqres.full
> +
> +mkdir $SCRATCH_MNT/a
> +mkdir $SCRATCH_MNT/a/b
> +$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
> +ln -s -f c $SCRATCH_MNT/a/d
> +mknod $SCRATCH_MNT/a/e b 8 0
> +ln -s -f b $SCRATCH_MNT/a/f

Later in the test script, there are two checks corresponding to accessibility
of file symlink and dir symlink. However, $SCRATCH_MNT/a/d and
$SCRATCH_MNT/a/f are actually referring to non-existant files since current
working directory at the time of invocation of ln command is the xfstests
directory.

i.e. 'c' and 'b' arguments to 'ln' command above must be qualified with
$SCRATCH_MNT/a/.

> +
> +_scratch_unmount
> +
> +echo "Check xfs_db path on directories"
> +_scratch_xfs_db -c 'path /a' -c print | grep -q 'sfdir.*count.* 5$' || \
> +	echo "Did not find directory /a"
> +
> +_scratch_xfs_db -c 'path /a/b' -c print | grep -q sfdir || \
> +	echo "Did not find empty sf directory /a/b"
> +
> +echo "Check xfs_db path on files"
> +_scratch_xfs_db -c 'path /a/c' -c print | grep -q 'core.size.*61' || \
> +	echo "Did not find 61-byte file /a/c"
> +
> +echo "Check xfs_db path on file symlinks"
> +_scratch_xfs_db -c 'path /a/d' -c print | grep -q symlink || \
> +	echo "Did not find symlink /a/d"
> +
> +echo "Check xfs_db path on bdevs"
> +_scratch_xfs_db -c 'path /a/e' -c print | grep -q 'format.*dev' || \
> +	echo "Did not find bdev /a/e"
> +
> +echo "Check xfs_db path on dir symlinks"
> +_scratch_xfs_db -c 'path /a/f' -c print | grep -q symlink || \
> +	echo "Did not find symlink /a/f"

--
chandan

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

* Re: [PATCH 2/2] xfs: test the xfs_db ls command
  2021-03-23  4:20 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
@ 2021-03-25 10:08   ` Chandan Babu R
  2021-03-25 16:35     ` Darrick J. Wong
  2021-03-25 16:36   ` [PATCH v1.1 " Darrick J. Wong
  1 sibling, 1 reply; 12+ messages in thread
From: Chandan Babu R @ 2021-03-25 10:08 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On 23 Mar 2021 at 09:50, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Make sure that the xfs_db ls command works the way the author thinks it
> does.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  tests/xfs/918     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/918.out |   27 +++++++++++++
>  tests/xfs/group   |    1
>  3 files changed, 137 insertions(+)
>  create mode 100755 tests/xfs/918
>  create mode 100644 tests/xfs/918.out
>
>
> diff --git a/tests/xfs/918 b/tests/xfs/918
> new file mode 100755
> index 00000000..7211df92
> --- /dev/null
> +++ b/tests/xfs/918
> @@ -0,0 +1,109 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test No. 918
> +#
> +# Make sure the xfs_db ls command works the way the author thinks it does.
> +# This means that we can list the current directory, list an arbitrary path,
> +# and we can't list things that aren't directories.
> +#
> +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
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_xfs_db_command "path"
> +_require_xfs_db_command "ls"
> +_require_scratch
> +
> +echo "Format filesystem and populate"
> +_scratch_mkfs > $seqres.full
> +_scratch_mount >> $seqres.full
> +
> +$XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
> +	_notrun "filesystem does not support ftype"
> +
> +filter_ls() {
> +	awk '
> +BEGIN { cookie = 0; }
> +{
> +	if (cookie == 0)
> +		cookie = $1;
> +	printf("+%d %s %s %s %s %s\n", $1 - cookie, $2, $3, $4, $5, $6);
> +	cookie = $1;
> +}' | \
> +	sed	-e "s/ $root_ino directory / root directory /g" \
> +		-e "s/ $a_ino directory / a_ino directory /g" \
> +		-e "s/ $b_ino directory / b_ino directory /g" \
> +		-e "s/ $c_ino regular / c_ino regular /g" \
> +		-e "s/ $d_ino symlink / d_ino symlink /g" \
> +		-e "s/ $e_ino blkdev / e_ino blkdev /g" \
> +		-e "s/ $f_ino chardev / f_ino chardev /g" \
> +		-e "s/ $g_ino fifo / g_ino fifo /g" \
> +		-e "s/ $big0_ino regular / big0_ino regular /g" \
> +		-e "s/ $big1_ino regular / big1_ino regular /g" \
> +		-e "s/ $h_ino regular / g_ino regular /g"
> +}
> +
> +mkdir $SCRATCH_MNT/a
> +mkdir $SCRATCH_MNT/a/b
> +$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
> +ln -s -f b $SCRATCH_MNT/a/d

Similar to the previous patch, the symbolic link 'd' will refer to a
non-existing file. However, it shouldn't matter w.r.t to correctness of this
test.

> +mknod $SCRATCH_MNT/a/e b 0 0
> +mknod $SCRATCH_MNT/a/f c 0 0
> +mknod $SCRATCH_MNT/a/g p
> +touch $SCRATCH_MNT/a/averylongnameforadirectorysothatwecanpushthecookieforward
> +touch $SCRATCH_MNT/a/andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
> +touch $SCRATCH_MNT/a/h
> +
> +root_ino=$(stat -c '%i' $SCRATCH_MNT)
> +a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
> +b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
> +c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
> +d_ino=$(stat -c '%i' $SCRATCH_MNT/a/d)
> +e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
> +f_ino=$(stat -c '%i' $SCRATCH_MNT/a/f)
> +g_ino=$(stat -c '%i' $SCRATCH_MNT/a/g)
> +big0_ino=$(stat -c '%i' $SCRATCH_MNT/a/avery*)
> +big1_ino=$(stat -c '%i' $SCRATCH_MNT/a/andma*)
> +h_ino=$(stat -c '%i' $SCRATCH_MNT/a/h)
> +
> +_scratch_unmount
> +
> +echo "Manually navigate to root dir then list"
> +_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls > /tmp/fuck0
> +cat /tmp/fuck0 | filter_ls > /tmp/fuck1

The two lines above are redundant.

> +_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls

--
chandan

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

* Re: [PATCH 1/2] xfs: test the xfs_db path command
  2021-03-25  9:33   ` Chandan Babu R
@ 2021-03-25 16:33     ` Darrick J. Wong
  2021-03-26  3:31       ` Chandan Babu R
  0 siblings, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2021-03-25 16:33 UTC (permalink / raw)
  To: Chandan Babu R; +Cc: guaneryu, linux-xfs, fstests, guan

On Thu, Mar 25, 2021 at 03:03:14PM +0530, Chandan Babu R wrote:
> On 23 Mar 2021 at 09:50, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Add a new test to make sure the xfs_db path command works the way the
> > author thinks it should.
> >
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  tests/xfs/917     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/917.out |   19 ++++++++++
> >  tests/xfs/group   |    1 +
> >  3 files changed, 118 insertions(+)
> >  create mode 100755 tests/xfs/917
> >  create mode 100644 tests/xfs/917.out
> >
> >
> > diff --git a/tests/xfs/917 b/tests/xfs/917
> > new file mode 100755
> > index 00000000..bf21b290
> > --- /dev/null
> > +++ b/tests/xfs/917
> > @@ -0,0 +1,98 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 917
> > +#
> > +# Make sure the xfs_db path command works the way the author thinks it does.
> > +# This means that it can navigate to random inodes, fails on paths that don't
> > +# resolve.
> > +#
> > +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
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_xfs_db_command "path"
> > +_require_scratch
> > +
> > +echo "Format filesystem and populate"
> > +_scratch_mkfs > $seqres.full
> > +_scratch_mount >> $seqres.full
> > +
> > +mkdir $SCRATCH_MNT/a
> > +mkdir $SCRATCH_MNT/a/b
> > +$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
> > +ln -s -f c $SCRATCH_MNT/a/d
> > +mknod $SCRATCH_MNT/a/e b 8 0
> > +ln -s -f b $SCRATCH_MNT/a/f
> 
> Later in the test script, there are two checks corresponding to accessibility
> of file symlink and dir symlink. However, $SCRATCH_MNT/a/d and
> $SCRATCH_MNT/a/f are actually referring to non-existant files since current
> working directory at the time of invocation of ln command is the xfstests
> directory.
> 
> i.e. 'c' and 'b' arguments to 'ln' command above must be qualified with
> $SCRATCH_MNT/a/.

Hm?  d and f look fine to me:

$ ./check xfs/917
$ mount /dev/sdf /opt
$ cd /opt/a
$ ls
total 4
drwxr-xr-x 2 root root    6 Mar 25 09:25 b/
-rw------- 1 root root   61 Mar 25 09:25 c
lrwxrwxrwx 1 root root    1 Mar 25 09:25 d -> c
brw-r--r-- 1 root root 8, 0 Mar 25 09:25 e
lrwxrwxrwx 1 root root    1 Mar 25 09:25 f -> b/

The link target is copied verbatim into the symlink, so I don't see why
they need to be qualified?

(FWIW the path command doesn't resolve symlinks, so it really only
checks that /a/d and /a/f exist and are of type symlink.)

--D

> 
> > +
> > +_scratch_unmount
> > +
> > +echo "Check xfs_db path on directories"
> > +_scratch_xfs_db -c 'path /a' -c print | grep -q 'sfdir.*count.* 5$' || \
> > +	echo "Did not find directory /a"
> > +
> > +_scratch_xfs_db -c 'path /a/b' -c print | grep -q sfdir || \
> > +	echo "Did not find empty sf directory /a/b"
> > +
> > +echo "Check xfs_db path on files"
> > +_scratch_xfs_db -c 'path /a/c' -c print | grep -q 'core.size.*61' || \
> > +	echo "Did not find 61-byte file /a/c"
> > +
> > +echo "Check xfs_db path on file symlinks"
> > +_scratch_xfs_db -c 'path /a/d' -c print | grep -q symlink || \
> > +	echo "Did not find symlink /a/d"
> > +
> > +echo "Check xfs_db path on bdevs"
> > +_scratch_xfs_db -c 'path /a/e' -c print | grep -q 'format.*dev' || \
> > +	echo "Did not find bdev /a/e"
> > +
> > +echo "Check xfs_db path on dir symlinks"
> > +_scratch_xfs_db -c 'path /a/f' -c print | grep -q symlink || \
> > +	echo "Did not find symlink /a/f"
> 
> --
> chandan

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

* Re: [PATCH 2/2] xfs: test the xfs_db ls command
  2021-03-25 10:08   ` Chandan Babu R
@ 2021-03-25 16:35     ` Darrick J. Wong
  0 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2021-03-25 16:35 UTC (permalink / raw)
  To: Chandan Babu R; +Cc: guaneryu, linux-xfs, fstests, guan

On Thu, Mar 25, 2021 at 03:38:56PM +0530, Chandan Babu R wrote:
> On 23 Mar 2021 at 09:50, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Make sure that the xfs_db ls command works the way the author thinks it
> > does.
> >
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  tests/xfs/918     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/918.out |   27 +++++++++++++
> >  tests/xfs/group   |    1
> >  3 files changed, 137 insertions(+)
> >  create mode 100755 tests/xfs/918
> >  create mode 100644 tests/xfs/918.out
> >
> >
> > diff --git a/tests/xfs/918 b/tests/xfs/918
> > new file mode 100755
> > index 00000000..7211df92
> > --- /dev/null
> > +++ b/tests/xfs/918
> > @@ -0,0 +1,109 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 918
> > +#
> > +# Make sure the xfs_db ls command works the way the author thinks it does.
> > +# This means that we can list the current directory, list an arbitrary path,
> > +# and we can't list things that aren't directories.
> > +#
> > +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
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_xfs_db_command "path"
> > +_require_xfs_db_command "ls"
> > +_require_scratch
> > +
> > +echo "Format filesystem and populate"
> > +_scratch_mkfs > $seqres.full
> > +_scratch_mount >> $seqres.full
> > +
> > +$XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
> > +	_notrun "filesystem does not support ftype"
> > +
> > +filter_ls() {
> > +	awk '
> > +BEGIN { cookie = 0; }
> > +{
> > +	if (cookie == 0)
> > +		cookie = $1;
> > +	printf("+%d %s %s %s %s %s\n", $1 - cookie, $2, $3, $4, $5, $6);
> > +	cookie = $1;
> > +}' | \
> > +	sed	-e "s/ $root_ino directory / root directory /g" \
> > +		-e "s/ $a_ino directory / a_ino directory /g" \
> > +		-e "s/ $b_ino directory / b_ino directory /g" \
> > +		-e "s/ $c_ino regular / c_ino regular /g" \
> > +		-e "s/ $d_ino symlink / d_ino symlink /g" \
> > +		-e "s/ $e_ino blkdev / e_ino blkdev /g" \
> > +		-e "s/ $f_ino chardev / f_ino chardev /g" \
> > +		-e "s/ $g_ino fifo / g_ino fifo /g" \
> > +		-e "s/ $big0_ino regular / big0_ino regular /g" \
> > +		-e "s/ $big1_ino regular / big1_ino regular /g" \
> > +		-e "s/ $h_ino regular / g_ino regular /g"
> > +}
> > +
> > +mkdir $SCRATCH_MNT/a
> > +mkdir $SCRATCH_MNT/a/b
> > +$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
> > +ln -s -f b $SCRATCH_MNT/a/d
> 
> Similar to the previous patch, the symbolic link 'd' will refer to a
> non-existing file. However, it shouldn't matter w.r.t to correctness of this
> test.

Right.

> > +mknod $SCRATCH_MNT/a/e b 0 0
> > +mknod $SCRATCH_MNT/a/f c 0 0
> > +mknod $SCRATCH_MNT/a/g p
> > +touch $SCRATCH_MNT/a/averylongnameforadirectorysothatwecanpushthecookieforward
> > +touch $SCRATCH_MNT/a/andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
> > +touch $SCRATCH_MNT/a/h
> > +
> > +root_ino=$(stat -c '%i' $SCRATCH_MNT)
> > +a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
> > +b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
> > +c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
> > +d_ino=$(stat -c '%i' $SCRATCH_MNT/a/d)
> > +e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
> > +f_ino=$(stat -c '%i' $SCRATCH_MNT/a/f)
> > +g_ino=$(stat -c '%i' $SCRATCH_MNT/a/g)
> > +big0_ino=$(stat -c '%i' $SCRATCH_MNT/a/avery*)
> > +big1_ino=$(stat -c '%i' $SCRATCH_MNT/a/andma*)
> > +h_ino=$(stat -c '%i' $SCRATCH_MNT/a/h)
> > +
> > +_scratch_unmount
> > +
> > +echo "Manually navigate to root dir then list"
> > +_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls > /tmp/fuck0
> > +cat /tmp/fuck0 | filter_ls > /tmp/fuck1
> 
> The two lines above are redundant.

Yikes, sorry about that, everyone.

--D

> > +_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls
> 
> --
> chandan

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

* [PATCH v1.1 2/2] xfs: test the xfs_db ls command
  2021-03-23  4:20 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
  2021-03-25 10:08   ` Chandan Babu R
@ 2021-03-25 16:36   ` Darrick J. Wong
  2021-03-26  3:32     ` Chandan Babu R
  1 sibling, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2021-03-25 16:36 UTC (permalink / raw)
  To: guaneryu; +Cc: linux-xfs, fstests, guan, chandanrlinux

From: Darrick J. Wong <djwong@kernel.org>

Make sure that the xfs_db ls command works the way the author thinks it
does.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
v1.1: fix word usage
---
 tests/xfs/918     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/918.out |   27 +++++++++++++
 tests/xfs/group   |    1 
 3 files changed, 135 insertions(+)
 create mode 100755 tests/xfs/918
 create mode 100644 tests/xfs/918.out

diff --git a/tests/xfs/918 b/tests/xfs/918
new file mode 100755
index 00000000..68b6bdd1
--- /dev/null
+++ b/tests/xfs/918
@@ -0,0 +1,107 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 918
+#
+# Make sure the xfs_db ls command works the way the author thinks it does.
+# This means that we can list the current directory, list an arbitrary path,
+# and we can't list things that aren't directories.
+#
+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
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_db_command "path"
+_require_xfs_db_command "ls"
+_require_scratch
+
+echo "Format filesystem and populate"
+_scratch_mkfs > $seqres.full
+_scratch_mount >> $seqres.full
+
+$XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
+	_notrun "filesystem does not support ftype"
+
+filter_ls() {
+	awk '
+BEGIN { cookie = 0; }
+{
+	if (cookie == 0)
+		cookie = $1;
+	printf("+%d %s %s %s %s %s\n", $1 - cookie, $2, $3, $4, $5, $6);
+	cookie = $1;
+}' | \
+	sed	-e "s/ $root_ino directory / root directory /g" \
+		-e "s/ $a_ino directory / a_ino directory /g" \
+		-e "s/ $b_ino directory / b_ino directory /g" \
+		-e "s/ $c_ino regular / c_ino regular /g" \
+		-e "s/ $d_ino symlink / d_ino symlink /g" \
+		-e "s/ $e_ino blkdev / e_ino blkdev /g" \
+		-e "s/ $f_ino chardev / f_ino chardev /g" \
+		-e "s/ $g_ino fifo / g_ino fifo /g" \
+		-e "s/ $big0_ino regular / big0_ino regular /g" \
+		-e "s/ $big1_ino regular / big1_ino regular /g" \
+		-e "s/ $h_ino regular / g_ino regular /g"
+}
+
+mkdir $SCRATCH_MNT/a
+mkdir $SCRATCH_MNT/a/b
+$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
+ln -s -f b $SCRATCH_MNT/a/d
+mknod $SCRATCH_MNT/a/e b 0 0
+mknod $SCRATCH_MNT/a/f c 0 0
+mknod $SCRATCH_MNT/a/g p
+touch $SCRATCH_MNT/a/averylongnameforadirectorysothatwecanpushthecookieforward
+touch $SCRATCH_MNT/a/andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
+touch $SCRATCH_MNT/a/h
+
+root_ino=$(stat -c '%i' $SCRATCH_MNT)
+a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
+b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
+c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
+d_ino=$(stat -c '%i' $SCRATCH_MNT/a/d)
+e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
+f_ino=$(stat -c '%i' $SCRATCH_MNT/a/f)
+g_ino=$(stat -c '%i' $SCRATCH_MNT/a/g)
+big0_ino=$(stat -c '%i' $SCRATCH_MNT/a/avery*)
+big1_ino=$(stat -c '%i' $SCRATCH_MNT/a/andma*)
+h_ino=$(stat -c '%i' $SCRATCH_MNT/a/h)
+
+_scratch_unmount
+
+echo "Manually navigate to root dir then list"
+_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls
+
+echo "Use path to navigate to root dir then list"
+_scratch_xfs_db -c 'path /' -c ls | filter_ls
+
+echo "Use path to navigate to /a then list"
+_scratch_xfs_db -c 'path /a' -c ls | filter_ls
+
+echo "Use path to navigate to /a/b then list"
+_scratch_xfs_db -c 'path /a/b' -c ls | filter_ls
+
+echo "Use path to navigate to /a/c (non-dir) then list"
+_scratch_xfs_db -c 'path /a/c' -c ls
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/918.out b/tests/xfs/918.out
new file mode 100644
index 00000000..62d43c8a
--- /dev/null
+++ b/tests/xfs/918.out
@@ -0,0 +1,27 @@
+QA output created by 918
+Format filesystem and populate
+Manually navigate to root dir then list
++0 root directory 0x0000002e 1 .
++2 root directory 0x0000172e 2 ..
++2 a_ino directory 0x00000061 1 a
+Use path to navigate to root dir then list
++0 root directory 0x0000002e 1 .
++2 root directory 0x0000172e 2 ..
++2 a_ino directory 0x00000061 1 a
+Use path to navigate to /a then list
++0 a_ino directory 0x0000002e 1 .
++2 root directory 0x0000172e 2 ..
++2 b_ino directory 0x00000062 1 b
++2 c_ino regular 0x00000063 1 c
++2 d_ino symlink 0x00000064 1 d
++2 e_ino blkdev 0x00000065 1 e
++2 f_ino chardev 0x00000066 1 f
++2 g_ino fifo 0x00000067 1 g
++2 big0_ino regular 0xc7457cba 57 averylongnameforadirectorysothatwecanpushthecookieforward
++9 big1_ino regular 0xeefd9237 57 andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
++9 g_ino regular 0x00000068 1 h
+Use path to navigate to /a/b then list
++0 b_ino directory 0x0000002e 1 .
++2 a_ino directory 0x0000172e 2 ..
+Use path to navigate to /a/c (non-dir) then list
+Not a directory
diff --git a/tests/xfs/group b/tests/xfs/group
index daa56787..45628739 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -518,3 +518,4 @@
 759 auto quick rw realtime
 760 auto quick rw realtime collapse insert unshare zero prealloc
 917 auto quick db
+918 auto quick db

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

* Re: [PATCH 1/2] xfs: test the xfs_db path command
  2021-03-25 16:33     ` Darrick J. Wong
@ 2021-03-26  3:31       ` Chandan Babu R
  0 siblings, 0 replies; 12+ messages in thread
From: Chandan Babu R @ 2021-03-26  3:31 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On 25 Mar 2021 at 22:03, Darrick J. Wong wrote:
> On Thu, Mar 25, 2021 at 03:03:14PM +0530, Chandan Babu R wrote:
>> On 23 Mar 2021 at 09:50, Darrick J. Wong wrote:
>> > From: Darrick J. Wong <djwong@kernel.org>
>> >
>> > Add a new test to make sure the xfs_db path command works the way the
>> > author thinks it should.
>> >
>> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
>> > ---
>> >  tests/xfs/917     |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> >  tests/xfs/917.out |   19 ++++++++++
>> >  tests/xfs/group   |    1 +
>> >  3 files changed, 118 insertions(+)
>> >  create mode 100755 tests/xfs/917
>> >  create mode 100644 tests/xfs/917.out
>> >
>> >
>> > diff --git a/tests/xfs/917 b/tests/xfs/917
>> > new file mode 100755
>> > index 00000000..bf21b290
>> > --- /dev/null
>> > +++ b/tests/xfs/917
>> > @@ -0,0 +1,98 @@
>> > +#! /bin/bash
>> > +# SPDX-License-Identifier: GPL-2.0-or-later
>> > +# Copyright (c) 2021 Oracle.  All Rights Reserved.
>> > +#
>> > +# FS QA Test No. 917
>> > +#
>> > +# Make sure the xfs_db path command works the way the author thinks it does.
>> > +# This means that it can navigate to random inodes, fails on paths that don't
>> > +# resolve.
>> > +#
>> > +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
>> > +
>> > +# real QA test starts here
>> > +_supported_fs xfs
>> > +_require_xfs_db_command "path"
>> > +_require_scratch
>> > +
>> > +echo "Format filesystem and populate"
>> > +_scratch_mkfs > $seqres.full
>> > +_scratch_mount >> $seqres.full
>> > +
>> > +mkdir $SCRATCH_MNT/a
>> > +mkdir $SCRATCH_MNT/a/b
>> > +$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
>> > +ln -s -f c $SCRATCH_MNT/a/d
>> > +mknod $SCRATCH_MNT/a/e b 8 0
>> > +ln -s -f b $SCRATCH_MNT/a/f
>> 
>> Later in the test script, there are two checks corresponding to accessibility
>> of file symlink and dir symlink. However, $SCRATCH_MNT/a/d and
>> $SCRATCH_MNT/a/f are actually referring to non-existant files since current
>> working directory at the time of invocation of ln command is the xfstests
>> directory.
>> 
>> i.e. 'c' and 'b' arguments to 'ln' command above must be qualified with
>> $SCRATCH_MNT/a/.
>
> Hm?  d and f look fine to me:
>
> $ ./check xfs/917
> $ mount /dev/sdf /opt
> $ cd /opt/a
> $ ls
> total 4
> drwxr-xr-x 2 root root    6 Mar 25 09:25 b/
> -rw------- 1 root root   61 Mar 25 09:25 c
> lrwxrwxrwx 1 root root    1 Mar 25 09:25 d -> c
> brw-r--r-- 1 root root 8, 0 Mar 25 09:25 e
> lrwxrwxrwx 1 root root    1 Mar 25 09:25 f -> b/
>
> The link target is copied verbatim into the symlink, so I don't see why
> they need to be qualified?
>
> (FWIW the path command doesn't resolve symlinks, so it really only
> checks that /a/d and /a/f exist and are of type symlink.)

Sorry, I got confused. The patch looks good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

-- 
chandan

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

* Re: [PATCH v1.1 2/2] xfs: test the xfs_db ls command
  2021-03-25 16:36   ` [PATCH v1.1 " Darrick J. Wong
@ 2021-03-26  3:32     ` Chandan Babu R
  0 siblings, 0 replies; 12+ messages in thread
From: Chandan Babu R @ 2021-03-26  3:32 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: guaneryu, linux-xfs, fstests, guan

On 25 Mar 2021 at 22:06, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Make sure that the xfs_db ls command works the way the author thinks it
> does.
>

Looks good.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

-- 
chandan

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

* Re: [PATCH 2/2] xfs: test the xfs_db ls command
  2020-10-27 19:03 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
@ 2020-10-29 20:24   ` Darrick J. Wong
  0 siblings, 0 replies; 12+ messages in thread
From: Darrick J. Wong @ 2020-10-29 20:24 UTC (permalink / raw)
  To: guaneryu; +Cc: linux-xfs, fstests

On Tue, Oct 27, 2020 at 12:03:32PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure that the xfs_db ls command works the way the author thinks it
> does.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

FWIW, this test will have to change to accomodate some of the review
suggestions, so anyone looking at this series might as well wait until
v2.

--D

> ---
>  tests/xfs/918     |   87 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/918.out |   23 ++++++++++++++
>  tests/xfs/group   |    1 +
>  3 files changed, 111 insertions(+)
>  create mode 100755 tests/xfs/918
>  create mode 100644 tests/xfs/918.out
> 
> 
> diff --git a/tests/xfs/918 b/tests/xfs/918
> new file mode 100755
> index 00000000..759943ac
> --- /dev/null
> +++ b/tests/xfs/918
> @@ -0,0 +1,87 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# FS QA Test No. 918
> +#
> +# Make sure the xfs_db ls command works the way the author thinks it does.
> +# This means that we can list the current directory, list an arbitrary path,
> +# and we can't list things that aren't directories.
> +#
> +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
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_xfs_db_command "path"
> +_require_xfs_db_command "ls"
> +_require_scratch
> +
> +echo "Format filesystem and populate"
> +_scratch_mkfs > $seqres.full
> +_scratch_mount >> $seqres.full
> +
> +$XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
> +	_notrun "filesystem does not support ftype"
> +
> +filter_ls() {
> +	sed	-e "s/^$root_ino /rootd/g" \
> +		-e "s/^$a_ino /a_ino/g" \
> +		-e "s/^$b_ino /b_ino/g" \
> +		-e "s/^$c_ino /c_ino/g" \
> +		-e "s/^$d_ino /d_ino/g" \
> +		-e "s/^$e_ino /e_ino/g" |
> +	awk '{printf("%s %s %s %s %s\n", $1, $2, $3, $4, $5);}'
> +}
> +
> +mkdir $SCRATCH_MNT/a
> +mkdir $SCRATCH_MNT/a/b
> +$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
> +ln $SCRATCH_MNT/a/c $SCRATCH_MNT/d
> +ln -s -f b $SCRATCH_MNT/a/e
> +
> +root_ino=$(stat -c '%i' $SCRATCH_MNT)
> +a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
> +b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
> +c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
> +d_ino=$(stat -c '%i' $SCRATCH_MNT/d)
> +e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
> +
> +_scratch_unmount
> +
> +echo "Manually navigate to root dir then list"
> +_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls
> +
> +echo "Use path to navigate to root dir then list"
> +_scratch_xfs_db -c 'path /' -c ls | filter_ls
> +
> +echo "Use path to navigate to /a then list"
> +_scratch_xfs_db -c 'path /a' -c ls | filter_ls
> +
> +echo "Use path to navigate to /a/b then list"
> +_scratch_xfs_db -c 'path /a/b' -c ls | filter_ls
> +
> +echo "Use path to navigate to /a/c then list"
> +_scratch_xfs_db -c 'path /a/c' -c ls | \
> +	sed -e "s/^$c_ino /c_ino /g" -e "s/<$c_ino>/<c_ino>/g" |
> +	awk '{printf("%s %s %s\n", $1, $2, $5);}'
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/918.out b/tests/xfs/918.out
> new file mode 100644
> index 00000000..2e0ad939
> --- /dev/null
> +++ b/tests/xfs/918.out
> @@ -0,0 +1,23 @@
> +QA output created by 918
> +Format filesystem and populate
> +Manually navigate to root dir then list
> +rootd directory 0x0000002e 1 .
> +rootd directory 0x0000172e 2 ..
> +a_ino directory 0x00000061 1 a
> +c_ino regular 0x00000064 1 d
> +Use path to navigate to root dir then list
> +rootd directory 0x0000002e 1 .
> +rootd directory 0x0000172e 2 ..
> +a_ino directory 0x00000061 1 a
> +c_ino regular 0x00000064 1 d
> +Use path to navigate to /a then list
> +a_ino directory 0x0000002e 1 .
> +rootd directory 0x0000172e 2 ..
> +b_ino directory 0x00000062 1 b
> +c_ino regular 0x00000063 1 c
> +e_ino symlink 0x00000065 1 e
> +Use path to navigate to /a/b then list
> +b_ino directory 0x0000002e 1 .
> +a_ino directory 0x0000172e 2 ..
> +Use path to navigate to /a/c then list
> +c_ino regular <c_ino>
> diff --git a/tests/xfs/group b/tests/xfs/group
> index 82e02196..4b0caea4 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -526,3 +526,4 @@
>  763 auto quick rw realtime
>  915 auto quick quota
>  917 auto quick db
> +918 auto quick db
> 

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

* [PATCH 2/2] xfs: test the xfs_db ls command
  2020-10-27 19:03 [PATCH RFC 0/2] xfs_db: add minimal directory navigation Darrick J. Wong
@ 2020-10-27 19:03 ` Darrick J. Wong
  2020-10-29 20:24   ` Darrick J. Wong
  0 siblings, 1 reply; 12+ messages in thread
From: Darrick J. Wong @ 2020-10-27 19:03 UTC (permalink / raw)
  To: darrick.wong, guaneryu; +Cc: linux-xfs, fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

Make sure that the xfs_db ls command works the way the author thinks it
does.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/918     |   87 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/918.out |   23 ++++++++++++++
 tests/xfs/group   |    1 +
 3 files changed, 111 insertions(+)
 create mode 100755 tests/xfs/918
 create mode 100644 tests/xfs/918.out


diff --git a/tests/xfs/918 b/tests/xfs/918
new file mode 100755
index 00000000..759943ac
--- /dev/null
+++ b/tests/xfs/918
@@ -0,0 +1,87 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 918
+#
+# Make sure the xfs_db ls command works the way the author thinks it does.
+# This means that we can list the current directory, list an arbitrary path,
+# and we can't list things that aren't directories.
+#
+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
+
+# real QA test starts here
+_supported_fs xfs
+_require_xfs_db_command "path"
+_require_xfs_db_command "ls"
+_require_scratch
+
+echo "Format filesystem and populate"
+_scratch_mkfs > $seqres.full
+_scratch_mount >> $seqres.full
+
+$XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
+	_notrun "filesystem does not support ftype"
+
+filter_ls() {
+	sed	-e "s/^$root_ino /rootd/g" \
+		-e "s/^$a_ino /a_ino/g" \
+		-e "s/^$b_ino /b_ino/g" \
+		-e "s/^$c_ino /c_ino/g" \
+		-e "s/^$d_ino /d_ino/g" \
+		-e "s/^$e_ino /e_ino/g" |
+	awk '{printf("%s %s %s %s %s\n", $1, $2, $3, $4, $5);}'
+}
+
+mkdir $SCRATCH_MNT/a
+mkdir $SCRATCH_MNT/a/b
+$XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
+ln $SCRATCH_MNT/a/c $SCRATCH_MNT/d
+ln -s -f b $SCRATCH_MNT/a/e
+
+root_ino=$(stat -c '%i' $SCRATCH_MNT)
+a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
+b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
+c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
+d_ino=$(stat -c '%i' $SCRATCH_MNT/d)
+e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
+
+_scratch_unmount
+
+echo "Manually navigate to root dir then list"
+_scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls
+
+echo "Use path to navigate to root dir then list"
+_scratch_xfs_db -c 'path /' -c ls | filter_ls
+
+echo "Use path to navigate to /a then list"
+_scratch_xfs_db -c 'path /a' -c ls | filter_ls
+
+echo "Use path to navigate to /a/b then list"
+_scratch_xfs_db -c 'path /a/b' -c ls | filter_ls
+
+echo "Use path to navigate to /a/c then list"
+_scratch_xfs_db -c 'path /a/c' -c ls | \
+	sed -e "s/^$c_ino /c_ino /g" -e "s/<$c_ino>/<c_ino>/g" |
+	awk '{printf("%s %s %s\n", $1, $2, $5);}'
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/918.out b/tests/xfs/918.out
new file mode 100644
index 00000000..2e0ad939
--- /dev/null
+++ b/tests/xfs/918.out
@@ -0,0 +1,23 @@
+QA output created by 918
+Format filesystem and populate
+Manually navigate to root dir then list
+rootd directory 0x0000002e 1 .
+rootd directory 0x0000172e 2 ..
+a_ino directory 0x00000061 1 a
+c_ino regular 0x00000064 1 d
+Use path to navigate to root dir then list
+rootd directory 0x0000002e 1 .
+rootd directory 0x0000172e 2 ..
+a_ino directory 0x00000061 1 a
+c_ino regular 0x00000064 1 d
+Use path to navigate to /a then list
+a_ino directory 0x0000002e 1 .
+rootd directory 0x0000172e 2 ..
+b_ino directory 0x00000062 1 b
+c_ino regular 0x00000063 1 c
+e_ino symlink 0x00000065 1 e
+Use path to navigate to /a/b then list
+b_ino directory 0x0000002e 1 .
+a_ino directory 0x0000172e 2 ..
+Use path to navigate to /a/c then list
+c_ino regular <c_ino>
diff --git a/tests/xfs/group b/tests/xfs/group
index 82e02196..4b0caea4 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -526,3 +526,4 @@
 763 auto quick rw realtime
 915 auto quick quota
 917 auto quick db
+918 auto quick db


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

end of thread, other threads:[~2021-03-26  3:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  4:20 [PATCHSET 0/2] fstests: test xfs_db directory navigation Darrick J. Wong
2021-03-23  4:20 ` [PATCH 1/2] xfs: test the xfs_db path command Darrick J. Wong
2021-03-25  9:33   ` Chandan Babu R
2021-03-25 16:33     ` Darrick J. Wong
2021-03-26  3:31       ` Chandan Babu R
2021-03-23  4:20 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
2021-03-25 10:08   ` Chandan Babu R
2021-03-25 16:35     ` Darrick J. Wong
2021-03-25 16:36   ` [PATCH v1.1 " Darrick J. Wong
2021-03-26  3:32     ` Chandan Babu R
  -- strict thread matches above, loose matches on Subject: below --
2020-10-27 19:03 [PATCH RFC 0/2] xfs_db: add minimal directory navigation Darrick J. Wong
2020-10-27 19:03 ` [PATCH 2/2] xfs: test the xfs_db ls command Darrick J. Wong
2020-10-29 20:24   ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).