4 # Ensure that we can dedupe 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 # - Dedupe the last block of file1 to the last block in file2 and file3.
9 # - Check that files 1-2 match, and that 3-4 match.
10 # - Check that the ends of 1-2 and 3-4 match, and that 1-3 don't match.
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 "Dedupe the last blocks together"
85 _dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $BLKSZ 37 >> "$seqres.full"
86 _dedupe_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 (intentional)"
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 (intentional)"
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"