xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 495
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 495
6 #
7 # Test invalid swap files.
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 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 _supported_fs generic
32 _supported_os Linux
33 _require_scratch_swapfile
34 _require_test_program mkswap
35 _require_test_program swapon
36
37 _scratch_mkfs >> $seqres.full 2>&1
38 _scratch_mount
39
40 echo "File with holes"
41 # We can't use _format_swapfile because we're using our custom mkswap and
42 # swapon.
43 touch "$SCRATCH_MNT/swap"
44 $CHATTR_PROG +C "$SCRATCH_MNT/swap" >> $seqres.full 2>&1
45 chmod 0600 "$SCRATCH_MNT/swap"
46 $XFS_IO_PROG -c "truncate $(($(get_page_size) * 10))" "$SCRATCH_MNT/swap"
47 "$here/src/mkswap" "$SCRATCH_MNT/swap"
48 "$here/src/swapon" "$SCRATCH_MNT/swap"
49 swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
50
51 echo "Empty swap file (only swap header)"
52 rm -f "$SCRATCH_MNT/swap"
53 touch "$SCRATCH_MNT/swap"
54 $CHATTR_PROG +C "$SCRATCH_MNT/swap" >> $seqres.full 2>&1
55 chmod 0600 "$SCRATCH_MNT/swap"
56 _pwrite_byte 0x61 0 $(get_page_size) "$SCRATCH_MNT/swap" >> $seqres.full
57 "$here/src/mkswap" "$SCRATCH_MNT/swap"
58 "$here/src/swapon" "$SCRATCH_MNT/swap"
59 swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
60
61 status=0
62 exit