2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that we can dedupe parts of two files:
8 # - Dedupe identical parts of two identical files
9 # - Check that still have identical contents
12 _begin_fstest auto quick clone dedupe
14 # Override the default cleanup function.
18 rm -rf $tmp.* $testdir
21 # Import common functions.
25 # real QA test starts here
28 testdir=$TEST_DIR/test-$seq
32 echo "Create the original files"
34 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
35 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
38 md5sum $testdir/file1 | _filter_test_dir
39 md5sum $testdir/file2 | _filter_test_dir
41 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
42 || echo "Files 1-2 do not match (intentional)"
44 echo "Dedupe the middle blocks together"
45 free_before=$(stat -f -c '%a' $testdir)
46 _dedupe_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
47 $((blksz * 4)) $((blksz * 2)) >> $seqres.full
49 free_after=$(stat -f -c '%a' $testdir)
50 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
52 echo "Compare sections"
53 md5sum $testdir/file1 | _filter_test_dir
54 md5sum $testdir/file2 | _filter_test_dir
56 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
57 || echo "Start sections do not match"
59 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
60 $((blksz * 4)) $((blksz * 2)) \
61 || echo "Middle sections do not match"
63 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
64 $((blksz * 6)) $((blksz * 2)) \
65 || echo "End sections do not match"