misc: move exit status into trap handler
[xfstests-dev.git] / tests / xfs / 111
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 111
6 #
7 # Infinite xfs_bulkstat bad-inode loop case from Roger Willcocks.
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 "rm -f $tmp.*; exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs xfs
24 _require_scratch
25
26 rm -f $seqres.full
27
28 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
29
30 # real QA test starts here
31 _scratch_unmount 2>/dev/null
32 MKFS_OPTIONS="-bsize=4096"
33 MOUNT_OPTIONS="-o noatime"
34 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
35 _scratch_mount
36
37 echo Create some files
38 I=0
39 while [ $I -lt 1000 ]
40 do
41     $XFS_IO_PROG -f -c "pwrite 0 512" $SCRATCH_MNT/${I} > /dev/null
42     let I=$I+1
43 done
44
45 # Roughly the middle of the created inodes
46 INO=`ls -i $SCRATCH_MNT/512 | awk '{print $1}'`
47 _scratch_unmount
48
49 # Figure out where that middle inode starts
50 BYTE=`_scratch_xfs_db -c "convert inode $INO byte" \
51         | awk '{print $2}' | sed s/[\(\)]//g`
52
53 echo Blat inode clusters
54 $here/src/itrash $SCRATCH_DEV $BYTE
55
56 _try_scratch_mount || _fail "Couldn't mount after itrash"
57
58 echo Attempting bulkstat
59 #$here/src/bstat -q $SCRATCH_MNT
60 $XFS_FSR_PROG -g $SCRATCH_MNT | _filter_scratch
61
62 # Fix up intentional corruption so test can pass
63 _scratch_unmount
64 _scratch_xfs_repair >> $seqres.full 2>&1
65
66 status=0
67 exit