summaryrefslogtreecommitdiff
path: root/tests/generic/192
blob: 28254866357bd636fa7d5ffc1f075d7013bec781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
#
# FS QA Test No. 192
#
# Simple test of atime
# - ensure it is persistent after unmount
# - check updated time by correct amount
#
. ./common/preamble
_begin_fstest atime auto

_access_time()
{
	stat -c %X $1
}

# Import common functions.
. ./common/filter

# real QA test starts here

_supported_fs generic
_require_test
_require_atime
delay=5

testfile=$TEST_DIR/testfile
rm -f $testfile

# Preload every binary used between sampling time1 and time2 so that loading
# them has minimal overhead even if the root fs is hosted over a slow network.
# Also don't put pipe and tee creation in that critical section.
for i in echo stat sleep cat; do
	$i --help &>/dev/null
done

echo test >$testfile
time1=`_access_time $testfile`
echo $time1 >> $seqres.full

echo "sleep for $delay seconds"
sleep $delay # sleep to allow time to move on for access
cat $testfile
time2=`_access_time $testfile`
echo $time2 >> $seqres.full

cd /
_test_cycle_mount
time3=`_access_time $testfile`
echo $time3 >> $seqres.full

delta1=`expr $time2 - $time1`
delta2=`expr $time3 - $time1`

min_tol=0
if [ "$FSTYP" = "exfat" ]; then
	min_tol=1
fi

# tolerate an atime up to 2s later than the ideal case
_within_tolerance "delta1" $delta1 $delay $min_tol 2 -v
_within_tolerance "delta2" $delta2 $delta1 0 0 -v

# success, all done
status=0
exit