fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 143
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. 143
6 #
7 # Ensure that reflinking a file N times and DIO CoWing the copies leaves the
8 # original intact.
9 #   - Create a file and record its hash
10 #   - Create some reflink copies
11 #   - Rewrite all the reflink copies w/ directio
12 #   - Compare the contents of the original file
13 #
14 . ./common/preamble
15 _begin_fstest auto quick clone
16
17 # Override the default cleanup function.
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $testdir
22 }
23
24 # Import common functions.
25 . ./common/filter
26 . ./common/reflink
27
28 # real QA test starts here
29 _require_test_reflink
30 _require_cp_reflink
31 _require_odirect
32
33 testdir=$TEST_DIR/test-$seq
34 rm -rf $testdir
35 mkdir $testdir
36
37 echo "Create the original file blocks"
38 blksz=65536
39 nr=9
40 filesize=$((blksz * nr))
41 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
42 _test_cycle_mount
43
44 md5sum $testdir/file1 | _filter_test_dir
45 csum=$(_md5_checksum $testdir/file1)
46
47 echo "Create the reflink copies"
48 seq 2 $nr | while read i; do
49         _cp_reflink $testdir/file1 $testdir/file$i
50 done
51 _test_cycle_mount
52
53 echo "Rewrite the copies"
54 seq 2 $nr | while read i; do
55         _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file$i -d >> $seqres.full
56 done
57 _test_cycle_mount
58
59 echo "Examine original file"
60 md5sum $testdir/file1 | _filter_test_dir
61 md5sum $testdir/file2 | _filter_test_dir
62
63 mod_csum=$(_md5_checksum $testdir/file2)
64 new_csum=$(_md5_checksum $testdir/file1)
65 test ${csum} != ${mod_csum} || echo "checksums do not match"
66 test ${csum} = ${new_csum} || echo "checksums do not match"
67
68 # success, all done
69 status=0
70 exit