generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 120
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 120
6 #
7 # Test noatime mount option.
8 #
9 . ./common/preamble
10 _begin_fstest other atime auto quick
11
12 # Import common functions.
13 . ./common/filter
14
15 # real QA test starts here
16 _supported_fs generic
17
18 _require_scratch
19 _require_atime
20
21 _scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
22
23 _compare_access_times()
24 {
25         original_access_time="`cat $tmp.out | sed -n '5p'|awk '{ print substr($0,0,32)}'`"
26         accessed_time="`$here/src/lstat64 $1 | sed -n '5p'| awk '{ print substr($0,0,32)}'`"
27         echo "*** compare access times ***"
28         if [ "$original_access_time" != "$accessed_time" ]
29                 then
30                 echo "*** file access time updated on $2 (unexpected) ***"
31                 cat $tmp.out
32                 echo "---------------------------------------------------"
33                 $here/src/lstat64 $1
34                 mount | grep $SCRATCH_MNT
35         fi
36
37 }
38
39 if ! _try_scratch_mount "-o noatime" >$tmp.out 2>&1
40 then
41     cat $tmp.out
42     echo "!!! mount failed"
43     exit
44 fi
45
46 #executable file
47 echo "*** copying file ***"
48 cp $here/src/lstat64 $SCRATCH_MNT
49 $here/src/lstat64 $SCRATCH_MNT/lstat64 >$tmp.out
50 sleep 5
51 echo "*** executing file ***"
52 $SCRATCH_MNT/lstat64 $SCRATCH_MNT/lstat64 >/dev/null
53 _compare_access_times $SCRATCH_MNT/lstat64 "executing file"
54
55 #reading file
56 echo "*** creating file ***"
57 touch $SCRATCH_MNT/testfile
58 $here/src/lstat64 $SCRATCH_MNT/testfile >$tmp.out
59 sleep 5
60 echo "*** reading file ***"
61 cat $SCRATCH_MNT/testfile >/dev/null
62 _compare_access_times $SCRATCH_MNT/testfile "reading file"
63
64 #writing file
65 echo "*** creating file ***"
66 touch $SCRATCH_MNT/testfile2
67 $here/src/lstat64 $SCRATCH_MNT/testfile2 >$tmp.out
68 sleep 5
69 echo "*** writing to file ***"
70 echo "asdf" >> $SCRATCH_MNT/testfile2
71 _compare_access_times $SCRATCH_MNT/testfile2 "writing file"
72
73 _scratch_unmount
74
75 # success, all done
76 status=0
77 exit