generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 080
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FS QA Test No. 080
6 #
7 # Verify that mtime is updated when writing to mmap-ed pages
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=0
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22         rm -f $testfile
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs generic
31 _supported_os Linux
32 _require_test
33
34 echo "Silence is golden."
35 rm -f $seqres.full
36
37 # pattern the file.
38 testfile=$TEST_DIR/mmap_mtime_testfile
39 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $testfile >> $seqres.full
40
41 # sample timestamps.
42 mtime1=`stat -c %Y $testfile`
43 ctime1=`stat -c %Z $testfile`
44 echo "before mwrite: $mtime1 $ctime1" >> $seqres.full
45
46 # map read followed by map write to trigger timestamp change
47 sleep 2
48 $XFS_IO_PROG -c "mmap 0 4k" -c "mread 0 4k" -c "mwrite 0 4k" $testfile \
49         >> $seqres.full
50
51 # sample and verify that timestamps have changed.
52 mtime2=`stat -c %Y $testfile`
53 ctime2=`stat -c %Z $testfile`
54 echo "after mwrite : $mtime2 $ctime2" >> $seqres.full
55
56 if [ "$mtime1" == "$mtime2" ]; then
57         echo "mtime not updated"
58         let status=$status+1
59 fi
60 if [ "$ctime1" == "$ctime2" ]; then
61         echo "ctime not updated"
62         let status=$status+1
63 fi
64
65 exit