fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 296
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 296
6 #
7 # - Create two reflinked files a byte longer than a block.
8 # - Rewrite the whole file.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_scratch_reflink
33 _require_cp_reflink
34
35 rm -f $seqres.full
36
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
40
41 testdir=$SCRATCH_MNT/test-$seq
42 mkdir $testdir
43
44 blksz=65536
45 nr=128
46 filesize=$((blksz * nr))
47 bufnr=16
48 bufsize=$((blksz * bufnr))
49
50 real_blksz=$(_get_block_size "$testdir")
51 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
52
53 echo "Create the original files"
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
56 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file2.chk >> $seqres.full
57 _scratch_cycle_mount
58
59 echo "Compare files"
60 md5sum $testdir/file1 | _filter_scratch
61 md5sum $testdir/file2 | _filter_scratch
62 md5sum $testdir/file2.chk | _filter_scratch
63
64 echo "CoW and unmount"
65 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file2 >> $seqres.full
66 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file2.chk >> $seqres.full
67 _scratch_cycle_mount
68
69 echo "Compare files"
70 md5sum $testdir/file1 | _filter_scratch
71 md5sum $testdir/file2 | _filter_scratch
72 md5sum $testdir/file2.chk | _filter_scratch
73
74 # success, all done
75 status=0
76 exit