6ddd1fcffb0b75c3406eba89cd41ee20e9c3ed78
[xfstests-dev.git] / tests / generic / 215
1 #! /bin/bash
2 # FS QA Test No. 215
3 #
4 # Test out c/mtime updates after mapped writes.
5 #
6 # Based on the testcase in http://bugzilla.kernel.org/show_bug.cgi?id=2645
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2009 Christoph Hellwig.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 _cleanup()
31 {
32         cd /
33         rm -f $testfile
34 }
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os Linux
48 _require_test
49
50 testfile=$TEST_DIR/tst.mmap
51
52 echo
53 echo "creating test file"
54 dd if=/dev/zero of=$testfile count=4096
55
56 mtime1=`stat --printf="%Y" $testfile`
57 ctime1=`stat --printf="%Z" $testfile`
58
59 sleep 2
60
61 echo
62 echo "writing via mmap"
63 $XFS_IO_PROG -f                 \
64         -c 'mmap 0 4096'        \
65         -c 'mwrite 0 4096'      \
66         $testfile | _filter_xfs_io_unique
67
68 mtime2=`stat --printf="%Y" $testfile`
69 ctime2=`stat --printf="%Z" $testfile`
70
71 let mtime_diff=$mtime2-$mtime1
72 let ctime_diff=$ctime2-$ctime1
73
74 if [ "$mtime_diff" -eq "0" ]; then
75    echo "FAIL: mtime not update after mapped write"
76 fi
77
78 if [ "$ctime_diff" -eq "0" ]; then
79    echo "FAIL: ctime not update after mapped write"
80 fi
81
82 # success, all done
83 echo "*** done"
84 rm -f $seqres.full
85 status=0