public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: test xfs_db fuzz command verbs
@ 2017-08-19 15:46 Darrick J. Wong
  2017-08-22  7:06 ` Eryu Guan
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2017-08-19 15:46 UTC (permalink / raw)
  To: Eryu Guan; +Cc: xfs, fstests

Ensure that the fuzz command does what it says.

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

diff --git a/tests/xfs/1386 b/tests/xfs/1386
new file mode 100755
index 0000000..1c8eb83
--- /dev/null
+++ b/tests/xfs/1386
@@ -0,0 +1,74 @@
+#! /bin/bash
+# FS QA Test No. 1386
+#
+# Ensure that xfs_db fuzz command works as advertised.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017, Oracle and/or its affiliates.  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=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/fuzzy
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_nocheck
+_require_command "$XFS_DB_PROG" "xfs_db"
+_require_xfs_db_command "fuzz"
+
+rm -f "$seqres.full"
+
+echo "Format"
+_scratch_mkfs > "$seqres.full" 2>&1
+
+# Make sure that each fuzz verb works.  For the firstbit/middlebit/lastbit
+# tests, we depend on 'ones' having set the field to all ones.
+field="fdblocks"
+_scratch_xfs_db -x -c 'sb 0' -c "write -d ${field} 0"
+SCRATCH_XFS_LIST_FUZZ_VERBS= _scratch_xfs_list_fuzz_verbs | while read verb; do
+	test "${verb}" = "random" && continue
+	echo "Test verb ${verb}"
+	_scratch_xfs_db -x -c 'sb 0' -c "fuzz -d ${field} ${verb}"
+done
+
+echo "Test verb random"
+before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
+_scratch_xfs_db -x -c 'sb 0' -c "fuzz -d ${field} random" >> $seqres.full
+after="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
+test "${before}" != "${after}" && echo "${field} changed"
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/1386.out b/tests/xfs/1386.out
new file mode 100644
index 0000000..f30da83
--- /dev/null
+++ b/tests/xfs/1386.out
@@ -0,0 +1,28 @@
+QA output created by 1386
+Format
+Allowing write of corrupted data with good CRC
+fdblocks = 0
+Test verb zeroes
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 0
+Test verb ones
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 18446744073709551615
+Test verb firstbit
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 9223372036854775807
+Test verb middlebit
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 9223372034707292159
+Test verb lastbit
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 9223372034707292158
+Test verb add
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 9223372034707294175
+Test verb sub
+Allowing fuzz of corrupted data with good CRC
+fdblocks = 9223372034707292158
+Test verb random
+fdblocks changed
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 1bb40f9..0468e4b 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -428,3 +428,4 @@
 1383 dangerous_fuzzers dangerous_scrub dangerous_online_repair
 1384 dangerous_fuzzers dangerous_scrub dangerous_repair
 1385 dangerous_fuzzers dangerous_scrub dangerous_online_repair
+1386 auto quick fuzzers

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

* Re: [PATCH] xfs: test xfs_db fuzz command verbs
  2017-08-19 15:46 [PATCH] xfs: test xfs_db fuzz command verbs Darrick J. Wong
@ 2017-08-22  7:06 ` Eryu Guan
  2017-08-22 16:24   ` Darrick J. Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Eryu Guan @ 2017-08-22  7:06 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs, fstests

Hi Darrick,

On Sat, Aug 19, 2017 at 08:46:45AM -0700, Darrick J. Wong wrote:
> Ensure that the fuzz command does what it says.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

I applied your patch "[PATCH] xfs_db: bit fuzzing should read the right
bit when flipping" on top of xfsprogs for-next branch (which contains
commit ef209a960d82 "xfs_db: make write/fuzz -c and -d work on non-crc
filesystems") and tested this patch. All worked fine on CRC enabled XFS,
but test failed with non-CRC xfs as it missed lines like:

Allowing fuzz of corrupted data with good CRC

I did the following modifications and test passed with both CRC and
non-CRC XFS, if you think it's OK then I can fold the changes to your
patch and no need for a resend :)

Thanks,
Eryu

diff --git a/tests/xfs/058 b/tests/xfs/058
index 4a39942..32ceb0d 100755
--- a/tests/xfs/058
+++ b/tests/xfs/058
@@ -50,21 +50,31 @@ _require_xfs_db_command "fuzz"
 rm -f "$seqres.full"
 
 echo "Format"
-_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >> "$seqres.full"
+source $tmp.mkfs
+
+do_xfs_db()
+{
+       local cmd=$1
+       if [ $_fs_has_crcs -eq 0 ]; then
+               echo "Allowing $cmd of corrupted data with good CRC"
+       fi
+       _scratch_xfs_db -x -c 'sb 0' -c "$*"
+}
 
 # Make sure that each fuzz verb works.  For the firstbit/middlebit/lastbit
 # tests, we depend on 'ones' having set the field to all ones.
 field="fdblocks"
-_scratch_xfs_db -x -c 'sb 0' -c "write -d ${field} 0"
+do_xfs_db write -d ${field} 0
 SCRATCH_XFS_LIST_FUZZ_VERBS= _scratch_xfs_list_fuzz_verbs | while read verb; do
        test "${verb}" = "random" && continue
        echo "Test verb ${verb}"
-       _scratch_xfs_db -x -c 'sb 0' -c "fuzz -d ${field} ${verb}"
+       do_xfs_db fuzz -d ${field} ${verb}
 done
 
 echo "Test verb random"
 before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
-_scratch_xfs_db -x -c 'sb 0' -c "fuzz -d ${field} random" >> $seqres.full
+do_xfs_db fuzz -d ${field} random >> $seqres.full
 after="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
 test "${before}" != "${after}" && echo "${field} changed"


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

* Re: [PATCH] xfs: test xfs_db fuzz command verbs
  2017-08-22  7:06 ` Eryu Guan
@ 2017-08-22 16:24   ` Darrick J. Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2017-08-22 16:24 UTC (permalink / raw)
  To: Eryu Guan; +Cc: xfs, fstests

On Tue, Aug 22, 2017 at 03:06:14PM +0800, Eryu Guan wrote:
> Hi Darrick,
> 
> On Sat, Aug 19, 2017 at 08:46:45AM -0700, Darrick J. Wong wrote:
> > Ensure that the fuzz command does what it says.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> I applied your patch "[PATCH] xfs_db: bit fuzzing should read the right
> bit when flipping" on top of xfsprogs for-next branch (which contains
> commit ef209a960d82 "xfs_db: make write/fuzz -c and -d work on non-crc
> filesystems") and tested this patch. All worked fine on CRC enabled XFS,
> but test failed with non-CRC xfs as it missed lines like:
> 
> Allowing fuzz of corrupted data with good CRC
> 
> I did the following modifications and test passed with both CRC and
> non-CRC XFS, if you think it's OK then I can fold the changes to your
> patch and no need for a resend :)

Looks fine to me, go ahead and fold it in.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> 
> Thanks,
> Eryu
> 
> diff --git a/tests/xfs/058 b/tests/xfs/058
> index 4a39942..32ceb0d 100755
> --- a/tests/xfs/058
> +++ b/tests/xfs/058
> @@ -50,21 +50,31 @@ _require_xfs_db_command "fuzz"
>  rm -f "$seqres.full"
>  
>  echo "Format"
> -_scratch_mkfs > "$seqres.full" 2>&1
> +_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >> "$seqres.full"
> +source $tmp.mkfs
> +
> +do_xfs_db()
> +{
> +       local cmd=$1
> +       if [ $_fs_has_crcs -eq 0 ]; then
> +               echo "Allowing $cmd of corrupted data with good CRC"
> +       fi
> +       _scratch_xfs_db -x -c 'sb 0' -c "$*"
> +}
>  
>  # Make sure that each fuzz verb works.  For the firstbit/middlebit/lastbit
>  # tests, we depend on 'ones' having set the field to all ones.
>  field="fdblocks"
> -_scratch_xfs_db -x -c 'sb 0' -c "write -d ${field} 0"
> +do_xfs_db write -d ${field} 0
>  SCRATCH_XFS_LIST_FUZZ_VERBS= _scratch_xfs_list_fuzz_verbs | while read verb; do
>         test "${verb}" = "random" && continue
>         echo "Test verb ${verb}"
> -       _scratch_xfs_db -x -c 'sb 0' -c "fuzz -d ${field} ${verb}"
> +       do_xfs_db fuzz -d ${field} ${verb}
>  done
>  
>  echo "Test verb random"
>  before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
> -_scratch_xfs_db -x -c 'sb 0' -c "fuzz -d ${field} random" >> $seqres.full
> +do_xfs_db fuzz -d ${field} random >> $seqres.full
>  after="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
>  test "${before}" != "${after}" && echo "${field} changed"
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-08-22 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-19 15:46 [PATCH] xfs: test xfs_db fuzz command verbs Darrick J. Wong
2017-08-22  7:06 ` Eryu Guan
2017-08-22 16: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