fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / overlay / 039
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 039
6 #
7 # Test access time update issue for directories in upper layer.
8 #
9 # Upstream Commit cd91304e7190 ("ovl: fix relatime for directories")
10 # fixed this issue.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs overlay
36 _supported_os Linux
37 _require_scratch
38 _require_relatime
39
40 # remove all files from previous runs
41 _scratch_mkfs
42
43 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
44 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
45 mkdir -p $upperdir/test
46
47 _scratch_mount "-o relatime"
48
49 # access test dir, it's access time will be updated normally
50 ls $SCRATCH_MNT/test
51
52 pre_access_time=`stat -c "%X" $SCRATCH_MNT/test`
53
54 # In relatime mode, access time is only updated if the previous
55 # access time was earlier than the current modify or change time,
56 # so trigger modify and change time update.
57 touch $SCRATCH_MNT/test/foo
58 sleep 1
59
60 # access test dir again
61 ls $SCRATCH_MNT/test > /dev/null 2>&1
62
63 cur_access_time=`stat -c "%X" $SCRATCH_MNT/test`
64
65 # compare the results, current access time should later than the previous one
66 if [ $cur_access_time -le $pre_access_time ] ; then
67         echo "Access time is not updated correctly."
68 fi
69
70 # success, all done
71 echo "Silence is golden"
72 status=0
73 exit