generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 116
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 116
6 #
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
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1    # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -rf $tmp.* $testdir
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30
31 # real QA test starts here
32 _supported_os Linux
33 _require_test_reflink
34
35 rm -f $seqres.full
36
37 testdir=$TEST_DIR/test-$seq
38 rm -rf $testdir
39 mkdir $testdir
40
41 echo "Create the original files"
42 blksz=65536
43 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file1 >> $seqres.full
44 _pwrite_byte 0x61 $((blksz * 2)) $((blksz * 6)) $testdir/file2 >> $seqres.full
45 _test_cycle_mount
46
47 md5sum $testdir/file1 | _filter_test_dir
48 md5sum $testdir/file2 | _filter_test_dir
49
50 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 8)) \
51        || echo "Files do not match"
52
53 echo "Reflink the middle blocks together"
54 free_before=$(stat -f -c '%a' $testdir)
55 _reflink_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
56                 $((blksz * 4)) $((blksz * 2)) >> $seqres.full
57 _test_cycle_mount
58 free_after=$(stat -f -c '%a' $testdir)
59 echo "freesp changed by $free_before -> $free_after" >> $seqres.full
60
61 echo "Compare sections"
62 md5sum $testdir/file1 | _filter_test_dir
63 md5sum $testdir/file2 | _filter_test_dir
64
65 _compare_range $testdir/file1 0 $testdir/file2 0 $((blksz * 4)) \
66        || echo "Start sections do not match"
67
68 _compare_range $testdir/file1 $((blksz * 4)) $testdir/file2 \
69                 $((blksz * 4)) $((blksz * 2)) \
70        || echo "Middle sections do not match"
71
72 _compare_range $testdir/file1 $((blksz * 6)) $testdir/file2 \
73                 $((blksz * 6)) $((blksz * 2)) \
74        || echo "End sections do not match"
75
76 # success, all done
77 status=0
78 exit