xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 419
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 419
6 #
7 # Check that we can't swapon a realtime 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 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_os Linux
30 _supported_fs xfs
31 _require_realtime
32 _require_scratch_swapfile
33
34 echo "Format and mount"
35 _scratch_mkfs > $seqres.full 2>&1
36 _scratch_mount >> $seqres.full 2>&1
37
38 testdir=$SCRATCH_MNT/test-$seq
39 mkdir $testdir
40
41 blocks=160
42 blksz=65536
43
44 echo "Initialize file"
45 echo >> $seqres.full
46 $XFS_IO_PROG -c "open -f -R $testdir/dummy" $testdir >> $seqres.full
47 echo moo >> $testdir/dummy
48 $XFS_IO_PROG -c "open -f -R $testdir/file1" $testdir >> $seqres.full
49 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full
50 mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full
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