4 # Ensure that we can dedupe parts of two files:
5 # - Dedupe identical parts of two identical files
6 # - Check that still have identical contents
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
26 seqres="$RESULT_DIR/$seq"
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
37 rm -rf "$tmp".* "$TESTDIR"
40 # get standard environment, filters and checks
45 # real QA test starts here
51 TESTDIR="$TEST_DIR/test-$seq"
55 echo "Create the original files"
57 _pwrite_byte 0x61 $((BLKSZ * 2)) $((BLKSZ * 6)) "$TESTDIR/file1" >> "$seqres.full"
58 _pwrite_byte 0x61 $((BLKSZ * 2)) $((BLKSZ * 6)) "$TESTDIR/file2" >> "$seqres.full"
61 md5sum "$TESTDIR/file1" | _filter_test_dir
62 md5sum "$TESTDIR/file2" | _filter_test_dir
64 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $((BLKSZ * 8)) \
65 || echo "Files 1-2 do not match (intentional)"
67 echo "Dedupe the middle blocks together"
68 free_before="$(stat -f -c '%a' "$TESTDIR")"
69 _dedupe_range "$TESTDIR/file1" $((BLKSZ * 4)) "$TESTDIR/file2" \
70 $((BLKSZ * 4)) $((BLKSZ * 2)) >> "$seqres.full"
72 free_after="$(stat -f -c '%a' "$TESTDIR")"
73 echo "freesp changed by $free_before -> $free_after" >> "$seqres.full"
75 echo "Compare sections"
76 md5sum "$TESTDIR/file1" | _filter_test_dir
77 md5sum "$TESTDIR/file2" | _filter_test_dir
79 _compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $((BLKSZ * 4)) \
80 || echo "Start sections do not match"
82 _compare_range "$TESTDIR/file1" $((BLKSZ * 4)) "$TESTDIR/file2" \
83 $((BLKSZ * 4)) $((BLKSZ * 2)) \
84 || echo "Middle sections do not match"
86 _compare_range "$TESTDIR/file1" $((BLKSZ * 6)) "$TESTDIR/file2" \
87 $((BLKSZ * 6)) $((BLKSZ * 2)) \
88 || echo "End sections do not match"