misc: move exit status into trap handler
[xfstests-dev.git] / tests / generic / 405
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 405
6 #
7 # Test mkfs against thin provision device, which has very small backing size,
8 # mkfs should return error when it hits EIO.
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 # Initialize dmthin device with very small backing size & very big virtual
20 # size, with the hope that mkfs hit EIO at mkfs time
21 BACKING_SIZE=$((1 * 1024 * 1024 / 512))                 # 1M
22 VIRTUAL_SIZE=$((1 * 1024 * 1024 * 1024 * 1024 / 512))   # 1T
23
24 _cleanup()
25 {
26         _dmthin_cleanup
27         cd /
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34 . ./common/dmthin
35
36 # remove previous $seqres.full before test
37 rm -f $seqres.full
38
39 # real QA test starts here
40 _supported_fs generic
41 # $SCRATCH_DEV won't be directly created filesystem on, so fsck isn't required
42 _require_scratch_nocheck
43 _require_dm_target thin-pool
44
45 _dmthin_init $BACKING_SIZE $VIRTUAL_SIZE
46
47 # try mkfs on dmthin device, expect mkfs failure if 1M isn't big enough to hold
48 # all the metadata. But if mkfs returns success, we expect the filesystem is
49 # consistent, make sure it doesn't currupt silently.
50 $MKFS_PROG -t $FSTYP $DMTHIN_VOL_DEV >>$seqres.full 2>&1
51 if [ $? -eq 0 ]; then
52         _dmthin_check_fs
53 fi
54
55 echo "Silence is golden"
56 status=0
57 exit