f1fb173cae90fadf0a541aaef2422061b548cd8f
[xfstests-dev.git] / soak
1 #!/bin/sh
2 #-----------------------------------------------------------------------
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #-----------------------------------------------------------------------
5 #
6 # creator
7 owner=dxm@sgi.com
8
9 # get standard environment, filters and checks
10 . ./common.rc
11 . ./common.filter
12
13 tmp=/tmp/$$
14 seq=soak
15 status=1        # failure is the default!
16
17 _cleanup()
18 {
19     echo "        *** umount"
20     umount $SCRATCH_DEV >/dev/null 2>&1
21 }
22
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 ROOT="."
26 LOG="$ROOT/soak.log"
27 FULL="$ROOT/soak.full"
28
29 _log()
30 {
31     echo "$*" 1>&2
32     echo "$*" >>$LOG
33     echo "$*" >>$FULL
34 }
35
36 _logp()
37 {
38     tee -a $FULL
39 }
40
41 _fail()
42 {
43     _log "$*"
44     status=1
45     exit 1
46 }
47
48 _require_scratch
49
50 passes=-1
51 stress=100000
52 proc=1
53
54 if [ $# -gt 0 ]
55 then
56     passes=$1
57     if [ $# -gt 1 ]
58     then
59         stress=$2
60         if [ $# -gt 2 ]
61         then
62             proc=$3
63         fi
64     fi
65 fi
66
67 echo "" >$FULL
68 echo "" >$LOG
69 _log "*** soak test started (passes=$passes, stress=$stress, proc=$proc)"
70 _log "***     (`date`)"
71
72
73 _log "    *** init"
74 _log "        *** unmounting scratch device"
75
76 umount $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL
77
78 _log "        *** clean scratch device"
79
80 mkfs_xfs -f $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL \
81                         || _fail "            !!! failed to mkfs SCRATCH_DEV"
82
83 pass=1
84
85 while [ $pass -le $passes -o $passes -lt 0 ]
86 do
87     _log "    *** pass $pass (`date`)"
88     
89     _log "        *** check"
90     _check_scratch_fs
91     
92     _log "        *** mounting scratch device"
93
94     if ! _scratch_mount 2>&1 | _logp
95     then
96         _fail "            !!! failed to mount"
97     fi
98                         
99     if [ $pass != 1 ]
100     then
101         _log "        *** cleanup"
102         rm -rf $SCRATCH_MNT/soak_test \
103                         || _fail "            !!! couldn't delete old dir"
104
105         _log "        *** check"
106         _check_scratch_fs
107     fi
108
109     _log "        *** mkdir"
110     mkdir $SCRATCH_MNT/soak_test \
111                         || _fail "            !!! couldn't delete old dir"
112     
113     _log "        *** stress"
114     ltp/fsstress -d $SCRATCH_MNT/soak_test -p $proc -n $stress $FSSTRESS_AVOID 2>&1 | \
115         _fix_malloc >>$FULL
116
117     _log "        *** unmounting scratch device"
118
119     umount $SCRATCH_DEV 2>&1 | _logp \
120                             || _fail "            !!! failed to umount"
121     
122     let "pass = pass + 1"
123 done
124