fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 217
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. 217
6 #
7 # See what happens if we DIO CoW blocks 2-4 of a page's worth of blocks when
8 # the second block is a unwritten block.
9 #
10 # This test is dependent on the system page size, so we cannot use md5 in
11 # the golden output; we can only compare to a check file.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     cd /
25     rm -rf $tmp.* $testdir
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/reflink
32
33 # real QA test starts here
34 _supported_os Linux
35 _require_scratch_reflink
36 _require_xfs_io_command "falloc"
37 _require_odirect
38
39 rm -f $seqres.full
40
41 pagesz=$(getconf PAGE_SIZE)
42 blksz=$((pagesz / 4))
43
44 echo "Format and mount"
45 _scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
46 _scratch_mount >> $seqres.full 2>&1
47
48 testdir=$SCRATCH_MNT/test-$seq
49 mkdir $testdir
50
51 real_blksz=$(_get_file_block_size $testdir)
52 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
53
54 echo "Create the original files"
55 _pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
56
57 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
58 $XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
59
60 $XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $testdir/file2 >> $seqres.full
61 _pwrite_byte 0x00 $blksz $blksz $testdir/file2.chk >> $seqres.full
62
63 $XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
64 _pwrite_byte 0x00 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
65
66 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
67 _pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
68 _scratch_cycle_mount
69
70 echo "Compare files"
71 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
72 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
73
74 echo "CoW and unmount"
75 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 $blksz $((blksz * 3))" $testdir/file2 >> $seqres.full
76 $XFS_IO_PROG -f -c "pwrite -S 0x63 $blksz $((blksz * 3))" $testdir/file2.chk >> $seqres.full
77 _scratch_cycle_mount
78
79 echo "Compare files"
80 ! cmp -s $testdir/file1 $testdir/file2 || _fail "file1 and file2 don't match."
81 cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
82
83 # success, all done
84 status=0
85 exit