cd81ce53028d67e1faa297de9ccd7ae54aa61744
[xfstests-dev.git] / tests / overlay / 039
1 #! /bin/bash
2 # FS QA Test 039
3 #
4 # Test access time update issue for directories in upper layer.
5 #
6 # Upstream Commit cd91304e7190 ("ovl: fix relatime for directories")
7 # fixed this issue.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 Huawei.  All Rights Reserved.
11 # Author: zhangyi (F) <yi.zhang@huawei.com>
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46
47 # remove previous $seqres.full before test
48 rm -f $seqres.full
49
50 # real QA test starts here
51 _supported_fs overlay
52 _supported_os Linux
53 _require_scratch
54 _require_relatime
55
56 # remove all files from previous runs
57 _scratch_mkfs
58
59 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
60 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
61 mkdir -p $upperdir/test
62
63 _scratch_mount "-o relatime"
64
65 # access test dir, it's access time will be updated normally
66 ls $SCRATCH_MNT/test
67
68 pre_access_time=`stat -c "%X" $SCRATCH_MNT/test`
69
70 # In relatime mode, access time is only updated if the previous
71 # access time was earlier than the current modify or change time,
72 # so trigger modify and change time update.
73 touch $SCRATCH_MNT/test/foo
74 sleep 1
75
76 # access test dir again
77 ls $SCRATCH_MNT/test > /dev/null 2>&1
78
79 cur_access_time=`stat -c "%X" $SCRATCH_MNT/test`
80
81 # compare the results, current access time should later than the previous one
82 if [ $cur_access_time -le $pre_access_time ] ; then
83         echo "Access time is not updated correctly."
84 fi
85
86 # success, all done
87 echo "Silence is golden"
88 status=0
89 exit