xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 119
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 119
6 #
7 # Reflinking two sets of files together:
8 #   - Reflink identical parts of two identical files
9 #   - Reflink identical parts of two other identical files
10 #   - Reflink identical parts of all four files
11 #   - Check that we end up with identical contents
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     cd /
25     rm -rf $tmp.* $testdir
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/reflink
32
33 # real QA test starts here
34 _supported_os Linux
35 _require_test_reflink
36 _require_arbitrary_fileset_reflink
37
38 rm -f $seqres.full
39
40 testdir=$TEST_DIR/test-$seq
41 rm -rf $testdir
42 mkdir $testdir
43
44 echo "Create the original files"
45 blksz=65536
46 _pwrite_byte 0x61 0 $((blksz * 8)) $testdir/file1 >> $seqres.full
47 _pwrite_byte 0x62 0 $((blksz * 8)) $testdir/file2 >> $seqres.full
48 _pwrite_byte 0x63 0 $((blksz * 8)) $testdir/file3 >> $seqres.full
49 _pwrite_byte 0x64 0 $((blksz * 8)) $testdir/file4 >> $seqres.full
50 _test_cycle_mount
51
52 md5sum $testdir/file1 | _filter_test_dir
53 md5sum $testdir/file2 | _filter_test_dir
54 md5sum $testdir/file3 | _filter_test_dir
55 md5sum $testdir/file4 | _filter_test_dir
56
57 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
58        || echo "Files 1-2 do not match (intentional)"
59
60 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 8)) \
61        || echo "Files 1-3 do not match (intentional)"
62
63 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 8)) \
64        || echo "Files 1-4 do not match (intentional)"
65
66 echo "Reflink the first four blocks together, 1-2 3-4"
67 free_before=$(stat -f -c '%a' $testdir)
68 _reflink_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) >> $seqres.full
69 _reflink_range $testdir/file3 0 $testdir/file4 0 $((blksz * 4)) >> $seqres.full
70 _test_cycle_mount
71 free_after=$(stat -f -c '%a' $testdir)
72 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
73
74 echo "Compare sections"
75 md5sum $testdir/file1 | _filter_test_dir
76 md5sum $testdir/file2 | _filter_test_dir
77 md5sum $testdir/file3 | _filter_test_dir
78 md5sum $testdir/file4 | _filter_test_dir
79
80 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
81        || echo "Sections of file 1-2 do not match"
82
83 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 4)) \
84        || echo "Sections of file 1-3 do not match (intentional)"
85
86 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 4)) \
87        || echo "Sections of file 1-4 do not match (intentional)"
88
89 _compare_range $testdir/file2 0 $testdir/file3 0 $((blksz * 4)) \
90        || echo "Sections of file 2-3 do not match (intentional)"
91
92 _compare_range $testdir/file2 0 $testdir/file4 0 $((blksz * 4)) \
93        || echo "Sections of file 2-4 do not match (intentional)"
94
95 _compare_range $testdir/file3 0 $testdir/file4 0 $((blksz * 4)) \
96        || echo "Sections of file 3-4 do not match"
97
98 echo "Reflink the first two blocks together, 1-3 1-4"
99 free_before=$(stat -f -c '%a' $testdir)
100 _reflink_range $testdir/file1 0 $testdir/file3 0 $((blksz * 2)) >> $seqres.full
101 _reflink_range $testdir/file1 0 $testdir/file4 0 $((blksz * 2)) >> $seqres.full
102 _test_cycle_mount
103 free_after=$(stat -f -c '%a' $testdir)
104 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
105
106 echo "Compare sections"
107 md5sum $testdir/file1 | _filter_test_dir
108 md5sum $testdir/file2 | _filter_test_dir
109 md5sum $testdir/file3 | _filter_test_dir
110 md5sum $testdir/file4 | _filter_test_dir
111
112 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 2)) \
113        || echo "Sections of files 1-2 do not match"
114
115 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 2)) \
116        || echo "Sections of files 1-3 do not match"
117
118 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 2)) \
119        || echo "Sections of files 1-4 do not match"
120
121 _compare_range $testdir/file2 0 $testdir/file3 0 $((blksz * 2)) \
122        || echo "Sections of files 2-3 do not match"
123
124 _compare_range $testdir/file2 0 $testdir/file4 0 $((blksz * 2)) \
125        || echo "Sections of files 2-4 do not match"
126
127 _compare_range $testdir/file3 0 $testdir/file4 0 $((blksz * 2)) \
128        || echo "Sections of files 3-4 do not match"
129
130 echo "Compare previously reflinked sections"
131 _compare_range $testdir/file1 $((blksz * 2)) $testdir/file2 \
132                 $((blksz * 2)) $((blksz * 2)) \
133        || echo "Sections of file 1-2 do not match"
134
135 _compare_range $testdir/file1 $((blksz * 2)) $testdir/file3 \
136                 $((blksz * 2)) $((blksz * 2)) \
137        || echo "Sections of file 1-3 do not match (intentional)"
138
139 _compare_range $testdir/file1 $((blksz * 2)) $testdir/file4 \
140                 $((blksz * 2)) $((blksz * 2)) \
141        || echo "Sections of file 1-4 do not match (intentional)"
142
143 _compare_range $testdir/file2 $((blksz * 2)) $testdir/file3 \
144                 $((blksz * 2)) $((blksz * 2)) \
145        || echo "Sections of file 2-3 do not match (intentional)"
146
147 _compare_range $testdir/file2 $((blksz * 2)) $testdir/file4 \
148                 $((blksz * 2)) $((blksz * 2)) \
149        || echo "Sections of file 2-4 do not match (intentional)"
150
151 _compare_range $testdir/file3 $((blksz * 2)) $testdir/file4 \
152                 $((blksz * 2)) $((blksz * 2)) \
153        || echo "Sections of file 3-4 do not match"
154
155 # success, all done
156 status=0
157 exit