4 # Ensuring that we can reflink non-matching parts of files:
5 # - Reflink identical ranges of two different files
6 # - Check that the non-linked ranges still do not match
7 # - Check that we end up with identical contents in the linked ranges
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
38 rm -rf $tmp.* $testdir
41 # get standard environment, filters and checks
46 # real QA test starts here
52 testdir=$TEST_DIR/test-$seq
56 echo "Create the original files"
58 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
59 _pwrite_byte 0x62 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
62 md5sum $testdir/file1 | _filter_test_dir
63 md5sum $testdir/file2 | _filter_test_dir
65 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
66 || echo "Files do not match (intentional)"
68 echo "Reflink the middle blocks together"
69 free_before=$(stat -f -c '%a' $testdir)
70 _reflink_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
71 $((blksz * 4)) $((blksz * 2)) >> $seqres.full
73 free_after=$(stat -f -c '%a' $testdir)
74 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
76 echo "Compare sections"
77 md5sum $testdir/file1 | _filter_test_dir
78 md5sum $testdir/file2 | _filter_test_dir
80 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
81 || echo "Start sections do not match (intentional)"
83 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
84 $((blksz * 4)) $((blksz * 2)) \
85 || echo "Middle sections do not match"
87 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
88 $((blksz * 6)) $((blksz * 2)) \
89 || echo "End sections do not match (intentional)"