xfstests 241: run longer
[xfstests-dev.git] / soak
1 #!/bin/bash
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
6 # modify it under the terms 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,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 #
18 #-----------------------------------------------------------------------
19 #
20 # creator
21 owner=dxm@sgi.com
22
23 # get standard environment, filters and checks
24 . ./common.rc
25 . ./common.filter
26
27 tmp=/tmp/$$
28 seq=soak
29 status=1        # failure is the default!
30
31 _cleanup()
32 {
33     echo "        *** umount"
34     umount $SCRATCH_DEV >/dev/null 2>&1
35 }
36
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 ROOT="."
40 LOG="$ROOT/soak.log"
41 FULL="$ROOT/soak.full"
42
43 _log()
44 {
45     echo "$*" 1>&2
46     echo "$*" >>$LOG
47     echo "$*" >>$FULL
48 }
49
50 _logp()
51 {
52     tee -a $FULL
53 }
54
55 _fail()
56 {
57     _log "$*"
58     status=1
59     exit 1
60 }
61
62 _require_scratch
63
64 passes=-1
65 stress=100000
66 proc=1
67
68 if [ $# -gt 0 ]
69 then
70     passes=$1
71     if [ $# -gt 1 ]
72     then
73         stress=$2
74         if [ $# -gt 2 ]
75         then
76             proc=$3
77         fi
78     fi
79 fi
80
81 echo "" >$FULL
82 echo "" >$LOG
83 _log "*** soak test started (passes=$passes, stress=$stress, proc=$proc)"
84 _log "***     (`date`)"
85
86
87 _log "    *** init"
88 _log "        *** unmounting scratch device"
89
90 umount $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL
91
92 _log "        *** clean scratch device"
93
94 mkfs_xfs -f $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL \
95                         || _fail "            !!! failed to mkfs SCRATCH_DEV"
96
97 pass=1
98
99 while [ $pass -le $passes -o $passes -lt 0 ]
100 do
101     _log "    *** pass $pass (`date`)"
102     
103     _log "        *** check"
104     _check_scratch_fs
105     
106     _log "        *** mounting scratch device"
107
108     if ! _scratch_mount 2>&1 | _logp
109     then
110         _fail "            !!! failed to mount"
111     fi
112                         
113     if [ $pass != 1 ]
114     then
115         _log "        *** cleanup"
116         rm -rf $SCRATCH_MNT/soak_test \
117                         || _fail "            !!! couldn't delete old dir"
118
119         _log "        *** check"
120         _check_scratch_fs
121     fi
122
123     _log "        *** mkdir"
124     mkdir $SCRATCH_MNT/soak_test \
125                         || _fail "            !!! couldn't delete old dir"
126     
127     _log "        *** stress"
128     ltp/fsstress -d $SCRATCH_MNT/soak_test -p $proc -n $stress $FSSTRESS_AVOID 2>&1 | \
129         _fix_malloc >>$FULL
130
131     _log "        *** unmounting scratch device"
132
133     umount $SCRATCH_DEV 2>&1 | _logp \
134                             || _fail "            !!! failed to umount"
135     
136     let "pass = pass + 1"
137 done
138