xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 083
index 040f3b6cbf3c498154e5b94ab4e695425b94a20d..14a36416f47efb2a18edd781d0e87241471f027e 100755 (executable)
@@ -1,28 +1,13 @@
 #! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2015 Oracle, Inc.  All Rights Reserved.
+#
 # FS QA Test No. 083
 #
 # Create and populate an XFS filesystem, fuzz the metadata, then see how
 # the kernel reacts, how xfs_repair fares in fixing the mess, and then
 # try more kernel accesses to see if it really fixed things.
 #
-#-----------------------------------------------------------------------
-# Copyright (c) 2015 Oracle, Inc.  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"
@@ -43,24 +28,23 @@ _cleanup()
 . ./common/filter
 . ./common/attr
 . ./common/populate
+. ./common/fuzzy
 
 # real QA test starts here
 _supported_fs xfs
-_supported_os Linux
 
-_require_xfs_io_command "falloc"
-_require_xfs_io_command "fpunch"
 _require_scratch
 #_require_xfs_crc      # checksum not required, but you probably want it anyway...
 #_require_xfs_mkfs_crc
 _require_attrs
+_require_populate_commands
 
 scratch_repair() {
        fsck_pass="$1"
 
        FSCK_LOG="${tmp}-fuzz-${fsck_pass}.log"
        echo "++ fsck pass ${fsck_pass}" > "${FSCK_LOG}"
-       _scratch_xfs_repair >> "${FSCK_LOG}" 2>&1
+       _repair_scratch_fs >> "${FSCK_LOG}" 2>&1
        res=$?
        if [ "${res}" -eq 0 ]; then
                echo "++ allegedly fixed, reverify" >> "${FSCK_LOG}"
@@ -75,7 +59,7 @@ scratch_repair() {
        elif [ "${res}" -eq 2 ]; then
                # replay log?
                echo "+++ replaying log" >> "${FSCK_LOG}"
-               _scratch_mount >> "${FSCK_LOG}" 2>&1
+               _try_scratch_mount >> "${FSCK_LOG}" 2>&1
                res=$?
                echo "+++ mount returns ${res}" >> "${FSCK_LOG}"
                if [ "${res}" -gt 0 ]; then
@@ -121,13 +105,13 @@ echo "+ populate fs image" >> $seqres.full
 _scratch_populate >> $seqres.full
 
 echo "+ check fs" >> $seqres.full
-_scratch_xfs_repair >> $seqres.full 2>&1 || _fail "should pass initial fsck"
+_repair_scratch_fs >> $seqres.full 2>&1 || _fail "should pass initial fsck"
 
 echo "++ corrupt image" >> $seqres.full
-xfs_db -x -c blockget -c "blocktrash ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+_scratch_xfs_db -x -c blockget -c "blocktrash ${FUZZ_ARGS}" >> $seqres.full 2>&1
 
 echo "++ mount image" >> $seqres.full
-_scratch_mount >> $seqres.full 2>&1
+_try_scratch_mount >> $seqres.full 2>&1
 
 echo "+++ test scratch" >> $seqres.full
 _scratch_fuzz_test >> $seqres.full 2>&1
@@ -145,11 +129,11 @@ done
 echo "+ fsck loop returns ${fsck_loop_ret}" >> $seqres.full
 
 echo "++ check fs for round 2" >> $seqres.full
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 ROUND2_LOG="${tmp}-round2-${fsck_pass}.log"
 echo "++ mount image (2)" >> $ROUND2_LOG
-_scratch_mount >> $ROUND2_LOG 2>&1
+_try_scratch_mount >> $ROUND2_LOG 2>&1
 
 echo "++ chattr -R -i" >> $ROUND2_LOG
 $CHATTR_PROG -R -f -i "${SCRATCH_MNT}/" > /dev/null 2>> $ROUND2_LOG
@@ -166,7 +150,7 @@ umount "${SCRATCH_MNT}" >> $ROUND2_LOG 2>&1
 cat "$ROUND2_LOG" >> $seqres.full
 
 echo "++ check fs (2)" >> $seqres.full
-_scratch_xfs_repair >> $seqres.full 2>&1
+_repair_scratch_fs >> $seqres.full 2>&1
 
 egrep -q '(did not fix|makes no progress)' $seqres.full && echo "xfs_repair failed" | tee -a $seqres.full
 if [ "$(wc -l < "$ROUND2_LOG")" -ne 8 ]; then