misc: move exit status into trap handler
[xfstests-dev.git] / tests / xfs / 303
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Oracle Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 303
6 #
7 # Test to verify xfs_quota(8) administrator commands can deal with invalid
8 # storage mount point without NULL pointer dereference problem.
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 _cleanup()
20 {
21     cd /
22     rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs xfs
31
32 echo "Silence is golden"
33
34 # To run this sanity check we don't need to enable quota function
35 # nor need a scratch device as quota tool will get the mount path
36 # at first.
37 # An non-existent xfs mount point
38 INVALID_PATH="/INVALID_XFS_MOUNT_POINT"
39
40 xfs_quota -x -c 'report -a' $INVALID_PATH       2>/dev/null
41 xfs_quota -x -c 'state -a' $INVALID_PATH        2>/dev/null
42 xfs_quota -x -c 'free -h' $INVALID_PATH         2>/dev/null
43 xfs_quota -x -c 'quot -v' $INVALID_PATH         2>/dev/null
44 xfs_quota -x -c 'remove' $INALID_PATH           2>/dev/null
45 xfs_quota -x -c 'disable' $INVALID_PATH         2>/dev/null
46 xfs_quota -x -c 'enable' $INVALID_PATH          2>/dev/null
47
48 # success, all done
49 status=0
50 exit