2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensuring that we cannot dedupe non-matching parts of files:
8 # - Fail to dedupe non-identical parts of two different files
9 # - Check that nothing changes in either file
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
23 rm -rf $tmp.* $testdir
26 # get standard environment, filters and checks
31 # real QA test starts here
37 testdir=$TEST_DIR/test-$seq
41 echo "Create the original files"
43 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
44 _pwrite_byte 0x62 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
47 md5sum $testdir/file1 | _filter_test_dir
48 md5sum $testdir/file2 | _filter_test_dir
50 _compare_range $testdir/file1 0 $testdir/file2 0 "$((blksz * 8))" \
51 || echo "Files 1-2 do not match (intentional)"
53 echo "(Fail to) dedupe the middle blocks together"
54 free_before=$(stat -f -c '%a' $testdir)
55 _dedupe_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
56 $((blksz * 4)) $((blksz * 2)) 2>&1 | _filter_dedupe_error
58 free_after=$(stat -f -c '%a' $testdir)
59 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
61 echo "Compare sections"
62 md5sum $testdir/file1 | _filter_test_dir
63 md5sum $testdir/file2 | _filter_test_dir
65 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
66 || echo "Start sections do not match (intentional)"
68 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
69 $((blksz * 4)) $((blksz * 2)) \
70 || echo "Middle sections do not match (intentional)"
72 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
73 $((blksz * 6)) $((blksz * 2)) \
74 || echo "End sections do not match (intentional)"