xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 032
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 032
6 #
7 # Test xfs_copy for all filesystem sector size / block size
8 # combinations possible on this platform.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=0        # success is the default!
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18
19 # get standard environment, filters and checks
20 . ./common/rc
21
22 # real QA test starts here
23 _supported_fs xfs
24
25 _require_scratch
26 _require_test_program "feature"
27 _require_xfs_copy
28
29 rm -f $seqres.full
30
31 SECTORSIZE=`blockdev --getss $SCRATCH_DEV`
32 PAGESIZE=`$here/src/feature -s`
33 IMGFILE=$TEST_DIR/${seq}_copy.img
34
35 echo "Silence is golden."
36
37 do_copy()
38 {
39         local opts="$*"
40
41         $XFS_COPY_PROG $opts $SCRATCH_DEV $IMGFILE >> $seqres.full 2>&1 || \
42                 _fail "xfs_copy $opts failed for Sector size $SECTORSIZE Block size $BLOCKSIZE"
43         # Must use "-n" to get exit code; without it xfs_repair always returns 0
44         $XFS_REPAIR_PROG -n -f $IMGFILE >> $seqres.full 2>&1 || \
45                 _fail "xfs_copy $opts corrupted for Sector size $SECTORSIZE Block size $BLOCKSIZE"
46 }
47
48 while [ $SECTORSIZE -le $PAGESIZE ]; do
49         BLOCKSIZE=$SECTORSIZE;
50
51         while [ $BLOCKSIZE -le $PAGESIZE ]; do
52
53                 echo "=== Sector size $SECTORSIZE Block size $BLOCKSIZE ==" >> $seqres.full
54                 _scratch_mkfs -s size=$SECTORSIZE -b size=$BLOCKSIZE -d size=1g >> $seqres.full 2>&1
55                 # Maybe return error at here, e.g: mkfs.xfs -m crc=1 -b size=512
56                 if [ $? -ne 0 ]; then
57                         BLOCKSIZE=$(($BLOCKSIZE * 2))
58                         continue
59                 fi
60                 _scratch_mount
61                 # light population of the fs
62                 $FSSTRESS_PROG -n 100 -d $SCRATCH_MNT >> $seqres.full 2>&1
63                 _scratch_unmount
64
65                 # Test "duplicate" copy at first, if $XFS_COPY_PROG won't do it.
66                 if [[ ! "$XFS_COPY_PROG" =~ -d ]]; then
67                         do_copy -d
68                 fi
69                 do_copy
70
71                 BLOCKSIZE=$(($BLOCKSIZE * 2));
72         done
73         SECTORSIZE=$(($SECTORSIZE * 2));
74 done
75
76 # success, all done
77 exit