misc: move exit status into trap handler
[xfstests-dev.git] / tests / generic / 236
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 FUJITSU LIMITED. All Rights Reserved.
4 #
5 # FS QA Test No. 236
6 #
7 # Check ctime updated or not if file linked
8 # See also http://marc.info/?l=linux-btrfs&m=127434439020230&w=2
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 _cleanup()
15 {
16         rm -f $TEST_DIR/ouch*
17 }
18
19 here=`pwd`
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 # get standard environment, filters and checks
24 . ./common/rc
25
26 # real QA test starts here
27 _supported_fs generic
28 _require_hardlinks
29 _require_test
30
31 rm -f $TEST_DIR/ouch*
32
33 # create a file and get its ctime
34 touch $TEST_DIR/ouch
35 ctime=`stat -c %Z $TEST_DIR/ouch`
36 sleep 1
37
38 # create a link to a file and get existing file's ctime
39 link $TEST_DIR/ouch $TEST_DIR/ouch2
40 ctime2=`stat -c %Z $TEST_DIR/ouch`
41
42 # check ctime updated
43 if [ $ctime2 -le $ctime ]; then
44         echo "ctime: $ctime -> $ctime2 "
45         echo "Fatal error: ctime not updated after link"
46         _cleanup
47         exit 1
48 fi
49
50 echo "Test over."
51 # success, all done
52 status=0
53 exit