2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
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
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
25 rm -rf $tmp.* $testdir
28 # get standard environment, filters and checks
33 # real QA test starts here
36 _require_arbitrary_fileset_reflink
40 testdir=$TEST_DIR/test-$seq
44 echo "Create the original files"
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
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
57 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
58 || echo "Files 1-2 do not match (intentional)"
60 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 8)) \
61 || echo "Files 1-3 do not match (intentional)"
63 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 8)) \
64 || echo "Files 1-4 do not match (intentional)"
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
71 free_after=$(stat -f -c '%a' $testdir)
72 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
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
80 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
81 || echo "Sections of file 1-2 do not match"
83 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 4)) \
84 || echo "Sections of file 1-3 do not match (intentional)"
86 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 4)) \
87 || echo "Sections of file 1-4 do not match (intentional)"
89 _compare_range $testdir/file2 0 $testdir/file3 0 $((blksz * 4)) \
90 || echo "Sections of file 2-3 do not match (intentional)"
92 _compare_range $testdir/file2 0 $testdir/file4 0 $((blksz * 4)) \
93 || echo "Sections of file 2-4 do not match (intentional)"
95 _compare_range $testdir/file3 0 $testdir/file4 0 $((blksz * 4)) \
96 || echo "Sections of file 3-4 do not match"
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
103 free_after=$(stat -f -c '%a' $testdir)
104 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
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
112 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 2)) \
113 || echo "Sections of files 1-2 do not match"
115 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 2)) \
116 || echo "Sections of files 1-3 do not match"
118 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 2)) \
119 || echo "Sections of files 1-4 do not match"
121 _compare_range $testdir/file2 0 $testdir/file3 0 $((blksz * 2)) \
122 || echo "Sections of files 2-3 do not match"
124 _compare_range $testdir/file2 0 $testdir/file4 0 $((blksz * 2)) \
125 || echo "Sections of files 2-4 do not match"
127 _compare_range $testdir/file3 0 $testdir/file4 0 $((blksz * 2)) \
128 || echo "Sections of files 3-4 do not match"
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"
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)"
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)"
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)"
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)"
151 _compare_range $testdir/file3 $((blksz * 2)) $testdir/file4 \
152 $((blksz * 2)) $((blksz * 2)) \
153 || echo "Sections of file 3-4 do not match"