xfstests: introduce a common directory
[xfstests-dev.git] / tests / generic / 120
1 #!/bin/bash
2 # FS QA Test No. 120
3 #
4 # Test noatime mount option.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common/rc
38 . ./common/filter
39
40 # real QA test starts here
41 _supported_fs generic
42 _supported_os Linux IRIX
43
44 _require_scratch
45 _scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
46
47 _compare_access_times()
48 {
49         original_access_time="`cat $tmp.out | sed -n '5p'|awk '{ print substr($0,0,32)}'`"
50         accessed_time="`src/lstat64 $1 | sed -n '5p'| awk '{ print substr($0,0,32)}'`"
51         echo "*** compare access times ***"
52         if [ "$original_access_time" != "$accessed_time" ]
53                 then
54                 echo "*** file access time updated on $2 (unexpected) ***"
55                 cat $tmp.out
56                 echo "---------------------------------------------------"
57                 src/lstat64 $1
58                 mount | grep $SCRATCH_MNT
59         fi
60
61 }
62
63 if ! _scratch_mount "-o noatime" >$tmp.out 2>&1
64 then
65     cat $tmp.out
66     echo "!!! mount failed"
67     exit
68 fi
69
70 #executable file
71 echo "*** copying file ***"
72 cp src/lstat64 $SCRATCH_MNT
73 src/lstat64 $SCRATCH_MNT/lstat64 >$tmp.out
74 sleep 5
75 echo "*** executing file ***"
76 $SCRATCH_MNT/lstat64 $SCRATCH_MNT/lstat64 >/dev/null
77 _compare_access_times $SCRATCH_MNT/lstat64 "executing file"
78
79 #reading file
80 echo "*** creating file ***"
81 touch $SCRATCH_MNT/testfile
82 src/lstat64 $SCRATCH_MNT/testfile >$tmp.out
83 sleep 5
84 echo "*** reading file ***"
85 cat $SCRATCH_MNT/testfile >/dev/null
86 _compare_access_times $SCRATCH_MNT/testfile "reading file"
87
88 #writing file
89 echo "*** creating file ***"
90 touch $SCRATCH_MNT/testfile2
91 src/lstat64 $SCRATCH_MNT/testfile2 >$tmp.out
92 sleep 5
93 echo "*** writing to file ***"
94 echo "asdf" >> $SCRATCH_MNT/testfile2
95 _compare_access_times $SCRATCH_MNT/testfile2 "writing file"
96
97
98 umount $SCRATCH_MNT
99
100 # success, all done
101 status=0
102 exit