xfs: test xfs_db fuzz command verbs
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 19 Aug 2017 15:46:45 +0000 (08:46 -0700)
committerEryu Guan <eguan@redhat.com>
Tue, 22 Aug 2017 07:08:05 +0000 (15:08 +0800)
Ensure that the fuzz command does what it says.

[eguan: fixed test failures on non-CRC XFS]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
tests/xfs/058 [new file with mode: 0755]
tests/xfs/058.out [new file with mode: 0644]
tests/xfs/group

diff --git a/tests/xfs/058 b/tests/xfs/058
new file mode 100755 (executable)
index 0000000..32ceb0d
--- /dev/null
@@ -0,0 +1,84 @@
+#! /bin/bash
+# FS QA Test No. 058
+#
+# 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 | _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"
+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}"
+       do_xfs_db fuzz -d ${field} ${verb}
+done
+
+echo "Test verb random"
+before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
+do_xfs_db 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/058.out b/tests/xfs/058.out
new file mode 100644 (file)
index 0000000..5c187c0
--- /dev/null
@@ -0,0 +1,28 @@
+QA output created by 058
+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
index 617c3d2ad67d3a47cf03ba50e9ef63c846df71cf..2d83c12f610a0d6a9f53d494677988049559c5d8 100644 (file)
@@ -55,6 +55,7 @@
 055 dump ioctl remote tape
 056 dump ioctl auto quick
 057 auto log
+058 auto quick fuzzers
 059 dump ioctl auto quick
 060 dump ioctl auto quick
 061 dump ioctl auto quick