274: Many fixups
[xfstests-dev.git] / 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 # creator
25 owner=allanr@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
39 # real QA test starts here
40 _supported_fs generic
41 _supported_os Linux IRIX
42
43 _require_scratch
44 _scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
45
46 _compare_access_times()
47 {
48         original_access_time="`cat $tmp.out | sed -n '5p'|awk '{ print substr($0,0,32)}'`"
49         accessed_time="`src/lstat64 $1 | sed -n '5p'| awk '{ print substr($0,0,32)}'`"
50         echo "*** compare access times ***"
51         if [ "$original_access_time" != "$accessed_time" ]
52                 then
53                 echo "*** file access time updated on $2 (unexpected) ***"
54                 cat $tmp.out
55                 echo "---------------------------------------------------"
56                 src/lstat64 $1
57                 mount | grep $SCRATCH_MNT
58         fi
59
60 }
61
62 if ! _scratch_mount "-o noatime" >$tmp.out 2>&1
63 then
64     cat $tmp.out
65     echo "!!! mount failed"
66     exit
67 fi
68
69 #executable file
70 echo "*** copying file ***"
71 cp src/lstat64 $SCRATCH_MNT
72 src/lstat64 $SCRATCH_MNT/lstat64 >$tmp.out
73 sleep 5
74 echo "*** executing file ***"
75 $SCRATCH_MNT/lstat64 $SCRATCH_MNT/lstat64 >/dev/null
76 _compare_access_times $SCRATCH_MNT/lstat64 "executing file"
77
78 #reading file
79 echo "*** creating file ***"
80 touch $SCRATCH_MNT/testfile
81 src/lstat64 $SCRATCH_MNT/testfile >$tmp.out
82 sleep 5
83 echo "*** reading file ***"
84 cat $SCRATCH_MNT/testfile >/dev/null
85 _compare_access_times $SCRATCH_MNT/testfile "reading file"
86
87 #writing file
88 echo "*** creating file ***"
89 touch $SCRATCH_MNT/testfile2
90 src/lstat64 $SCRATCH_MNT/testfile2 >$tmp.out
91 sleep 5
92 echo "*** writing to file ***"
93 echo "asdf" >> $SCRATCH_MNT/testfile2
94 _compare_access_times $SCRATCH_MNT/testfile2 "writing file"
95
96
97 umount $SCRATCH_MNT
98
99 # success, all done
100 status=0
101 exit