test-definitions/blob/master/auto-test/iperf/iperf.sh

#!/bin/sh -e
set -x
cd ../../utils
    . ./sys_info.sh
cd -
SERVER="127.0.0.1"
TIME="10"
THREADS="1"
VERSION="3.1.4"

if [ `whoami` != 'root' ] ; then
    echo "You must be the superuser to run this script" >&2
    exit 1
fi

#while getopts "c:t:p:v:s:h" o; do
 # case "$o" in
  #  c) SERVER="${OPTARG}" ;;
   # t) TIME="${OPTARG}" ;;
    #p) THREADS="${OPTARG}" ;;
    #v) VERSION="${OPTARG}" ;;
    #s) SKIP_INSTALL="${OPTARG}" ;;
   # h|*) usage ;;
 # esac
#done
#distro=`cat /etc/redhat-release | cut -b 1-6`
case $distro in
    "ubuntu")
         apt-get install iperf -y
         apt-get install iperf3 -y
         print_info $? install-iperf
         ;;
    "centos")
         yum install wget -y
         yum install gcc -y
         yum install make -y
         wget https://github.com/esnet/iperf/archive/"${VERSION}".tar.gz
         tar xf "${VERSION}".tar.gz
         cd iperf-"${VERSION}"
         ./configure
         make
         make install
         print_info $? install-iperf
         ;;
    "opensuse")
         zypper install -y iperf
         ;;
 esac
sed -i '$a\/usr/local/lib' /etc/ld.so.conf
cd /etc
ldconfig
# Run local iperf3 server as a daemon when testing localhost.
[ "${SERVER}" = "127.0.0.1" ] && iperf3 -s -D
print_info $? start-iperf-server
# Run iperf test with unbuffered output mode.
stdbuf -o0 iperf3 -c "${SERVER}" -t "${TIME}" -P "${THREADS}" 2>&1 \
    | tee iperf.log
print_info $? start-iperf-client
TCID="iperf test"
# Parse logfile.
if [ "${THREADS}" -eq 1 ]; then
    egrep "(sender|receiver)" iperf.log \
        | awk '{printf("iperf-%s pass %s %s\n", $NF,$7,$8)}' \
        | tee -a iperf.log
    lava-test-case $TCID --result pass
elif [ "${THREADS}" -gt 1 ]; then
    egrep "[SUM].*(sender|receiver)" "${LOGFILE}" \
        | awk '{printf("iperf-%s pass %s %s\n", $NF,$6,$7)}' \
        | tee -a iperf.log
    lava-test-case $TCID --result pass
else
    lava-test-case $TCID --result fail
fi

# Kill iperf test daemon if any.
pkill iperf3 || true
print_info $? kill-iperf
case $distro in
    "ubuntu")
        apt-get remove iperf* -y
        print_info $? remove-package
        ;;
    "centos")
        yum remove gcc make wget -y
        print_info $? remove-package
        ;;
esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值