fsx/fsstress: round blocksize properly
[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 file (with holes)
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 _require_scratch_swapfile
33 _require_test_program mkswap
34 _require_test_program swapon
35 _require_sparse_files
36
37 _scratch_mkfs >> $seqres.full 2>&1
38 _scratch_mount
39
40 # We can't use _format_swapfile because we're using our custom mkswap and
41 # swapon.
42 touch "$SCRATCH_MNT/swap"
43 $CHATTR_PROG +C "$SCRATCH_MNT/swap" >> $seqres.full 2>&1
44 chmod 0600 "$SCRATCH_MNT/swap"
45 $XFS_IO_PROG -c "truncate $(($(get_page_size) * 10))" "$SCRATCH_MNT/swap"
46 "$here/src/mkswap" "$SCRATCH_MNT/swap"
47 "$here/src/swapon" "$SCRATCH_MNT/swap"
48 swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
49
50 status=0
51 exit