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