generic: test adding filesystem-level fscrypt key via key_id
[xfstests-dev.git] / tests / generic / 192
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 192
6 #
7 # Simple test of atime
8 # - ensure it is persistent after unmount
9 # - check updated time by correct amount
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "exit \$status" 0 1 2 3 15
19
20 _access_time()
21 {
22         stat -c %X $1
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30
31 _supported_fs generic
32 _supported_os Linux
33 _require_test
34 _require_atime
35 delay=5
36
37 testfile=$TEST_DIR/testfile
38 rm -f $testfile
39 rm -f $seqres.full
40
41 echo test >$testfile
42 time1=`_access_time $testfile | tee -a $seqres.full`
43
44 echo "sleep for $delay seconds"
45 sleep $delay # sleep to allow time to move on for access
46 cat $testfile
47 time2=`_access_time $testfile | tee -a $seqres.full`
48
49 cd /
50 _test_cycle_mount
51 time3=`_access_time $testfile | tee -a $seqres.full`
52
53 delta1=`expr $time2 - $time1`
54 delta2=`expr $time3 - $time1`
55
56 # tolerate an atime up to 2s later than the ideal case
57 _within_tolerance "delta1" $delta1 $delay  0 2 -v
58 _within_tolerance "delta2" $delta2 $delta1 0 0 -v
59
60 # success, all done
61 status=0
62 exit