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"