fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 147
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. 812
6 #
7 # Ensure that insert range steps around reflinked ranges:
8 #   - Create three reflink clones of a file
9 #   - Insert into the start, middle, and end of the reflink range of each
10 #     of the three files, respectively
11 #   - Check that the reflinked areas are still there.
12 #
13 . ./common/preamble
14 _begin_fstest auto quick clone insert
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19     cd /
20     rm -rf $tmp.* $testdir
21 }
22
23 # Import common functions.
24 . ./common/filter
25 . ./common/reflink
26
27 # real QA test starts here
28 _require_test_reflink
29 _require_cp_reflink
30 _require_xfs_io_command "finsert"
31
32 testdir=$TEST_DIR/test-$seq
33 rm -rf $testdir
34 mkdir $testdir
35
36 echo "Create the original files"
37 blksz=65536
38 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
39 _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full
40 _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full
41
42 _cp_reflink $testdir/file1 $testdir/file2
43 _cp_reflink $testdir/file1 $testdir/file3
44 _cp_reflink $testdir/file1 $testdir/file4
45
46 _pwrite_byte 0x00 0 $blksz $testdir/file2.chk >> $seqres.full
47 _pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
48 _pwrite_byte 0x62 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
49 _pwrite_byte 0x63 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
50
51 _pwrite_byte 0x61 0 $blksz $testdir/file3.chk >> $seqres.full
52 _pwrite_byte 0x00 $blksz $blksz $testdir/file3.chk >> $seqres.full
53 _pwrite_byte 0x62 $((blksz * 2)) $blksz $testdir/file3.chk >> $seqres.full
54 _pwrite_byte 0x63 $((blksz * 3)) $blksz $testdir/file3.chk >> $seqres.full
55
56 _pwrite_byte 0x61 0 $blksz $testdir/file4.chk >> $seqres.full
57 _pwrite_byte 0x62 $blksz $blksz $testdir/file4.chk >> $seqres.full
58 _pwrite_byte 0x00 $((blksz * 2)) $blksz $testdir/file4.chk >> $seqres.full
59 _pwrite_byte 0x63 $((blksz * 3)) $blksz $testdir/file4.chk >> $seqres.full
60 _test_cycle_mount
61
62 md5sum $testdir/file1 | _filter_test_dir
63 md5sum $testdir/file2 | _filter_test_dir
64 md5sum $testdir/file3 | _filter_test_dir
65 md5sum $testdir/file4 | _filter_test_dir
66 md5sum $testdir/file2.chk | _filter_test_dir
67 md5sum $testdir/file3.chk | _filter_test_dir
68 md5sum $testdir/file4.chk | _filter_test_dir
69
70 c1=$(_md5_checksum $testdir/file1)
71 c2=$(_md5_checksum $testdir/file2)
72 c3=$(_md5_checksum $testdir/file3)
73 c4=$(_md5_checksum $testdir/file4)
74
75 test ${c1} = ${c2} || echo "file1 and file2 should match"
76 test ${c1} = ${c3} || echo "file1 and file3 should match"
77 test ${c1} = ${c4} || echo "file1 and file4 should match"
78 test ${c2} = ${c3} || echo "file2 and file3 should match"
79 test ${c2} = ${c4} || echo "file2 and file4 should match"
80 test ${c3} = ${c4} || echo "file3 and file4 should match"
81
82 echo "finsert files"
83 $XFS_IO_PROG -f -c "finsert 0 $blksz" $testdir/file2
84 $XFS_IO_PROG -f -c "finsert $blksz $blksz" $testdir/file3
85 $XFS_IO_PROG -f -c "finsert $((blksz * 2)) $blksz" $testdir/file4
86 _test_cycle_mount
87
88 echo "Compare files"
89 md5sum $testdir/file1 | _filter_test_dir
90 md5sum $testdir/file2 | _filter_test_dir
91 md5sum $testdir/file3 | _filter_test_dir
92 md5sum $testdir/file4 | _filter_test_dir
93 md5sum $testdir/file2.chk | _filter_test_dir
94 md5sum $testdir/file3.chk | _filter_test_dir
95 md5sum $testdir/file4.chk | _filter_test_dir
96
97 c1=$(_md5_checksum $testdir/file1)
98 c2=$(_md5_checksum $testdir/file2)
99 c3=$(_md5_checksum $testdir/file3)
100 c4=$(_md5_checksum $testdir/file4)
101
102 test ${c1} != ${c2} || echo "file1 and file2 should not match"
103 test ${c1} != ${c3} || echo "file1 and file3 should not match"
104 test ${c1} != ${c4} || echo "file1 and file4 should not match"
105 test ${c2} != ${c3} || echo "file2 and file3 should not match"
106 test ${c2} != ${c4} || echo "file2 and file4 should not match"
107 test ${c3} != ${c4} || echo "file3 and file4 should not match"
108
109 echo "Compare against check files"
110 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
111 cmp -s $testdir/file3 $testdir/file3.chk || echo "file3 and file3.chk do not match"
112 cmp -s $testdir/file4 $testdir/file4.chk || echo "file4 and file4.chk do not match"
113
114 # success, all done
115 status=0
116 exit