2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that we can reflink parts of two identical files:
8 # - Reflink identical parts of two identical files
9 # - Check that we still have identical contents
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
23 rm -rf $tmp.* $testdir
26 # get standard environment, filters and checks
31 # real QA test starts here
36 testdir=$TEST_DIR/test-$seq
40 echo "Create the original files"
42 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
43 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
46 md5sum $testdir/file1 | _filter_test_dir
47 md5sum $testdir/file2 | _filter_test_dir
49 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
50 || echo "Files do not match"
52 echo "Reflink the middle blocks together"
53 free_before=$(stat -f -c '%a' $testdir)
54 _reflink_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
55 $((blksz * 4)) $((blksz * 2)) >> $seqres.full
57 free_after=$(stat -f -c '%a' $testdir)
58 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
60 echo "Compare sections"
61 md5sum $testdir/file1 | _filter_test_dir
62 md5sum $testdir/file2 | _filter_test_dir
64 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
65 || echo "Start sections do not match"
67 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
68 $((blksz * 4)) $((blksz * 2)) \
69 || echo "Middle sections do not match"
71 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
72 $((blksz * 6)) $((blksz * 2)) \
73 || echo "End sections do not match"