xfstests: Test FITRIM where length is smaller than FSB
[xfstests-dev.git] / 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 # creator
26 owner=hch@lst.de
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 _cleanup()
32 {
33         cd /
34         rm -f $testfile
35 }
36
37 here=`pwd`
38 tmp=/tmp/$$
39 status=1        # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
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 Linux
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 -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 $seq.full
85 status=0