Skip to content

Commit 844853e

Browse files
author
Octavian Purdila
committed
Merge pull request torvalds#152 from liuyuan10/testnetperf
lkl: Add netperf TCP_RR and TCP_STREAM to make test
2 parents 987ed9f + 80535f4 commit 844853e

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

tools/lkl/tests/hijack-test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ sudo arp -d 192.168.13.2
9494
sudo ping -i 0.01 -c 65 192.168.13.2 &
9595
${hijack_script} sleep 3
9696

97+
sh ${script_dir}/run_netperf.sh 192.168.13.1 1 0 TCP_STREAM
98+
sh ${script_dir}/run_netperf.sh 192.168.13.1 1 0 TCP_RR
99+
97100
echo "== VDE tests =="
98101
if [ ! -x "$(which vde_switch)" ]; then
99102
echo "WARNING: Cannot find a vde_switch executable, skipping VDE tests."

tools/lkl/tests/run_netperf.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
# Usage
4+
# ./run_netperf.sh [host_ip] [num_runs] [use_taskset] [test_name]
5+
6+
set -e
7+
8+
script_dir=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
9+
hijack_script=${script_dir}/../bin/lkl-hijack.sh
10+
11+
num_runs="1"
12+
test_name="TCP_STREAM"
13+
use_taskset="0"
14+
host_ip="192.168.13.1"
15+
taskset_cmd="taskset -c 1"
16+
test_len=10 # second
17+
18+
if [ ! -x "$(which netperf)" ]; then
19+
echo "WARNING: Cannot find a netserver executable, skipping netperf tests."
20+
exit 0
21+
fi
22+
23+
if [ $# -ge 1 ]
24+
then
25+
host_ip=$1
26+
fi
27+
if [ $# -ge 2 ]
28+
then
29+
num_runs=$2
30+
fi
31+
if [ $# -ge 3 ]
32+
then
33+
use_taskset=$3
34+
fi
35+
if [ $# -ge 4 ]
36+
then
37+
test_name=$4
38+
fi
39+
if [ $# -ge 5 ]
40+
then
41+
echo "BAD NUMBER of INPUTS."
42+
exit 1
43+
fi
44+
45+
if [ $use_taskset = "0" ]
46+
then
47+
taskset_cmd=""
48+
fi
49+
50+
# Starts the netsever. If it fails, there is no clean up needed.
51+
existing_netserver=$(ps -ef | grep -v grep | grep -c netserver) || true
52+
53+
if [ $existing_netserver -ne 0 ]
54+
then
55+
echo "netserver is running. You must kill it."
56+
exit 1
57+
fi
58+
59+
function clean {
60+
sudo killall netserver &> /dev/null || true
61+
}
62+
63+
function clean_with_tap {
64+
sudo ip link set dev $LKL_HIJACK_NET_IFPARAMS down &> /dev/null || true
65+
sudo ip tuntap del dev $LKL_HIJACK_NET_IFPARAMS mode tap &> /dev/null || true
66+
clean
67+
}
68+
69+
trap clean EXIT
70+
71+
# LKL_HIJACK_NET_IFTYPE is not set, which means it's not called from
72+
# hijack-test.sh. Needs to set up things first.
73+
if [ -z ${LKL_HIJACK_NET_IFTYPE+x} ]
74+
then
75+
# Setting up environmental vars and TAP
76+
export LKL_HIJACK_NET_IFTYPE=tap
77+
export LKL_HIJACK_NET_IFPARAMS=lkl_ptt0
78+
export LKL_HIJACK_NET_IP=192.168.13.2
79+
export LKL_HIJACK_NET_NETMASK_LEN=24
80+
81+
sudo ip tuntap del dev $LKL_HIJACK_NET_IFPARAMS mode tap || true
82+
sudo ip tuntap add dev $LKL_HIJACK_NET_IFPARAMS mode tap user $USER
83+
sudo ip link set dev $LKL_HIJACK_NET_IFPARAMS up
84+
sudo ip addr add dev $LKL_HIJACK_NET_IFPARAMS $host_ip/$LKL_HIJACK_NET_NETMASK_LEN
85+
86+
trap clean_with_tap EXIT
87+
fi
88+
89+
sudo netserver -L $host_ip
90+
91+
echo NUM=$num_runs, TEST=$test_name, TASKSET=$use_taskset
92+
for i in `seq $num_runs`; do
93+
echo Test: $i
94+
$taskset_cmd ${hijack_script} netperf -L $LKL_HIJACK_NET_IP -H $host_ip -t $test_name -l $test_len
95+
done

0 commit comments

Comments
 (0)