6d644ad86a68cefcfe3f542f051172028c0c4f1d
[xfstests-dev.git] / tests / xfs / 032
1 #! /bin/bash
2 # FS QA Test No. 032
3 #
4 # Test xfs_copy for all filesystem sector size / block size
5 # combinations possible on this platform.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=0        # success is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common/rc
37
38 # real QA test starts here
39 _supported_fs xfs
40 _supported_os IRIX Linux
41
42 _require_scratch
43 _require_test_program "feature"
44
45 [ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
46 [ -n "$XFS_COPY_PROG" ] || _notrun "xfs_copy binary not yet installed"
47
48 rm -f $seqres.full
49
50 SECTORSIZE=`blockdev --getss $SCRATCH_DEV`
51 PAGESIZE=`src/feature -s`
52 IMGFILE=$TEST_DIR/${seq}_copy.img
53
54 echo "Silence is golden."
55
56 do_copy()
57 {
58         local opts="$*"
59
60         $XFS_COPY_PROG $opts $SCRATCH_DEV $IMGFILE >> $seqres.full 2>&1 || \
61                 _fail "xfs_copy $opts failed for Sector size $SECTORSIZE Block size $BLOCKSIZE"
62         # Must use "-n" to get exit code; without it xfs_repair always returns 0
63         $XFS_REPAIR_PROG -n -f $IMGFILE >> $seqres.full 2>&1 || \
64                 _fail "xfs_copy $opts corrupted for Sector size $SECTORSIZE Block size $BLOCKSIZE"
65 }
66
67 while [ $SECTORSIZE -le $PAGESIZE ]; do
68         BLOCKSIZE=$SECTORSIZE;
69
70         while [ $BLOCKSIZE -le $PAGESIZE ]; do
71
72                 echo "=== Sector size $SECTORSIZE Block size $BLOCKSIZE ==" >> $seqres.full
73                 _scratch_mkfs -s size=$SECTORSIZE -b size=$BLOCKSIZE -d size=1g >> $seqres.full 2>&1
74                 # Maybe return error at here, e.g: mkfs.xfs -m crc=1 -b size=512
75                 if [ $? -ne 0 ]; then
76                         BLOCKSIZE=$(($BLOCKSIZE * 2))
77                         continue
78                 fi
79                 _scratch_mount
80                 # light population of the fs
81                 $FSSTRESS_PROG -n 100 -d $SCRATCH_MNT >> $seqres.full 2>&1
82                 _scratch_unmount
83
84                 # Test "duplicate" copy at first, if $XFS_COPY_PROG won't do it.
85                 if [[ ! "$XFS_COPY_PROG" =~ -d ]]; then
86                         do_copy -d
87                 fi
88                 do_copy
89
90                 BLOCKSIZE=$(($BLOCKSIZE * 2));
91         done
92         SECTORSIZE=$(($SECTORSIZE * 2));
93 done
94
95 # success, all done
96 exit