generic/563: use a loop device to avoid partition incompatibility
[xfstests-dev.git] / tests / btrfs / 173
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 173
6 #
7 # Test swap file activation restrictions specific to Btrfs, swap file can't be
8 # CoW file nor compressed 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 -f $tmp.*
23 }
24
25 . ./common/rc
26 . ./common/filter
27
28 rm -f $seqres.full
29
30 _supported_fs btrfs
31 _require_scratch_swapfile
32
33 _scratch_mkfs >> $seqres.full 2>&1
34 _scratch_mount
35
36 echo "COW file"
37 # We can't use _format_swapfile because we don't want chattr +C, and we can't
38 # unset it after the swap file has been created.
39 rm -f "$SCRATCH_MNT/swap"
40 touch "$SCRATCH_MNT/swap"
41 chmod 0600 "$SCRATCH_MNT/swap"
42 _pwrite_byte 0x61 0 $(($(get_page_size) * 10)) "$SCRATCH_MNT/swap" >> $seqres.full
43 $MKSWAP_PROG "$SCRATCH_MNT/swap" >> $seqres.full
44 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
45 swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
46
47 echo "Compressed file"
48 rm -f "$SCRATCH_MNT/swap"
49 _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
50 $CHATTR_PROG +c "$SCRATCH_MNT/swap" 2>&1 | grep -o "Invalid argument while setting flags"
51
52 status=0
53 exit