tools/testing/selftests/net/forwarding/sch_ets_tests.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/forwarding/sch_ets_tests.sh
Extension
.sh
Size
4431 bytes
Lines
235
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

# SPDX-License-Identifier: GPL-2.0

# Global interface:
#  $put -- port under test (e.g. $swp2)
#  collect_stats($streams...) -- A function to get stats for individual streams
#  ets_start_traffic($band) -- Start traffic for this band
#  ets_change_qdisc($op, $dev, $nstrict, $quanta...) -- Add or change qdisc

# WS describes the Qdisc configuration. It has one value per band (so the
# number of array elements indicates the number of bands). If the value is
# 0, it is a strict band, otherwise the it's a DRR band and the value is
# that band's quantum.
declare -a WS

qdisc_describe()
{
	local nbands=${#WS[@]}
	local nstrict=0
	local i

	for ((i = 0; i < nbands; i++)); do
		if ((!${WS[$i]})); then
			: $((nstrict++))
		fi
	done

	echo -n "ets bands $nbands"
	if ((nstrict)); then
		echo -n " strict $nstrict"
	fi
	if ((nstrict < nbands)); then
		echo -n " quanta"
		for ((i = nstrict; i < nbands; i++)); do
			echo -n " ${WS[$i]}"
		done
	fi
}

__strict_eval()
{
	local desc=$1; shift
	local d=$1; shift
	local total=$1; shift
	local above=$1; shift

	RET=0

	if ((! total)); then
		check_err 1 "No traffic observed"
		log_test "$desc"
		return
	fi

	local ratio=$(echo "scale=2; 100 * $d / $total" | bc -l)
	if ((above)); then
		test $(echo "$ratio > 95.0" | bc -l) -eq 1
		check_err $? "Not enough traffic"
		log_test "$desc"
		log_info "Expected ratio >95% Measured ratio $ratio"
	else
		test $(echo "$ratio < 5" | bc -l) -eq 1
		check_err $? "Too much traffic"
		log_test "$desc"
		log_info "Expected ratio <5% Measured ratio $ratio"
	fi
}

strict_eval()
{
	__strict_eval "$@" 1

Annotation

Implementation Notes