Skip to content

Commit

Permalink
Merge pull request torvalds#152 from liuyuan10/testnetperf
Browse files Browse the repository at this point in the history
lkl: Add netperf TCP_RR and TCP_STREAM to make test
  • Loading branch information
Octavian Purdila committed Apr 21, 2016
2 parents 987ed9f + 80535f4 commit 844853e
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/lkl/tests/hijack-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ sudo arp -d 192.168.13.2
sudo ping -i 0.01 -c 65 192.168.13.2 &
${hijack_script} sleep 3

sh ${script_dir}/run_netperf.sh 192.168.13.1 1 0 TCP_STREAM
sh ${script_dir}/run_netperf.sh 192.168.13.1 1 0 TCP_RR

echo "== VDE tests =="
if [ ! -x "$(which vde_switch)" ]; then
echo "WARNING: Cannot find a vde_switch executable, skipping VDE tests."
Expand Down
95 changes: 95 additions & 0 deletions tools/lkl/tests/run_netperf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

# Usage
# ./run_netperf.sh [host_ip] [num_runs] [use_taskset] [test_name]

set -e

script_dir=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
hijack_script=${script_dir}/../bin/lkl-hijack.sh

num_runs="1"
test_name="TCP_STREAM"
use_taskset="0"
host_ip="192.168.13.1"
taskset_cmd="taskset -c 1"
test_len=10 # second

if [ ! -x "$(which netperf)" ]; then
echo "WARNING: Cannot find a netserver executable, skipping netperf tests."
exit 0
fi

if [ $# -ge 1 ]
then
host_ip=$1
fi
if [ $# -ge 2 ]
then
num_runs=$2
fi
if [ $# -ge 3 ]
then
use_taskset=$3
fi
if [ $# -ge 4 ]
then
test_name=$4
fi
if [ $# -ge 5 ]
then
echo "BAD NUMBER of INPUTS."
exit 1
fi

if [ $use_taskset = "0" ]
then
taskset_cmd=""
fi

# Starts the netsever. If it fails, there is no clean up needed.
existing_netserver=$(ps -ef | grep -v grep | grep -c netserver) || true

if [ $existing_netserver -ne 0 ]
then
echo "netserver is running. You must kill it."
exit 1
fi

function clean {
sudo killall netserver &> /dev/null || true
}

function clean_with_tap {
sudo ip link set dev $LKL_HIJACK_NET_IFPARAMS down &> /dev/null || true
sudo ip tuntap del dev $LKL_HIJACK_NET_IFPARAMS mode tap &> /dev/null || true
clean
}

trap clean EXIT

# LKL_HIJACK_NET_IFTYPE is not set, which means it's not called from
# hijack-test.sh. Needs to set up things first.
if [ -z ${LKL_HIJACK_NET_IFTYPE+x} ]
then
# Setting up environmental vars and TAP
export LKL_HIJACK_NET_IFTYPE=tap
export LKL_HIJACK_NET_IFPARAMS=lkl_ptt0
export LKL_HIJACK_NET_IP=192.168.13.2
export LKL_HIJACK_NET_NETMASK_LEN=24

sudo ip tuntap del dev $LKL_HIJACK_NET_IFPARAMS mode tap || true
sudo ip tuntap add dev $LKL_HIJACK_NET_IFPARAMS mode tap user $USER
sudo ip link set dev $LKL_HIJACK_NET_IFPARAMS up
sudo ip addr add dev $LKL_HIJACK_NET_IFPARAMS $host_ip/$LKL_HIJACK_NET_NETMASK_LEN

trap clean_with_tap EXIT
fi

sudo netserver -L $host_ip

echo NUM=$num_runs, TEST=$test_name, TASKSET=$use_taskset
for i in `seq $num_runs`; do
echo Test: $i
$taskset_cmd ${hijack_script} netperf -L $LKL_HIJACK_NET_IP -H $host_ip -t $test_name -l $test_len
done

0 comments on commit 844853e

Please sign in to comment.