2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that reflinking a file N times and CoWing the copies leaves the
9 # - Create a file and record its hash
10 # - Create some reflink copies
11 # - Rewrite all the reflink copies
12 # - Compare the contents of the original file
15 _begin_fstest auto quick clone
17 # Override the default cleanup function.
21 rm -rf $tmp.* $testdir
24 # Import common functions.
28 # real QA test starts here
32 testdir=$TEST_DIR/test-$seq
36 echo "Create the original file blocks"
39 filesize=$((blksz * nr))
40 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
43 md5sum $testdir/file1 | _filter_test_dir
44 csum=$(_md5_checksum $testdir/file1)
46 echo "Create the reflink copies"
47 seq 2 $nr | while read i; do
48 _cp_reflink $testdir/file1 $testdir/file$i
52 echo "Rewrite the copies"
53 seq 2 $nr | while read i; do
54 _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file$i >> $seqres.full
58 echo "Examine original file"
59 md5sum $testdir/file1 | _filter_test_dir
60 md5sum $testdir/file2 | _filter_test_dir
62 mod_csum=$(_md5_checksum $testdir/file2)
63 new_csum=$(_md5_checksum $testdir/file1)
64 test ${csum} != ${mod_csum} || echo "checksums do not match"
65 test ${csum} = ${new_csum} || echo "checksums do not match"