10cf71afdf48f2e53753a6661719c160ef3922b1
[xfstests-dev.git] / tests / generic / 236
1 #! /bin/bash
2 # FS QA Test No. 236
3 #
4 # Check ctime updated or not if file linked
5 # See also http://marc.info/?l=linux-btrfs&m=127434439020230&w=2
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2010 FUJITSU LIMITED. All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 _cleanup()
31 {
32         rm -f $TEST_DIR/ouch*
33 }
34
35 here=`pwd`
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 # get standard environment, filters and checks
40 . ./common/rc
41
42 # real QA test starts here
43 _supported_fs generic
44 # only Linux supports fallocate
45 _supported_os Linux
46
47 rm -f $TEST_DIR/ouch*
48
49 # create a file and get its ctime
50 touch $TEST_DIR/ouch
51 ctime=`stat -c %Z $TEST_DIR/ouch`
52 sleep 1
53
54 # create a link to a file and get existing file's ctime
55 link $TEST_DIR/ouch $TEST_DIR/ouch2
56 ctime2=`stat -c %Z $TEST_DIR/ouch`
57
58 # check ctime updated
59 if [ $ctime2 -le $ctime ]; then
60         echo "ctime: $ctime -> $ctime2 "
61         echo "Fatal error: ctime not updated after link"
62         _cleanup
63         exit 1
64 fi
65
66 echo "Test over."
67 # success, all done
68 status=0
69 exit