Fix test 071 upper bound for 64 bit platforms
[xfstests-dev.git] / soak
1 #!/bin/sh
2 #-----------------------------------------------------------------------
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
8
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like.  Any license provided herein, whether implied or
16 # otherwise, applies only to this software file.  Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
19
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
23
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA  94043, or:
26
27 # http://www.sgi.com 
28
29 # For further information regarding this notice, see: 
30
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #-----------------------------------------------------------------------
33 #
34 # creator
35 owner=dxm@sgi.com
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40
41 tmp=/tmp/$$
42 seq=soak
43 status=1        # failure is the default!
44
45 _cleanup()
46 {
47     echo "        *** umount"
48     umount $SCRATCH_DEV >/dev/null 2>&1
49 }
50
51 trap "_cleanup; exit \$status" 0 1 2 3 15
52
53 ROOT="."
54 LOG="$ROOT/soak.log"
55 FULL="$ROOT/soak.full"
56
57 _log()
58 {
59     echo "$*" 1>&2
60     echo "$*" >>$LOG
61     echo "$*" >>$FULL
62 }
63
64 _logp()
65 {
66     tee -a $FULL
67 }
68
69 _fail()
70 {
71     _log "$*"
72     status=1
73     exit 1
74 }
75
76 _require_scratch
77
78 passes=-1
79 stress=100000
80 proc=1
81
82 if [ $# -gt 0 ]
83 then
84     passes=$1
85     if [ $# -gt 1 ]
86     then
87         stress=$2
88         if [ $# -gt 2 ]
89         then
90             proc=$3
91         fi
92     fi
93 fi
94
95 echo "" >$FULL
96 echo "" >$LOG
97 _log "*** soak test started (passes=$passes, stress=$stress, proc=$proc)"
98 _log "***     (`date`)"
99
100
101 _log "    *** init"
102 _log "        *** unmounting scratch device"
103
104 umount $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL
105
106 _log "        *** clean scratch device"
107
108 mkfs_xfs -f $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL \
109                         || _fail "            !!! failed to mkfs SCRATCH_DEV"
110
111 pass=1
112
113 while [ $pass -le $passes -o $passes -lt 0 ]
114 do
115     _log "    *** pass $pass (`date`)"
116     
117     _log "        *** check"
118     _check_scratch_fs
119     
120     _log "        *** mounting scratch device"
121
122     if ! _scratch_mount 2>&1 | _logp
123     then
124         _fail "            !!! failed to mount"
125     fi
126                         
127     if [ $pass != 1 ]
128     then
129         _log "        *** cleanup"
130         rm -rf $SCRATCH_MNT/soak_test \
131                         || _fail "            !!! couldn't delete old dir"
132
133         _log "        *** check"
134         _check_scratch_fs
135     fi
136
137     _log "        *** mkdir"
138     mkdir $SCRATCH_MNT/soak_test \
139                         || _fail "            !!! couldn't delete old dir"
140     
141     _log "        *** stress"
142     ltp/fsstress -d $SCRATCH_MNT/soak_test -p $proc -n $stress $FSSTRESS_AVOID 2>&1 | \
143         _fix_malloc >>$FULL
144
145     _log "        *** unmounting scratch device"
146
147     umount $SCRATCH_DEV 2>&1 | _logp \
148                             || _fail "            !!! failed to umount"
149     
150     let "pass = pass + 1"
151 done
152