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