generic/520: Remove sync in clean_dir
[xfstests-dev.git] / tests / generic / 215
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Christoph Hellwig.
4 #
5 # FS QA Test No. 215
6 #
7 # Test out c/mtime updates after mapped writes.
8 #
9 # Based on the testcase in http://bugzilla.kernel.org/show_bug.cgi?id=2645
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 _cleanup()
16 {
17         cd /
18         rm -f $testfile
19 }
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1        # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs generic
32 _supported_os Linux
33 _require_test
34
35 testfile=$TEST_DIR/tst.mmap
36
37 echo
38 echo "creating test file"
39 dd if=/dev/zero of=$testfile count=4096
40
41 mtime1=`stat -c "%Y" $testfile`
42 ctime1=`stat -c "%Z" $testfile`
43
44 sleep 2
45
46 echo
47 echo "writing via mmap"
48 $XFS_IO_PROG -f                 \
49         -c 'mmap 0 4096'        \
50         -c 'mwrite 0 4096'      \
51         $testfile | _filter_xfs_io_unique
52
53 mtime2=`stat -c "%Y" $testfile`
54 ctime2=`stat -c "%Z" $testfile`
55
56 let mtime_diff=$mtime2-$mtime1
57 let ctime_diff=$ctime2-$ctime1
58
59 if [ "$mtime_diff" -eq "0" ]; then
60    echo "FAIL: mtime not update after mapped write"
61 fi
62
63 if [ "$ctime_diff" -eq "0" ]; then
64    echo "FAIL: ctime not update after mapped write"
65 fi
66
67 # success, all done
68 echo "*** done"
69 rm -f $seqres.full
70 status=0