WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / udpgso_bench.sh
blob80b5d352702e57f85ce621df094a946ebd5f68df
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Run a series of udpgso benchmarks
6 readonly GREEN='\033[0;92m'
7 readonly YELLOW='\033[0;33m'
8 readonly RED='\033[0;31m'
9 readonly NC='\033[0m' # No Color
11 readonly KSFT_PASS=0
12 readonly KSFT_FAIL=1
13 readonly KSFT_SKIP=4
15 num_pass=0
16 num_err=0
17 num_skip=0
19 kselftest_test_exitcode() {
20 local -r exitcode=$1
22 if [[ ${exitcode} -eq ${KSFT_PASS} ]]; then
23 num_pass=$(( $num_pass + 1 ))
24 elif [[ ${exitcode} -eq ${KSFT_SKIP} ]]; then
25 num_skip=$(( $num_skip + 1 ))
26 else
27 num_err=$(( $num_err + 1 ))
31 kselftest_exit() {
32 echo -e "$(basename $0): PASS=${num_pass} SKIP=${num_skip} FAIL=${num_err}"
34 if [[ $num_err -ne 0 ]]; then
35 echo -e "$(basename $0): ${RED}FAIL${NC}"
36 exit ${KSFT_FAIL}
39 if [[ $num_skip -ne 0 ]]; then
40 echo -e "$(basename $0): ${YELLOW}SKIP${NC}"
41 exit ${KSFT_SKIP}
44 echo -e "$(basename $0): ${GREEN}PASS${NC}"
45 exit ${KSFT_PASS}
48 wake_children() {
49 local -r jobs="$(jobs -p)"
51 if [[ "${jobs}" != "" ]]; then
52 kill -1 ${jobs} 2>/dev/null
55 trap wake_children EXIT
57 run_one() {
58 local -r args=$@
60 ./udpgso_bench_rx &
61 ./udpgso_bench_rx -t &
63 ./udpgso_bench_tx ${args}
66 run_in_netns() {
67 local -r args=$@
69 ./in_netns.sh $0 __subprocess ${args}
70 kselftest_test_exitcode $?
73 run_udp() {
74 local -r args=$@
76 echo "udp"
77 run_in_netns ${args}
79 echo "udp gso"
80 run_in_netns ${args} -S 0
82 echo "udp gso zerocopy"
83 run_in_netns ${args} -S 0 -z
85 echo "udp gso timestamp"
86 run_in_netns ${args} -S 0 -T
88 echo "udp gso zerocopy audit"
89 run_in_netns ${args} -S 0 -z -a
91 echo "udp gso timestamp audit"
92 run_in_netns ${args} -S 0 -T -a
94 echo "udp gso zerocopy timestamp audit"
95 run_in_netns ${args} -S 0 -T -z -a
98 run_tcp() {
99 local -r args=$@
101 echo "tcp"
102 run_in_netns ${args} -t
104 echo "tcp zerocopy"
105 run_in_netns ${args} -t -z
107 # excluding for now because test fails intermittently
108 # add -P option to include poll() to reduce possibility of lost messages
109 #echo "tcp zerocopy audit"
110 #run_in_netns ${args} -t -z -P -a
113 run_all() {
114 local -r core_args="-l 3"
115 local -r ipv4_args="${core_args} -4 -D 127.0.0.1"
116 local -r ipv6_args="${core_args} -6 -D ::1"
118 echo "ipv4"
119 run_tcp "${ipv4_args}"
120 run_udp "${ipv4_args}"
122 echo "ipv6"
123 run_tcp "${ipv4_args}"
124 run_udp "${ipv6_args}"
127 if [[ $# -eq 0 ]]; then
128 run_all
129 kselftest_exit
130 elif [[ $1 == "__subprocess" ]]; then
131 shift
132 run_one $@
133 else
134 run_in_netns $@