Commit ae20cb45 authored by Dan Reading's avatar Dan Reading
Browse files

some changes to make tdd work

parent ad41aaa8
......@@ -43,7 +43,8 @@ fi
[[ -z "${mfsmode-}" ]] && declare -i mfsmode=0 #are we running in a MFS?
[[ -z "${bitsize-}" ]] && declare bitsize=""
[[ -z "${native_bitsize-}" ]] && declare -i native_bitsize=0 # what is our native binary bit size
[[ -z "${whichfile-}" ]] && declare whichfile=""
[[ -z "${USE_DD-}" ]] && declare USE_DD="tdd" # if set which dd for the tdd program to use
[[ -z "${TDD_DD-}" ]] && declare TDD_DD="dd" # if set which dd for the tdd program to use
# PathNames
[[ -z "${logfile-}" ]] && declare logfile # output log
......@@ -76,19 +77,31 @@ initialize () {
fi
fi
if [ -f /etc/emulab/ismfs ] ; then
mfsmode=1
else
mfsmode=0
fi
bitsize=$(uname -m)
case $bitsize in
i386 | x86 ) native_bitsize=32 ;;
i386 | x86 | i686 ) native_bitsize=32 ;;
amd64 | x86_64 ) native_bitsize=64 ;;
* ) native_bitsize=0 ;;
esac
if [ -f /etc/emulab/ismfs ] ; then
mfsmode=1
dd=$(whichdd2use)
if [ "$dd" != "${dd/tdd}" ] ; then
USE_DD=$dd
TDD_DD=$(which dd)
elif [ "$dd" != "${dd/bad}" ] ; then
USE_DD=$dd
TDD_DD=""
else
USE_DD=$(which dd)
TDD_DD=""
fi
else
mfsmode=0
# no speed test don't have to check tdd, etc.
fi
inithostname
initlogs $@
inittestinfo
......@@ -815,8 +828,63 @@ getfromtb() {
return 0
}
whichdd2use() {
local usetdd
local canwe
local -i bad64=0
workhorsedd=$(which dd)
canwe=$(ls -l $workhorsedd | grep busybox)
[[ $canwe ]] && { echo "bad_busybox_dd"; return 0; }
# if we have a timed dd, use a timeout rather than a count
usetdd=$(which tdd)
[[ -x $usetdd ]] && { USE_DD=$usetdd; TDD_DD=$workhorsedd; usedd=$usetdd; }
# check compatabily, ok to have 32bit on 64bit machine
if [ $native_bitsize -ne 64 ] ; then
# check directory name of where the exectuable is installed
# if not 32 or not 64 then assume native binary and is ok
if [ "$workhorsedd" != "${workhorsedd/64}" ] ; then # it has 64 in path
bad64=1
fi
# and check tdd if we are using it
if [ "${USE_DD}" != "${USE_DD/tdd}" ] ; then
if [ "$USE_DD" != "${USE_DD/64}" ] ; then
bad64=1
fi
fi
if [ $bad64 -eq 1 ] ; then
echo "bad_64bit_dd_on_32bit_machine"
return 0
fi
fi
echo "$usedd"
return 0
}
# call whichdd2use() before this to use correctly
ddargs() {
local args=""
if [ "$os" == "Linux" ] ; then
#args="bs=64k iflag=direct count=8000"
#note iflag direct can't be used with /dev/zero as infile
args="bs=64k"
elif [ "$os" == "FreeBSD" ] ; then
args="bs=64k"
fi
if [ "$USE_DD" != "${USE_DD/tdd}" ] ; then
# if we have a timed dd, use a timeout rather than a count
args="$args timeout=5 count=20000" # XXX paranoid: leave a count just in case
else
args="$args count=8000"
fi
echo "$args"
return 0
}
# The timesys function terminates its script unless it terminates earlier on its own
# args: max_time output_file command command_args
......
......@@ -29,8 +29,6 @@ echo -n ' Starting diskcheck..'
declare error=""
declare err=""
[[ -z "${USE_TDD-}" ]] && declare USE_TDD=""
source checkutils.sh
source hbis.sh
......@@ -666,61 +664,6 @@ getsectors() {
return 0
}
whichdd2use() {
local usedd
local usetdd
local canwe
local ddbs
local workhouredd
usedd=$(which dd)
canwe=$(ls -l $usedd | grep busybox)
[[ $canwe ]] && { echo "bad_busybox_dd"; return 0; }
workhorsedd=$usedd
# if we have a timed dd, use a timeout rather than a count
usetdd=$(which tdd)
[[ -x $usetdd ]] && { USE_TDD=$usetdd; export TDD_DD=$usedd; usedd=$usetdd; } # the wapper tdd will use /bin/dd by default but this var will override
# check compatabily, ok to have 32bit on 64bit machine
if [ $native_bitsize -ne 64 ] ; then
ddbs=$(file -L $workhorsedd)
if [ "$ddbs" != "${ddbs/64}" ] ; then
echo "bad_64bit_dd_on_32bit_machine"
return 0
fi
if [ "${USE_TDD}" != "${USE_TDD/tdd}" ] ; then
ddbs=$(file -L $USE_TDD)
if [ "$ddbs" != "${ddbs/64}" ] ; then
echo "bad_64bit_ddt_on_32bit_machine"
return 0
fi
fi
fi
echo "$usedd"
return 0
}
# call whichdd2use() before this to use correctly
ddargs() {
local args=""
if [ "$os" == "Linux" ] ; then
#args="bs=64k iflag=direct count=8000"
#note iflag direct can't be used with /dev/zero as infile
args="bs=64k"
elif [ "$os" == "FreeBSD" ] ; then
args="bs=64k"
fi
if [ "$USE_TDD" != "${USE_TDD/tdd}" ] ; then
# if we have a timed dd, use a timeout rather than a count
args="$args timeout=5 count=20000" # XXX paranoid: leave a count just in case
else
args="$args count=8000"
fi
echo "$args"
return 0
}
getwspeed() {
hdname=$1
......@@ -728,11 +671,12 @@ getwspeed() {
canwe=$(df | grep $hdname)
[[ $canwe ]] && { echo mounted; return 0; }
dd=$(whichdd2use)
dd=$USE_DD
[[ -x $dd ]] || { echo "$dd"; return 0; }
args=$(ddargs)
add_on_exit 'rm -f /tmp/ddresultw'
[[ -n "$TDD_DD" ]] && export TDD_DD
$dd if=/dev/zero of=$hdname $args >/tmp/ddresultw 2>&1
res=$(grep bytes /tmp/ddresultw)
......@@ -744,11 +688,12 @@ getrspeed() {
hdname=$1
# do we have a working dd
dd=$(whichdd2use)
dd=$USE_DD
[[ -x $dd ]] || { echo "$dd"; return 0; }
args=$(ddargs)
add_on_exit 'rm -f /tmp/ddresultr'
[[ -n "$TDD_DD" ]] && export TDD_DD
$dd of=/dev/null if=$hdname $args >/tmp/ddresultr 2>&1
res=$(grep bytes /tmp/ddresultr)
......
......@@ -69,7 +69,6 @@ fi
# if asked to collect need the collect dir for this project
# (as given by tmcc hwinfo) mounted to save logs
set -x
if [ "$collect" = "1" ] ; then
collectdir=`echo $testinfo | awk -F \" '{print $2}'`
a=`echo $collectdir | awk -F \/ '{print $2}'`
......@@ -120,7 +119,6 @@ if [ -f "/etc/emulab/ismfs" ] ; then
fi
exit 0
fi
set +x
echo "Running nodechecks"
# truncate file at boot time
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment