Re: [PATCH 2/2] xfs: test the xfs_db ls command

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



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

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
> 



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux