dc9a91a4388879939f14603591d1ac5c0ff4d752
[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 . ./common/preamble
10 _begin_fstest auto quick clone swap
11
12 _register_cleanup "_cleanup" BUS
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17         cd /
18         rm -rf $tmp.*
19         wait
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _require_scratch_swapfile
28 _require_scratch_reflink
29 _require_cp_reflink
30
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
33 _scratch_mount >> $seqres.full 2>&1
34
35 testdir=$SCRATCH_MNT/test-$seq
36 mkdir $testdir
37
38 blocks=160
39 blksz=65536
40
41 echo "Initialize file"
42 _format_swapfile "$testdir/file1" $((blocks * blksz))
43 touch "$testdir/file2"
44 $CHATTR_PROG +C "$testdir/file2" >/dev/null 2>&1
45 _cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
46
47 echo "Try to swapon"
48 swapon $testdir/file1 2>&1 | _filter_scratch
49
50 swapoff $testdir/file1 >> $seqres.full 2>&1
51
52 # success, all done
53 status=0
54 exit