tools/testing/selftests/net/udpgso_bench.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/udpgso_bench.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/udpgso_bench.sh
Extension
.sh
Size
2899 bytes
Lines
155
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Run a series of udpgso benchmarks

readonly GREEN='\033[0;92m'
readonly YELLOW='\033[0;33m'
readonly RED='\033[0;31m'
readonly NC='\033[0m' # No Color
readonly TESTPORT=8000

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}
}

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=$@
	local nr_socks=0
	local i=0
	local -r timeout=10

	./udpgso_bench_rx -p "$TESTPORT" &
	./udpgso_bench_rx -p "$TESTPORT" -t &

	# Wait for the above test program to get ready to receive connections.
	while [ "$i" -lt "$timeout" ]; do
		nr_socks="$(ss -lnHi | grep -c "\*:${TESTPORT}")"
		[ "$nr_socks" -eq 2 ] && break

Annotation

Implementation Notes