misc: move exit status into trap handler
[xfstests-dev.git] / tests / generic / 307
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 307
6 #
7 # Check if ctime is updated and written to disk after setfacl
8 #
9 # Regression test for the following extN commits
10 # c6ac12a ext4: update ctime when changing the file's permission by setfacl
11 # 30e2bab ext3: update ctime when changing the file's permission by setfacl
12 # 523825b ext2: update ctime when changing the file's permission by setfacl
13 #
14 # Based on test 277
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $testfile
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/attr
33
34 testfile=$SCRATCH_MNT/testfile.$seq
35
36 # real QA test starts here
37 _supported_fs generic
38 _require_scratch
39 _require_acls
40
41 echo "Silence is golden"
42
43 _scratch_mkfs >/dev/null 2>&1
44 _scratch_mount >/dev/null 2>&1
45
46 touch $testfile
47 _scratch_cycle_mount
48 ctime1=`stat -c %Z $testfile`
49
50 sleep 1
51 setfacl -m 'u::x,g::x,o::x' $testfile
52 ctime2=`stat -c %Z $testfile`
53
54 _scratch_cycle_mount
55 ctime3=`stat -c %Z $testfile`
56
57 if [ "$ctime1" == "$ctime2" ]; then
58         echo "error: ctime not updated after setfacl"
59 elif [ "$ctime1" == "$ctime3" ]; then
60         echo "error: on disk ctime not updated"
61 else
62         status=0
63 fi
64
65 exit