Whamcloud - gitweb
36af6ae888bf1e774181a07222ee69a988b98b68
[fs/lustre-release.git] / lustre / tests / run_dd.sh
1 #!/bin/bash
2
3 TMP=${TMP:-/tmp}
4
5 TESTLOG_PREFIX=${TESTLOG_PREFIX:-$TMP/recovery-mds-scale}
6 TESTNAME=${TESTNAME:-""}
7 [ -n "$TESTNAME" ] && TESTLOG_PREFIX=$TESTLOG_PREFIX.$TESTNAME
8
9 LOG=$TESTLOG_PREFIX.$(basename $0 .sh)_stdout.$(hostname -s).log
10 DEBUGLOG=$(echo $LOG | sed 's/\(.*\)stdout/\1debug/')
11
12 mkdir -p ${LOG%/*}
13
14 rm -f $LOG $DEBUGLOG
15 exec 2>$DEBUGLOG
16 set -x
17
18 . $(dirname $0)/functions.sh
19
20 assert_env MOUNT END_RUN_FILE LOAD_PID_FILE
21
22 trap signaled TERM
23
24 # recovery-*-scale scripts use this to signal the client loads to die
25 echo $$ >$LOAD_PID_FILE
26
27 TESTDIR=$MOUNT/d0.dd-$(hostname)
28
29 CONTINUE=true
30 while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
31     echoerr "$(date +'%F %H:%M:%S'): dd run starting"
32     mkdir -p $TESTDIR
33     cd $TESTDIR
34     # suppress dd xfer stat to workaround buggy coreutils/gettext
35     # combination in RHEL5 and OEL5, see BZ 21264
36     dd bs=4k count=1000000 status=noxfer if=/dev/zero of=$TESTDIR/dd-file 1>$LOG &
37     load_pid=$!
38     wait $load_pid
39
40     if [ $? -eq 0 ]; then
41         echoerr "$(date +'%F %H:%M:%S'): dd succeeded"
42         cd $TMP
43         rm -rf $TESTDIR
44         echoerr "$(date +'%F %H:%M:%S'): dd run finished"
45     else
46         echoerr "$(date +'%F %H:%M:%S'): dd failed"
47         if [ -z "$ERRORS_OK" ]; then
48             echo $(hostname) >> $END_RUN_FILE
49         fi
50         if [ $BREAK_ON_ERROR ]; then
51             # break
52             CONTINUE=false
53         fi
54     fi
55 done
56
57 echoerr "$(date +'%F %H:%M:%S'): dd run exiting"