fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / generic / 120
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 120
6 #
7 # Test noatime mount option.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs generic
24
25 _require_scratch
26 _require_atime
27
28 _scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
29
30 _compare_access_times()
31 {
32         original_access_time="`cat $tmp.out | sed -n '5p'|awk '{ print substr($0,0,32)}'`"
33         accessed_time="`$here/src/lstat64 $1 | sed -n '5p'| awk '{ print substr($0,0,32)}'`"
34         echo "*** compare access times ***"
35         if [ "$original_access_time" != "$accessed_time" ]
36                 then
37                 echo "*** file access time updated on $2 (unexpected) ***"
38                 cat $tmp.out
39                 echo "---------------------------------------------------"
40                 $here/src/lstat64 $1
41                 mount | grep $SCRATCH_MNT
42         fi
43
44 }
45
46 if ! _try_scratch_mount "-o noatime" >$tmp.out 2>&1
47 then
48     cat $tmp.out
49     echo "!!! mount failed"
50     exit
51 fi
52
53 #executable file
54 echo "*** copying file ***"
55 cp $here/src/lstat64 $SCRATCH_MNT
56 $here/src/lstat64 $SCRATCH_MNT/lstat64 >$tmp.out
57 sleep 5
58 echo "*** executing file ***"
59 $SCRATCH_MNT/lstat64 $SCRATCH_MNT/lstat64 >/dev/null
60 _compare_access_times $SCRATCH_MNT/lstat64 "executing file"
61
62 #reading file
63 echo "*** creating file ***"
64 touch $SCRATCH_MNT/testfile
65 $here/src/lstat64 $SCRATCH_MNT/testfile >$tmp.out
66 sleep 5
67 echo "*** reading file ***"
68 cat $SCRATCH_MNT/testfile >/dev/null
69 _compare_access_times $SCRATCH_MNT/testfile "reading file"
70
71 #writing file
72 echo "*** creating file ***"
73 touch $SCRATCH_MNT/testfile2
74 $here/src/lstat64 $SCRATCH_MNT/testfile2 >$tmp.out
75 sleep 5
76 echo "*** writing to file ***"
77 echo "asdf" >> $SCRATCH_MNT/testfile2
78 _compare_access_times $SCRATCH_MNT/testfile2 "writing file"
79
80 _scratch_unmount
81
82 # success, all done
83 status=0
84 exit