tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh
Extension
.sh
Size
7685 bytes
Lines
335
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
#
# In addition to the common variables, user might use:
# LC_SLOT - If not set, all probed line cards are going to be tested,
#	    with an exception of the "activation_16x100G_test".
#	    It set, only the selected line card is going to be used
#	    for tests, including "activation_16x100G_test".

lib_dir=$(dirname $0)/../../../net/forwarding

ALL_TESTS="
	unprovision_test
	provision_test
	activation_16x100G_test
"

NUM_NETIFS=0

source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh

until_lc_state_is()
{
	local state=$1; shift
	local current=$("$@")

	echo "$current"
	[ "$current" == "$state" ]
}

until_lc_state_is_not()
{
	! until_lc_state_is "$@"
}

lc_state_get()
{
	local lc=$1

	devlink lc show $DEVLINK_DEV lc $lc -j | jq -e -r ".[][][].state"
}

lc_wait_until_state_changes()
{
	local lc=$1
	local state=$2
	local timeout=$3 # ms

	busywait "$timeout" until_lc_state_is_not "$state" lc_state_get "$lc"
}

lc_wait_until_state_becomes()
{
	local lc=$1
	local state=$2
	local timeout=$3 # ms

	busywait "$timeout" until_lc_state_is "$state" lc_state_get "$lc"
}

until_lc_port_count_is()
{
	local port_count=$1; shift
	local current=$("$@")

	echo "$current"
	[ $current == $port_count ]
}

Annotation

Implementation Notes