cbaf3071e1f456e9048b8ce0389804fa59d2fcda
[xfstests-dev.git] / tests / generic / 309
1 #! /bin/bash
2 # FS QA Test No. 309
3 #
4 # Test directory mtime and ctime are updated when moving a file onto an
5 # existing file in the directory
6 #
7 # Regression test for commit:
8 # 0b23076 ext3: fix update of mtime and ctime on rename
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 status=0        # success is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -rf $TEST_DIR/testdir_$seq
39     rm -f $TEST_DIR/testfile.$seq
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # real QA test starts here
47 _supported_fs generic
48 _supported_os IRIX Linux
49
50 echo "Silence is golden"
51
52 mkdir -p $TEST_DIR/testdir_$seq
53 touch $TEST_DIR/testdir_$seq/testfile
54 touch $TEST_DIR/testfile.$seq
55
56 mtime1=`stat -c %Y $TEST_DIR/testdir_$seq`
57 ctime1=`stat -c %Z $TEST_DIR/testdir_$seq`
58
59 sleep 1
60 mv $TEST_DIR/testfile.$seq $TEST_DIR/testdir_$seq/testfile
61
62 mtime2=`stat -c %Y $TEST_DIR/testdir_$seq`
63 ctime2=`stat -c %Z $TEST_DIR/testdir_$seq`
64
65 if [ "$mtime1" == "$mtime2" ]; then
66         echo "mtime not updated"
67         let status=$status+1
68 fi
69 if [ "$ctime1" == "$ctime2" ]; then
70         echo "ctime not updated"
71         let status=$status+1
72 fi
73
74 exit