large-transfer-sizes.sh [plain text]
#! /bin/bash
SCRIPTBASE=${SCRIPTBASE:-$(cd $(dirname $0)/.. && pwd )}
. $SCRIPTBASE/common.sh || exit 2
if [ $cat <<EOF
Usage: large_transfer_sizes.sh SERVER SHARE USERNAME PASSWORD
EOF
exit 1;
fi
SERVER=$1
SHARE=$2
USERNAME=${3:-local}
PASSWORD=${4:-local}
DD=/usr/local/bin/cifsdd
DEBUGLEVEL=1
failed=0
failtest() {
failed=`expr $failed + 1`
}
runcopy() {
message="$1"
shift
echo $message
vrun $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL \
-U "$USERNAME"%"$PASSWORD" \
"$@"
}
compare() {
cmp "$1" "$2" > /dev/null 2>&1
}
sourcepath=tempfile.src.$$
destpath=tempfile.dst.$$
dd if=/dev/random of=$sourcepath bs=1024 count=400
dd if=/dev/random seek=$[1024 * 400] of=$sourcepath bs=1 count=30
ls -l $sourcepath
for bs in 512 4k 48k 64k 127k ; do
echo "Testing $bs block size ..."
runcopy "Testing local -> remote copy" \
if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs || failtest
runcopy "Testing remote -> local copy" \
if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs || failtest
compare $sourcepath $destpath || failtest
runcopy "Testing local -> remote copy" \
if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs || failtest
runcopy "Testing remote -> remote copy" \
if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs || failtest
runcopy "Testing remote -> local copy" \
if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs || failtest
compare $sourcepath $destpath || failtest
done
rm -f $sourcepath $destpath
testok $0 $failed