4 # Reflinking two sets of files together:
5 # - Reflink identical parts of two identical files
6 # - Reflink identical parts of two other identical files
7 # - Reflink identical parts of all four files
8 # - Check that we end up with identical contents
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
28 seqres="$RESULT_DIR/$seq"
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
39 rm -rf "$tmp".* "$TESTDIR"
42 # get standard environment, filters and checks
47 # real QA test starts here
53 TESTDIR=$TEST_DIR/test-$seq
57 echo "Create the original files"
59 _pwrite_byte 0x61 0 $((BLKSZ * 8)) "$TESTDIR/file1" >> "$seqres.full"
60 _pwrite_byte 0x62 0 $((BLKSZ * 8)) "$TESTDIR/file2" >> "$seqres.full"
61 _pwrite_byte 0x63 0 $((BLKSZ * 8)) "$TESTDIR/file3" >> "$seqres.full"
62 _pwrite_byte 0x64 0 $((BLKSZ * 8)) "$TESTDIR/file4" >> "$seqres.full"
65 md5sum "$TESTDIR/file1" | _filter_test_dir
66 md5sum "$TESTDIR/file2" | _filter_test_dir
67 md5sum "$TESTDIR/file3" | _filter_test_dir
68 md5sum "$TESTDIR/file4" | _filter_test_dir
70 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $((BLKSZ * 8)) \
71 || echo "Files 1-2 do not match (intentional)"
73 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file3" 0 $((BLKSZ * 8)) \
74 || echo "Files 1-3 do not match (intentional)"
76 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file4" 0 $((BLKSZ * 8)) \
77 || echo "Files 1-4 do not match (intentional)"
79 echo "Reflink the first four blocks together, 1-2 3-4"
80 free_before="$(stat -f -c '%a' "$TESTDIR")"
81 _reflink_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $((BLKSZ * 4)) >> "$seqres.full"
82 _reflink_range "$TESTDIR/file3" 0 "$TESTDIR/file4" 0 $((BLKSZ * 4)) >> "$seqres.full"
84 free_after="$(stat -f -c '%a' "$TESTDIR")"
85 echo "freesp changed by $free_before -> $free_after" >> "$seqres.full"
87 echo "Compare sections"
88 md5sum "$TESTDIR/file1" | _filter_test_dir
89 md5sum "$TESTDIR/file2" | _filter_test_dir
90 md5sum "$TESTDIR/file3" | _filter_test_dir
91 md5sum "$TESTDIR/file4" | _filter_test_dir
93 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $((BLKSZ * 4)) \
94 || echo "Sections of file 1-2 do not match"
96 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file3" 0 $((BLKSZ * 4)) \
97 || echo "Sections of file 1-3 do not match (intentional)"
99 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file4" 0 $((BLKSZ * 4)) \
100 || echo "Sections of file 1-4 do not match (intentional)"
102 _compare_range "$TESTDIR/file2" 0 "$TESTDIR/file3" 0 $((BLKSZ * 4)) \
103 || echo "Sections of file 2-3 do not match (intentional)"
105 _compare_range "$TESTDIR/file2" 0 "$TESTDIR/file4" 0 $((BLKSZ * 4)) \
106 || echo "Sections of file 2-4 do not match (intentional)"
108 _compare_range "$TESTDIR/file3" 0 "$TESTDIR/file4" 0 $((BLKSZ * 4)) \
109 || echo "Sections of file 3-4 do not match"
111 echo "Reflink the first two blocks together, 1-3 1-4"
112 free_before="$(stat -f -c '%a' $TESTDIR)"
113 _reflink_range "$TESTDIR/file1" 0 "$TESTDIR/file3" 0 $((BLKSZ * 2)) >> "$seqres.full"
114 _reflink_range "$TESTDIR/file1" 0 "$TESTDIR/file4" 0 $((BLKSZ * 2)) >> "$seqres.full"
116 free_after="$(stat -f -c '%a' $TESTDIR)"
117 echo "freesp changed by $free_before -> $free_after" >> "$seqres.full"
119 echo "Compare sections"
120 md5sum "$TESTDIR/file1" | _filter_test_dir
121 md5sum "$TESTDIR/file2" | _filter_test_dir
122 md5sum "$TESTDIR/file3" | _filter_test_dir
123 md5sum "$TESTDIR/file4" | _filter_test_dir
125 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $((BLKSZ * 2)) \
126 || echo "Sections of files 1-2 do not match"
128 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file3" 0 $((BLKSZ * 2)) \
129 || echo "Sections of files 1-3 do not match"
131 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file4" 0 $((BLKSZ * 2)) \
132 || echo "Sections of files 1-4 do not match"
134 _compare_range "$TESTDIR/file2" 0 "$TESTDIR/file3" 0 $((BLKSZ * 2)) \
135 || echo "Sections of files 2-3 do not match"
137 _compare_range "$TESTDIR/file2" 0 "$TESTDIR/file4" 0 $((BLKSZ * 2)) \
138 || echo "Sections of files 2-4 do not match"
140 _compare_range "$TESTDIR/file3" 0 "$TESTDIR/file4" 0 $((BLKSZ * 2)) \
141 || echo "Sections of files 3-4 do not match"
143 echo "Compare previously reflinked sections"
144 _compare_range "$TESTDIR/file1" $((BLKSZ * 2)) "$TESTDIR/file2" \
145 $((BLKSZ * 2)) $((BLKSZ * 2)) \
146 || echo "Sections of file 1-2 do not match"
148 _compare_range "$TESTDIR/file1" $((BLKSZ * 2)) "$TESTDIR/file3" \
149 $((BLKSZ * 2)) $((BLKSZ * 2)) \
150 || echo "Sections of file 1-3 do not match (intentional)"
152 _compare_range "$TESTDIR/file1" $((BLKSZ * 2)) "$TESTDIR/file4" \
153 $((BLKSZ * 2)) $((BLKSZ * 2)) \
154 || echo "Sections of file 1-4 do not match (intentional)"
156 _compare_range "$TESTDIR/file2" $((BLKSZ * 2)) "$TESTDIR/file3" \
157 $((BLKSZ * 2)) $((BLKSZ * 2)) \
158 || echo "Sections of file 2-3 do not match (intentional)"
160 _compare_range "$TESTDIR/file2" $((BLKSZ * 2)) "$TESTDIR/file4" \
161 $((BLKSZ * 2)) $((BLKSZ * 2)) \
162 || echo "Sections of file 2-4 do not match (intentional)"
164 _compare_range "$TESTDIR/file3" $((BLKSZ * 2)) "$TESTDIR/file4" \
165 $((BLKSZ * 2)) $((BLKSZ * 2)) \
166 || echo "Sections of file 3-4 do not match"