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