xfs/029: filter out "extended-header: cycle: 1" from output
[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 _supported_os Linux
25
26 _require_scratch
27 _require_test_program "feature"
28
29 [ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
30 [ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
31
32 rm -f $seqres.full
33
34 SECTORSIZE=`blockdev --getss $SCRATCH_DEV`
35 PAGESIZE=`$here/src/feature -s`
36 IMGFILE=$TEST_DIR/${seq}_copy.img
37
38 echo "Silence is golden."
39
40 do_copy()
41 {
42         local opts="$*"
43
44         $XFS_COPY_PROG $opts $SCRATCH_DEV $IMGFILE >> $seqres.full 2>&1 || \
45                 _fail "xfs_copy $opts failed for Sector size $SECTORSIZE Block size $BLOCKSIZE"
46         # Must use "-n" to get exit code; without it xfs_repair always returns 0
47         $XFS_REPAIR_PROG -n -f $IMGFILE >> $seqres.full 2>&1 || \
48                 _fail "xfs_copy $opts corrupted for Sector size $SECTORSIZE Block size $BLOCKSIZE"
49 }
50
51 while [ $SECTORSIZE -le $PAGESIZE ]; do
52         BLOCKSIZE=$SECTORSIZE;
53
54         while [ $BLOCKSIZE -le $PAGESIZE ]; do
55
56                 echo "=== Sector size $SECTORSIZE Block size $BLOCKSIZE ==" >> $seqres.full
57                 _scratch_mkfs -s size=$SECTORSIZE -b size=$BLOCKSIZE -d size=1g >> $seqres.full 2>&1
58                 # Maybe return error at here, e.g: mkfs.xfs -m crc=1 -b size=512
59                 if [ $? -ne 0 ]; then
60                         BLOCKSIZE=$(($BLOCKSIZE * 2))
61                         continue
62                 fi
63                 _scratch_mount
64                 # light population of the fs
65                 $FSSTRESS_PROG -n 100 -d $SCRATCH_MNT >> $seqres.full 2>&1
66                 _scratch_unmount
67
68                 # Test "duplicate" copy at first, if $XFS_COPY_PROG won't do it.
69                 if [[ ! "$XFS_COPY_PROG" =~ -d ]]; then
70                         do_copy -d
71                 fi
72                 do_copy
73
74                 BLOCKSIZE=$(($BLOCKSIZE * 2));
75         done
76         SECTORSIZE=$(($SECTORSIZE * 2));
77 done
78
79 # success, all done
80 exit