4 # Test the convention that reflink with length == 0 means "to the end of fileA"
6 # - Try to reflink "zero" bytes (which means reflink to EOF).
7 # - Check that the reflink happened.
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
53 TESTDIR="$TEST_DIR/test-$seq"
57 echo "Create the original files"
59 _pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full"
60 _pwrite_byte 0x62 0 $((BLKSZ * 257)) "$TESTDIR/file2" >> "$seqres.full"
61 _pwrite_byte 0x62 0 $((BLKSZ * 257)) "$TESTDIR/file2.chk" >> "$seqres.full"
62 _dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full"
65 md5sum "$TESTDIR/file1" | _filter_test_dir
66 md5sum "$TESTDIR/file2" | _filter_test_dir
67 md5sum "$TESTDIR/file2.chk" | _filter_test_dir
69 C1="$(_md5_checksum "$TESTDIR/file1")"
70 C2="$(_md5_checksum "$TESTDIR/file2")"
72 test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
74 echo "Compare against check files"
75 cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match"
77 echo "Make the original file almost dedup-able"
78 _pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full"
79 _pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file2" >> "$seqres.full"
80 _pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file2.chk" >> "$seqres.full"
81 _dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full"
84 md5sum "$TESTDIR/file1" | _filter_test_dir
85 md5sum "$TESTDIR/file2" | _filter_test_dir
86 md5sum "$TESTDIR/file2.chk" | _filter_test_dir
88 C1="$(_md5_checksum "$TESTDIR/file1")"
89 C2="$(_md5_checksum "$TESTDIR/file2")"
91 test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
93 echo "Compare against check files"
94 cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match"
96 echo "Make the original file dedup-able"
97 _pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full"
98 _pwrite_byte 0x61 0 $((BLKSZ * 257)) "$TESTDIR/file2" >> "$seqres.full"
99 _pwrite_byte 0x61 0 $((BLKSZ * 257)) "$TESTDIR/file2.chk" >> "$seqres.full"
100 _dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full"
103 md5sum "$TESTDIR/file1" | _filter_test_dir
104 md5sum "$TESTDIR/file2" | _filter_test_dir
105 md5sum "$TESTDIR/file2.chk" | _filter_test_dir
107 C1="$(_md5_checksum "$TESTDIR/file1")"
108 C2="$(_md5_checksum "$TESTDIR/file2")"
110 test "${C1}" = "${C2}" || echo "file1 and file2 should match"
112 echo "Compare against check files"
113 cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match"