Whamcloud - gitweb
LU-657 test: limit the write size in run_dd
[fs/lustre-release.git] / lustre / tests / run_dd.sh
index d50150e..6106bb0 100755 (executable)
@@ -1,20 +1,23 @@
 #!/bin/bash
-set -x
 
 TMP=${TMP:-/tmp}
 
-TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
-LOG=${TESTSUITELOG}_$(basename $0)-$(hostname)
-DEBUGLOG=${LOG}.debug
+TESTLOG_PREFIX=${TESTLOG_PREFIX:-$TMP/recovery-mds-scale}
+TESTNAME=${TESTNAME:-""}
+[ -n "$TESTNAME" ] && TESTLOG_PREFIX=$TESTLOG_PREFIX.$TESTNAME
+
+LOG=$TESTLOG_PREFIX.$(basename $0 .sh)_stdout.$(hostname -s).log
+DEBUGLOG=$(echo $LOG | sed 's/\(.*\)stdout/\1debug/')
 
 mkdir -p ${LOG%/*}
 
 rm -f $LOG $DEBUGLOG
 exec 2>$DEBUGLOG
+set -x
 
 . $(dirname $0)/functions.sh
 
-assert_env MOUNT END_RUN_FILE LOAD_PID_FILE
+assert_env MOUNT END_RUN_FILE LOAD_PID_FILE LFS
 
 trap signaled TERM
 
@@ -25,28 +28,36 @@ TESTDIR=$MOUNT/d0.dd-$(hostname)
 
 CONTINUE=true
 while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
-    echoerr "$(date +'%F %H:%M:%S'): dd run starting"
-    mkdir -p $TESTDIR
-    cd $TESTDIR
-    dd bs=4k count=1000000 if=/dev/zero of=$TESTDIR/dd-file 1>$LOG &
-    load_pid=$!
-    wait $load_pid
-
-    if [ $? -eq 0 ]; then
-       echoerr "$(date +'%F %H:%M:%S'): dd succeeded"
-       cd $TMP
-       rm -rf $TESTDIR
-       echoerr "$(date +'%F %H:%M:%S'): dd run finished"
-    else
-       echoerr "$(date +'%F %H:%M:%S'): dd failed"
-       if [ -z "$ERRORS_OK" ]; then
-           echo $(hostname) >> $END_RUN_FILE
-       fi
-       if [ $BREAK_ON_ERROR ]; then
-           # break
-            CONTINUE=false
+       echoerr "$(date +'%F %H:%M:%S'): dd run starting"
+       mkdir -p $TESTDIR
+       $LFS setstripe -c -1 $TESTDIR
+       cd $TESTDIR
+       # suppress dd xfer stat to workaround buggy coreutils/gettext
+       # combination in RHEL5 and OEL5, see BZ 21264
+       FREE_SPACE=$($LFS df $TESTDIR|awk '/filesystem summary:/ {print $5}')
+       BLKS=$((FREE_SPACE * 9 / 40))
+       echo "Free disk space is $FREE_SPACE, 4k blocks to dd is $BLKS"
+
+       dd bs=4k count=$BLKS status=noxfer if=/dev/zero of=$TESTDIR/dd-file \
+                                                               1>$LOG &
+       load_pid=$!
+       wait $load_pid
+
+       if [ $? -eq 0 ]; then
+               echoerr "$(date +'%F %H:%M:%S'): dd succeeded"
+               cd $TMP
+               rm -rf $TESTDIR
+               echoerr "$(date +'%F %H:%M:%S'): dd run finished"
+       else
+               echoerr "$(date +'%F %H:%M:%S'): dd failed"
+               if [ -z "$ERRORS_OK" ]; then
+                       echo $(hostname) >> $END_RUN_FILE
+               fi
+               if [ $BREAK_ON_ERROR ]; then
+                       # break
+                       CONTINUE=false
+               fi
        fi
-    fi
 done
 
 echoerr "$(date +'%F %H:%M:%S'): dd run exiting"