common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 356
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 356
6 #
7 # Check that we can't reflink a swapfile.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 7 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf $tmp.*
22         wait
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_swapfile
33 _require_scratch_reflink
34 _require_cp_reflink
35
36 echo "Format and mount"
37 _scratch_mkfs > $seqres.full 2>&1
38 _scratch_mount >> $seqres.full 2>&1
39
40 testdir=$SCRATCH_MNT/test-$seq
41 mkdir $testdir
42
43 blocks=160
44 blksz=65536
45
46 echo "Initialize file"
47 _format_swapfile "$testdir/file1" $((blocks * blksz))
48 swapon $testdir/file1
49
50 touch "$testdir/file2"
51 $CHATTR_PROG +C "$testdir/file2" >/dev/null 2>&1
52
53 echo "Try to reflink"
54 _cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
55
56 echo "Tear it down"
57 swapoff $testdir/file1
58
59 # success, all done
60 status=0
61 exit