misc: move exit status into trap handler
[xfstests-dev.git] / tests / generic / 406
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Liu Bo.  All Rights Reserved.
4 #
5 # FS QA Test generic/406
6 #
7 # If a larger dio write (size >= 128M) got splitted, the assertion in endio
8 # would complain (CONFIG_BTRFS_ASSERT is required).
9 #
10 # Regression test for
11 #   Btrfs: adjust outstanding_extents counter properly when dio write is split
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # remove previous $seqres.full before test
33 rm -f $seqres.full
34
35 # real QA test starts here
36
37 # Modify as appropriate.
38 _supported_fs generic
39 _require_scratch
40 _require_odirect
41
42 _scratch_mkfs >> $seqres.full 2>&1
43 _scratch_mount
44
45 # 2G / 1K
46 blocksize=$(( (128 + 1) * 2 * 1024 * 1024))
47 fsblock=$(( (128 + 1) * 2 * 1024))
48 _require_fs_space $SCRATCH_MNT $fsblock
49
50 echo "Silence is golden"
51
52 $XFS_IO_PROG -f -d -c "pwrite -b ${blocksize} 0 ${blocksize}" $SCRATCH_MNT/testfile.$seq >> $seqres.full 2>&1
53
54 _scratch_unmount
55
56 # success, all done
57 status=0
58 exit