Files
apfstests/tests/generic/192
T
Eric Biggers 22ea2f8c0a generic/192: use shorter sleep and tolerate 2s delay
generic/192 would sleep 40 seconds, update a file's atime, and then
fail if the atime was not exactly 40 seconds later.  This is
unreliable since things may be slow enough to cause an extra second
to elapse.  "Fix" this by allowing for 2 seconds of delay.  Also,
while we're at it shorten the sleep to a much more reasonable 5
seconds.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2017-07-21 15:30:09 +08:00

79 lines
2.0 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test No. 192
#
# Simple test of atime
# - ensure it is persistent after unmount
# - check updated time by correct amount
#
#-----------------------------------------------------------------------
# Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "exit \$status" 0 1 2 3 15
_access_time()
{
stat -c %X $1
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# real QA test starts here
_supported_fs generic
_supported_os Linux
_require_test
_require_atime
delay=5
testfile=$TEST_DIR/testfile
rm -f $testfile
rm -f $seqres.full
echo test >$testfile
time1=`_access_time $testfile | tee -a $seqres.full`
echo "sleep for $delay seconds"
sleep $delay # sleep to allow time to move on for access
cat $testfile
time2=`_access_time $testfile | tee -a $seqres.full`
cd /
_test_cycle_mount
time3=`_access_time $testfile | tee -a $seqres.full`
delta1=`expr $time2 - $time1`
delta2=`expr $time3 - $time1`
# tolerate an atime up to 2s later than the ideal case
_within_tolerance "delta1" $delta1 $delay 0 2 -v
_within_tolerance "delta2" $delta2 $delta1 0 0 -v
# success, all done
status=0
exit