xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / ceph / 003
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. ceph/005
6 #
7 # Test copy_file_range with infile = outfile
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf $tmp.*
22 }
23
24 # get standard environment
25 . common/rc
26 . common/filter
27 . common/attr
28 . common/reflink
29
30 # real QA test starts here
31 _supported_fs ceph
32
33 _require_xfs_io_command "copy_range"
34 _require_attrs
35 _require_test
36
37 workdir=$TEST_DIR/test-$seq
38 rm -rf $workdir
39 mkdir $workdir
40 rm -f $seqres.full
41
42 check_range()
43 {
44         local file=$1
45         local off0=$2
46         local off1=$3
47         local val=$4
48         _read_range $file $off0 $off1 | grep -v -q $val
49         [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
50 }
51
52 objsz=4194304
53 halfobj=$(($objsz / 2))
54 file="$workdir/file-$objsz"
55 copy="$workdir/copy-$objsz"
56 dest="$workdir/dest-$objsz"
57 backup="$file.backup"
58
59 # object_size has to be a multiple of stripe_unit
60 _ceph_create_file_layout $file $objsz 1 $objsz
61 _ceph_create_file_layout $backup $objsz 1 $objsz
62
63 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
64 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
65 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
66
67 cp $file $backup
68
69 echo "  Copy single object to the end:"
70 echo "    aaaa|bbbb|cccc => aaaa|bbbb|aaaa"
71 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$file"
72 check_range $file 0 $objsz 61
73 check_range $file $objsz $objsz 62
74 check_range $file $(($objsz * 2)) $objsz 61
75
76 echo "  Copy single object to the beginning:"
77 echo "    aaaa|bbbb|aaaa => bbbb|bbbb|aaaa"
78 $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$file"
79 check_range $file 0 $(($objsz * 2)) 62
80 check_range $file $(($objsz * 2)) $objsz 61
81
82 echo "  Copy single object to the middle:"
83 echo "    bbbb|bbbb|aaaa => bbbb|aaaa|aaaa"
84 $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $objsz -l $objsz $file" "$file"
85 check_range $file 0 $objsz 62
86 check_range $file $objsz $(($objsz * 2)) 61
87
88 cp $backup $file
89 echo "  Cross object boundary (no full object copy)"
90 echo "    aaaa|bbbb|cccc => aaaa|bbaa|aacc"
91 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
92 check_range $file 0 $objsz 61
93 check_range $file $objsz $halfobj 62
94 check_range $file $(($objsz + $halfobj)) $objsz 61
95 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
96
97 cp $backup $file
98 echo "    aaaa|bbbb|cccc => aaaa|bbaa|bbcc"
99 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz + $halfobj)) -l $objsz $file" "$file"
100 check_range $file 0 $objsz 61
101 check_range $file $objsz $halfobj 62
102 check_range $file $(($objsz + $halfobj)) $halfobj 61
103 check_range $file $(($objsz * 2)) $halfobj 62
104 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 63
105
106 cp $backup $file
107 echo "    aaaa|bbbb|cccc => aaaa|bbbb|aabb"
108 $XFS_IO_PROG -c "copy_range -s $halfobj -d $(($objsz * 2)) -l $objsz $file" "$file"
109 check_range $file 0 $objsz 61
110 check_range $file $objsz $objsz 62
111 check_range $file $(($objsz * 2)) $halfobj 61
112 check_range $file $(($objsz * 2 + $halfobj)) $halfobj 62
113
114 #success, all done
115 status=0
116 exit