4 # Ensure that we can reflink the last block of a file whose size isn't
6 # - Create two 'a' files file whose size isn't block-aligned.
7 # - Create two 'b' files file whose size isn't block-aligned.
8 # - Reflink the last block of file1 to the last block in file2 and file3.
9 # - Check that files 1-2 match, 3-4 don't match, and that nothing matches 3.
10 # - Check that the ends of 1-3 match, and 1-3 do not match the end of file4.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
41 rm -rf $tmp.* $testdir
44 # get standard environment, filters and checks
49 # real QA test starts here
55 testdir=$TEST_DIR/test-$seq
59 echo "Create the original files"
61 _pwrite_byte 0x61 0 $((blksz + 37)) $testdir/file1 >> $seqres.full
62 _pwrite_byte 0x61 0 $((blksz + 37)) $testdir/file2 >> $seqres.full
63 _pwrite_byte 0x62 0 $((blksz + 37)) $testdir/file3 >> $seqres.full
64 _pwrite_byte 0x62 0 $((blksz + 37)) $testdir/file4 >> $seqres.full
67 md5sum $testdir/file1 | _filter_test_dir
68 md5sum $testdir/file2 | _filter_test_dir
69 md5sum $testdir/file3 | _filter_test_dir
70 md5sum $testdir/file4 | _filter_test_dir
72 c1="$(_md5_checksum $testdir/file1)"
73 c2="$(_md5_checksum $testdir/file2)"
74 c3="$(_md5_checksum $testdir/file3)"
75 c4="$(_md5_checksum $testdir/file4)"
77 test ${c1} = ${c2} || echo "file1 and file2 should match"
78 test ${c1} != ${c3} || echo "file1 and file3 should not match"
79 test ${c1} != ${c4} || echo "file1 and file4 should not match"
80 test ${c2} != ${c3} || echo "file2 and file3 should not match"
81 test ${c2} != ${c4} || echo "file2 and file4 should not match"
82 test ${c3} = ${c4} || echo "file3 and file4 should match"
84 echo "Reflink the last blocks together, 1-2 1-3"
85 _reflink_range $testdir/file1 $blksz $testdir/file2 $blksz 37 >> $seqres.full
86 _reflink_range $testdir/file1 $blksz $testdir/file3 $blksz 37 >> $seqres.full
89 md5sum $testdir/file1 | _filter_test_dir
90 md5sum $testdir/file2 | _filter_test_dir
91 md5sum $testdir/file3 | _filter_test_dir
92 md5sum $testdir/file4 | _filter_test_dir
94 c1="$(_md5_checksum $testdir/file1)"
95 c2="$(_md5_checksum $testdir/file2)"
96 c3="$(_md5_checksum $testdir/file3)"
97 c4="$(_md5_checksum $testdir/file4)"
100 test ${c1} = ${c2} || echo "file1 and file2 should match"
101 test ${c1} != ${c3} || echo "file1 and file3 should not match"
102 test ${c1} != ${c4} || echo "file1 and file4 should not match"
103 test ${c2} != ${c3} || echo "file2 and file3 should not match"
104 test ${c2} != ${c4} || echo "file2 and file4 should not match"
105 test ${c3} != ${c4} || echo "file3 and file4 should match"
107 echo "Compare sections"
108 _compare_range $testdir/file1 $blksz $testdir/file2 $blksz 37 \
109 || echo "End sections of files 1-2 do not match"
111 _compare_range $testdir/file1 $blksz $testdir/file3 $blksz 37 \
112 || echo "End sections of files 1-3 do not match"
114 _compare_range $testdir/file1 $blksz $testdir/file4 $blksz 37 \
115 || echo "End sections of files 1-4 do not match (intentional)"
117 _compare_range $testdir/file2 $blksz $testdir/file3 $blksz 37 \
118 || echo "End sections of files 2-3 do not match"
120 _compare_range $testdir/file2 $blksz $testdir/file4 $blksz 37 \
121 || echo "End sections of files 2-4 do not match (intentional)"
123 _compare_range $testdir/file3 $blksz $testdir/file4 $blksz 37 \
124 || echo "End sections of files 3-4 do not match (intentional)"