misc: move exit status into trap handler
[xfstests-dev.git] / tests / generic / 370
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 370
6 #
7 # RichACL write-vs-append test
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
27 # remove previous $seqres.full before test
28 rm -f $seqres.full
29
30 # real QA test starts here
31
32 _supported_fs generic
33
34 _require_scratch
35 _require_scratch_richacl
36 _require_richacl_prog
37 _require_runas
38
39 _scratch_mkfs_richacl >> $seqres.full
40 _scratch_mount
41
42 cd $SCRATCH_MNT
43
44 r()
45 {
46         echo "--- runas -u 99 -g 99 $*"
47         _runas -u 99 -g 99 -- "$@"
48 }
49
50 touch a b c d e f
51 $SETRICHACL_PROG --set 'owner@:rwp::allow' a
52 $SETRICHACL_PROG --set 'owner@:rwp::allow u:99:w::allow' b
53 $SETRICHACL_PROG --set 'owner@:rwp::allow u:99:p::allow' c
54 $SETRICHACL_PROG --set 'owner@:rwp::allow u:99:wp::allow' d
55 $SETRICHACL_PROG --set 'u:99:a::deny owner@:rwp::allow u:99:w::allow' e
56 $SETRICHACL_PROG --set 'u:99:w::deny owner@:rwp::allow u:99:p::allow' f
57
58 r sh -c 'echo a > a'
59 r sh -c 'echo b > b'
60 r sh -c 'echo c > c'
61 r sh -c 'echo d > d'
62 r sh -c 'echo e > e'
63 r sh -c 'echo f > f'
64
65 r sh -c 'echo A >> a'
66 r sh -c 'echo B >> b'
67 r sh -c 'echo C >> c'
68 r sh -c 'echo D >> d'
69 r sh -c 'echo E >> e'
70 r sh -c 'echo F >> f'
71
72 # success, all done
73 status=0
74 exit