fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 357
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. 357
6 #
7 # Check that we can't swapon a reflinked file.
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 touch "$testdir/file2"
49 $CHATTR_PROG +C "$testdir/file2" >/dev/null 2>&1
50 _cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
51
52 echo "Try to swapon"
53 swapon $testdir/file1 2>&1 | _filter_scratch
54
55 swapoff $testdir/file1 >> $seqres.full 2>&1
56
57 # success, all done
58 status=0
59 exit