2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that unaligned zero-range steps around reflinked ranges:
8 # - Create a reflink clone of a file
9 # - Perform an unaligned zero-range in the middle of the file.
10 # - Check that the reflinked areas are still there.
13 _begin_fstest auto quick clone zero
15 # Override the default cleanup function.
19 rm -rf $tmp.* $testdir
22 # Import common functions.
26 # real QA test starts here
29 _require_xfs_io_command "fzero"
31 testdir=$TEST_DIR/test-$seq
35 echo "Create the original files"
37 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file1 >> $seqres.full
39 _cp_reflink $testdir/file1 $testdir/file2
41 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file2.chk >> $seqres.full
42 _pwrite_byte 0x00 $((blksz - 17)) $((blksz + 17)) $testdir/file2.chk >> $seqres.full
45 md5sum $testdir/file1 | _filter_test_dir
46 md5sum $testdir/file2 | _filter_test_dir
47 md5sum $testdir/file2.chk | _filter_test_dir
49 c1=$(_md5_checksum $testdir/file1)
50 c2=$(_md5_checksum $testdir/file2)
52 test ${c1} = ${c2} || echo "file1 and file2 should match"
55 $XFS_IO_PROG -f -c "fzero $((blksz - 17)) $((blksz + 17))" $testdir/file2
59 md5sum $testdir/file1 | _filter_test_dir
60 md5sum $testdir/file2 | _filter_test_dir
61 md5sum $testdir/file2.chk | _filter_test_dir
63 c1=$(_md5_checksum $testdir/file1)
64 c2=$(_md5_checksum $testdir/file2)
66 test ${c1} != ${c2} || echo "file1 and file2 should not match"
68 echo "Compare against check files"
69 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"