common/rc: Add _require_{chown,chmod}()
[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 _require_test
32
33 echo "Silence is golden."
34 rm -f $seqres.full
35
36 # pattern the file.
37 testfile=$TEST_DIR/mmap_mtime_testfile
38 $XFS_IO_PROG -f -c "pwrite 0 4k" -c fsync $testfile >> $seqres.full
39
40 # sample timestamps.
41 mtime1=`stat -c %Y $testfile`
42 ctime1=`stat -c %Z $testfile`
43 echo "before mwrite: $mtime1 $ctime1" >> $seqres.full
44
45 # map read followed by map write to trigger timestamp change
46 sleep 2
47 $XFS_IO_PROG -c "mmap 0 4k" -c "mread 0 4k" -c "mwrite 0 4k" $testfile \
48         >> $seqres.full
49
50 # sample and verify that timestamps have changed.
51 mtime2=`stat -c %Y $testfile`
52 ctime2=`stat -c %Z $testfile`
53 echo "after mwrite : $mtime2 $ctime2" >> $seqres.full
54
55 if [ "$mtime1" == "$mtime2" ]; then
56         echo "mtime not updated"
57         let status=$status+1
58 fi
59 if [ "$ctime1" == "$ctime2" ]; then
60         echo "ctime not updated"
61         let status=$status+1
62 fi
63
64 exit