4 # Ensure that zero-range steps around reflinked ranges:
5 # - Create three reflink clones of a file
6 # - Zero-range the start, middle, and end of the reflink range of each
7 # of the three files, respectively
8 # - Check that the reflinked areas are still there.
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
28 seqres="$RESULT_DIR/$seq"
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
39 rm -rf "$tmp".* "$TESTDIR"
42 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_xfs_io_command "fzero"
55 TESTDIR="$TEST_DIR/test-$seq"
59 echo "Create the original files"
61 _pwrite_byte 0x61 0 $BLKSZ "$TESTDIR/file1" >> "$seqres.full"
62 _pwrite_byte 0x62 $BLKSZ $BLKSZ "$TESTDIR/file1" >> "$seqres.full"
63 _pwrite_byte 0x63 $((BLKSZ * 2)) $BLKSZ "$TESTDIR/file1" >> "$seqres.full"
65 _cp_reflink "$TESTDIR/file1" "$TESTDIR/file2"
66 _cp_reflink "$TESTDIR/file1" "$TESTDIR/file3"
67 _cp_reflink "$TESTDIR/file1" "$TESTDIR/file4"
69 _pwrite_byte 0x00 0 $BLKSZ "$TESTDIR/file2.chk" >> "$seqres.full"
70 _pwrite_byte 0x62 $BLKSZ $BLKSZ "$TESTDIR/file2.chk" >> "$seqres.full"
71 _pwrite_byte 0x63 $((BLKSZ * 2)) $BLKSZ "$TESTDIR/file2.chk" >> "$seqres.full"
73 _pwrite_byte 0x61 0 $BLKSZ "$TESTDIR/file3.chk" >> "$seqres.full"
74 _pwrite_byte 0x00 $BLKSZ $BLKSZ "$TESTDIR/file3.chk" >> "$seqres.full"
75 _pwrite_byte 0x63 $((BLKSZ * 2)) $BLKSZ "$TESTDIR/file3.chk" >> "$seqres.full"
77 _pwrite_byte 0x61 0 $BLKSZ "$TESTDIR/file4.chk" >> "$seqres.full"
78 _pwrite_byte 0x62 $BLKSZ $BLKSZ "$TESTDIR/file4.chk" >> "$seqres.full"
79 _pwrite_byte 0x00 $((BLKSZ * 2)) $BLKSZ "$TESTDIR/file4.chk" >> "$seqres.full"
82 md5sum "$TESTDIR/file1" | _filter_test_dir
83 md5sum "$TESTDIR/file2" | _filter_test_dir
84 md5sum "$TESTDIR/file3" | _filter_test_dir
85 md5sum "$TESTDIR/file4" | _filter_test_dir
86 md5sum "$TESTDIR/file2.chk" | _filter_test_dir
87 md5sum "$TESTDIR/file3.chk" | _filter_test_dir
88 md5sum "$TESTDIR/file4.chk" | _filter_test_dir
90 C1="$(_md5_checksum "$TESTDIR/file1")"
91 C2="$(_md5_checksum "$TESTDIR/file2")"
92 C3="$(_md5_checksum "$TESTDIR/file3")"
93 C4="$(_md5_checksum "$TESTDIR/file4")"
95 test "${C1}" = "${C2}" || echo "file1 and file2 should match"
96 test "${C1}" = "${C3}" || echo "file1 and file3 should match"
97 test "${C1}" = "${C4}" || echo "file1 and file4 should match"
98 test "${C2}" = "${C3}" || echo "file2 and file3 should match"
99 test "${C2}" = "${C4}" || echo "file2 and file4 should match"
100 test "${C3}" = "${C4}" || echo "file3 and file4 should match"
103 "$XFS_IO_PROG" -f -c "fzero 0 $BLKSZ" "$TESTDIR/file2"
104 "$XFS_IO_PROG" -f -c "fzero $BLKSZ $BLKSZ" "$TESTDIR/file3"
105 "$XFS_IO_PROG" -f -c "fzero $((BLKSZ * 2)) $BLKSZ" "$TESTDIR/file4"
109 md5sum "$TESTDIR/file1" | _filter_test_dir
110 md5sum "$TESTDIR/file2" | _filter_test_dir
111 md5sum "$TESTDIR/file3" | _filter_test_dir
112 md5sum "$TESTDIR/file4" | _filter_test_dir
113 md5sum "$TESTDIR/file2.chk" | _filter_test_dir
114 md5sum "$TESTDIR/file3.chk" | _filter_test_dir
115 md5sum "$TESTDIR/file4.chk" | _filter_test_dir
117 C1="$(_md5_checksum "$TESTDIR/file1")"
118 C2="$(_md5_checksum "$TESTDIR/file2")"
119 C3="$(_md5_checksum "$TESTDIR/file3")"
120 C4="$(_md5_checksum "$TESTDIR/file4")"
122 test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
123 test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
124 test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
125 test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
126 test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
127 test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
129 echo "Compare against check files"
130 cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match"
131 cmp -s "$TESTDIR/file3" "$TESTDIR/file3.chk" || echo "file3 and file3.chk do not match"
132 cmp -s "$TESTDIR/file4" "$TESTDIR/file4.chk" || echo "file4 and file4.chk do not match"