fstests: use _require_symlinks on all necessary tests
[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 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1    # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25     cd /
26     rm -rf $tmp.* $testdir
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/reflink
33
34 # real QA test starts here
35 _supported_os Linux
36 _require_test_reflink
37 _require_cp_reflink
38 _require_odirect
39
40 rm -f $seqres.full
41
42 testdir=$TEST_DIR/test-$seq
43 rm -rf $testdir
44 mkdir $testdir
45
46 echo "Create the original file blocks"
47 blksz=65536
48 nr=9
49 filesize=$((blksz * nr))
50 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
51 _test_cycle_mount
52
53 md5sum $testdir/file1 | _filter_test_dir
54 csum=$(_md5_checksum $testdir/file1)
55
56 echo "Create the reflink copies"
57 seq 2 $nr | while read i; do
58         _cp_reflink $testdir/file1 $testdir/file$i
59 done
60 _test_cycle_mount
61
62 echo "Rewrite the copies"
63 seq 2 $nr | while read i; do
64         _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file$i -d >> $seqres.full
65 done
66 _test_cycle_mount
67
68 echo "Examine original file"
69 md5sum $testdir/file1 | _filter_test_dir
70 md5sum $testdir/file2 | _filter_test_dir
71
72 mod_csum=$(_md5_checksum $testdir/file2)
73 new_csum=$(_md5_checksum $testdir/file1)
74 test ${csum} != ${mod_csum} || echo "checksums do not match"
75 test ${csum} = ${new_csum} || echo "checksums do not match"
76
77 # success, all done
78 status=0
79 exit