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
35 _require_arbitrary_fileset_reflink
39 testdir=$TEST_DIR/test-$seq
43 echo "Create the original files"
45 _pwrite_byte 0x61 0 $((blksz * 8)) $testdir/file1 >> $seqres.full
46 _pwrite_byte 0x62 0 $((blksz * 8)) $testdir/file2 >> $seqres.full
47 _pwrite_byte 0x63 0 $((blksz * 8)) $testdir/file3 >> $seqres.full
48 _pwrite_byte 0x64 0 $((blksz * 8)) $testdir/file4 >> $seqres.full
51 md5sum $testdir/file1 | _filter_test_dir
52 md5sum $testdir/file2 | _filter_test_dir
53 md5sum $testdir/file3 | _filter_test_dir
54 md5sum $testdir/file4 | _filter_test_dir
56 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
57 || echo "Files 1-2 do not match (intentional)"
59 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 8)) \
60 || echo "Files 1-3 do not match (intentional)"
62 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 8)) \
63 || echo "Files 1-4 do not match (intentional)"
65 echo "Reflink the first four blocks together, 1-2 3-4"
66 free_before=$(stat -f -c '%a' $testdir)
67 _reflink_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) >> $seqres.full
68 _reflink_range $testdir/file3 0 $testdir/file4 0 $((blksz * 4)) >> $seqres.full
70 free_after=$(stat -f -c '%a' $testdir)
71 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
73 echo "Compare sections"
74 md5sum $testdir/file1 | _filter_test_dir
75 md5sum $testdir/file2 | _filter_test_dir
76 md5sum $testdir/file3 | _filter_test_dir
77 md5sum $testdir/file4 | _filter_test_dir
79 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
80 || echo "Sections of file 1-2 do not match"
82 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 4)) \
83 || echo "Sections of file 1-3 do not match (intentional)"
85 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 4)) \
86 || echo "Sections of file 1-4 do not match (intentional)"
88 _compare_range $testdir/file2 0 $testdir/file3 0 $((blksz * 4)) \
89 || echo "Sections of file 2-3 do not match (intentional)"
91 _compare_range $testdir/file2 0 $testdir/file4 0 $((blksz * 4)) \
92 || echo "Sections of file 2-4 do not match (intentional)"
94 _compare_range $testdir/file3 0 $testdir/file4 0 $((blksz * 4)) \
95 || echo "Sections of file 3-4 do not match"
97 echo "Reflink the first two blocks together, 1-3 1-4"
98 free_before=$(stat -f -c '%a' $testdir)
99 _reflink_range $testdir/file1 0 $testdir/file3 0 $((blksz * 2)) >> $seqres.full
100 _reflink_range $testdir/file1 0 $testdir/file4 0 $((blksz * 2)) >> $seqres.full
102 free_after=$(stat -f -c '%a' $testdir)
103 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
105 echo "Compare sections"
106 md5sum $testdir/file1 | _filter_test_dir
107 md5sum $testdir/file2 | _filter_test_dir
108 md5sum $testdir/file3 | _filter_test_dir
109 md5sum $testdir/file4 | _filter_test_dir
111 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 2)) \
112 || echo "Sections of files 1-2 do not match"
114 _compare_range $testdir/file1 0 $testdir/file3 0 $((blksz * 2)) \
115 || echo "Sections of files 1-3 do not match"
117 _compare_range $testdir/file1 0 $testdir/file4 0 $((blksz * 2)) \
118 || echo "Sections of files 1-4 do not match"
120 _compare_range $testdir/file2 0 $testdir/file3 0 $((blksz * 2)) \
121 || echo "Sections of files 2-3 do not match"
123 _compare_range $testdir/file2 0 $testdir/file4 0 $((blksz * 2)) \
124 || echo "Sections of files 2-4 do not match"
126 _compare_range $testdir/file3 0 $testdir/file4 0 $((blksz * 2)) \
127 || echo "Sections of files 3-4 do not match"
129 echo "Compare previously reflinked sections"
130 _compare_range $testdir/file1 $((blksz * 2)) $testdir/file2 \
131 $((blksz * 2)) $((blksz * 2)) \
132 || echo "Sections of file 1-2 do not match"
134 _compare_range $testdir/file1 $((blksz * 2)) $testdir/file3 \
135 $((blksz * 2)) $((blksz * 2)) \
136 || echo "Sections of file 1-3 do not match (intentional)"
138 _compare_range $testdir/file1 $((blksz * 2)) $testdir/file4 \
139 $((blksz * 2)) $((blksz * 2)) \
140 || echo "Sections of file 1-4 do not match (intentional)"
142 _compare_range $testdir/file2 $((blksz * 2)) $testdir/file3 \
143 $((blksz * 2)) $((blksz * 2)) \
144 || echo "Sections of file 2-3 do not match (intentional)"
146 _compare_range $testdir/file2 $((blksz * 2)) $testdir/file4 \
147 $((blksz * 2)) $((blksz * 2)) \
148 || echo "Sections of file 2-4 do not match (intentional)"
150 _compare_range $testdir/file3 $((blksz * 2)) $testdir/file4 \
151 $((blksz * 2)) $((blksz * 2)) \
152 || echo "Sections of file 3-4 do not match"