2018-10-11 11:54:53 +03:00
#!/bin/bash
2018-04-26 20:42:25 +03:00
# SPDX-License-Identifier: GPL-2.0
#
# Run a series of udpgso benchmarks
2019-06-18 23:03:04 +03:00
readonly GREEN = '\033[0;92m'
readonly YELLOW = '\033[0;33m'
readonly RED = '\033[0;31m'
readonly NC = '\033[0m' # No Color
readonly KSFT_PASS = 0
readonly KSFT_FAIL = 1
readonly KSFT_SKIP = 4
num_pass = 0
num_err = 0
num_skip = 0
kselftest_test_exitcode( ) {
local -r exitcode = $1
if [ [ ${ exitcode } -eq ${ KSFT_PASS } ] ] ; then
num_pass = $(( $num_pass + 1 ))
elif [ [ ${ exitcode } -eq ${ KSFT_SKIP } ] ] ; then
num_skip = $(( $num_skip + 1 ))
else
num_err = $(( $num_err + 1 ))
fi
}
kselftest_exit( ) {
echo -e " $( basename $0 ) : PASS= ${ num_pass } SKIP= ${ num_skip } FAIL= ${ num_err } "
if [ [ $num_err -ne 0 ] ] ; then
echo -e " $( basename $0 ) : ${ RED } FAIL ${ NC } "
exit ${ KSFT_FAIL }
fi
if [ [ $num_skip -ne 0 ] ] ; then
echo -e " $( basename $0 ) : ${ YELLOW } SKIP ${ NC } "
exit ${ KSFT_SKIP }
fi
echo -e " $( basename $0 ) : ${ GREEN } PASS ${ NC } "
exit ${ KSFT_PASS }
}
2019-06-17 22:08:37 +03:00
2018-04-26 20:42:25 +03:00
wake_children( ) {
local -r jobs = " $( jobs -p) "
if [ [ " ${ jobs } " != "" ] ] ; then
kill -1 ${ jobs } 2>/dev/null
fi
}
trap wake_children EXIT
run_one( ) {
local -r args = $@
./udpgso_bench_rx &
./udpgso_bench_rx -t &
./udpgso_bench_tx ${ args }
}
run_in_netns( ) {
local -r args = $@
./in_netns.sh $0 __subprocess ${ args }
2019-06-18 23:03:04 +03:00
kselftest_test_exitcode $?
2018-04-26 20:42:25 +03:00
}
run_udp( ) {
local -r args = $@
echo "udp"
run_in_netns ${ args }
echo "udp gso"
2018-11-07 14:38:37 +03:00
run_in_netns ${ args } -S 0
2018-11-30 23:32:41 +03:00
echo "udp gso zerocopy"
run_in_netns ${ args } -S 0 -z
2019-06-17 22:08:36 +03:00
echo "udp gso timestamp"
run_in_netns ${ args } -S 0 -T
echo "udp gso zerocopy audit"
run_in_netns ${ args } -S 0 -z -a
echo "udp gso timestamp audit"
run_in_netns ${ args } -S 0 -T -a
echo "udp gso zerocopy timestamp audit"
run_in_netns ${ args } -S 0 -T -z -a
2018-04-26 20:42:25 +03:00
}
run_tcp( ) {
local -r args = $@
echo "tcp"
run_in_netns ${ args } -t
echo "tcp zerocopy"
run_in_netns ${ args } -t -z
2019-06-17 22:08:36 +03:00
# excluding for now because test fails intermittently
# add -P option to include poll() to reduce possibility of lost messages
#echo "tcp zerocopy audit"
#run_in_netns ${args} -t -z -P -a
2018-04-26 20:42:25 +03:00
}
run_all( ) {
2019-06-17 22:08:36 +03:00
local -r core_args = "-l 3"
2018-04-26 20:42:25 +03:00
local -r ipv4_args = " ${ core_args } -4 -D 127.0.0.1 "
local -r ipv6_args = " ${ core_args } -6 -D ::1 "
echo "ipv4"
run_tcp " ${ ipv4_args } "
run_udp " ${ ipv4_args } "
echo "ipv6"
2022-06-23 03:02:34 +03:00
run_tcp " ${ ipv6_args } "
2018-04-26 20:42:25 +03:00
run_udp " ${ ipv6_args } "
}
if [ [ $# -eq 0 ] ] ; then
run_all
2019-06-18 23:03:04 +03:00
kselftest_exit
2018-04-26 20:42:25 +03:00
elif [ [ $1 = = "__subprocess" ] ] ; then
shift
run_one $@
else
run_in_netns $@
fi