tools/net/ynl/tests/test_ynl_ethtool.sh

Source file repositories/reference/linux-study-clean/tools/net/ynl/tests/test_ynl_ethtool.sh

File Facts

System
Linux kernel
Corpus path
tools/net/ynl/tests/test_ynl_ethtool.sh
Extension
.sh
Size
6293 bytes
Lines
223
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
# Test YNL ethtool functionality

# Load KTAP test helpers
KSELFTEST_KTAP_HELPERS="$(dirname "$(realpath "$0")")/../../../testing/selftests/kselftest/ktap_helpers.sh"
# shellcheck source=../../../testing/selftests/kselftest/ktap_helpers.sh
source "$KSELFTEST_KTAP_HELPERS"

# Default ynl-ethtool path for direct execution, can be overridden by make install
ynl_ethtool="./ethtool.py"

readonly NSIM_ID="1337"
readonly NSIM_DEV_NAME="nsim${NSIM_ID}"
readonly VETH_A="veth_a"
readonly VETH_B="veth_b"

testns="ynl-ethtool-$(mktemp -u XXXXXX)"
TESTS_NO=0

# Uses veth device as netdevsim doesn't support basic ethtool device info
ethtool_device_info()
{
	local info_output

	info_output=$(ip netns exec "$testns" $ynl_ethtool "$VETH_A" 2>/dev/null)

	if ! echo "$info_output" | grep -q "Settings for"; then
		ktap_test_fail "YNL ethtool device info (device info output missing expected content)"
		return
	fi

	ktap_test_pass "YNL ethtool device info"
}
TESTS_NO=$((TESTS_NO + 1))

ethtool_statistics()
{
	local stats_output

	stats_output=$(ip netns exec "$testns" $ynl_ethtool --statistics "$NSIM_DEV_NAME" 2>/dev/null)

	if ! echo "$stats_output" | grep -q -E "(NIC statistics|packets|bytes)"; then
		ktap_test_fail "YNL ethtool statistics (statistics output missing expected content)"
		return
	fi

	ktap_test_pass "YNL ethtool statistics"
}
TESTS_NO=$((TESTS_NO + 1))

ethtool_ring_params()
{
	local ring_output

	ring_output=$(ip netns exec "$testns" $ynl_ethtool --show-ring "$NSIM_DEV_NAME" 2>/dev/null)

	if ! echo "$ring_output" | grep -q -E "(Ring parameters|RX|TX)"; then
		ktap_test_fail "YNL ethtool ring parameters (ring parameters output missing expected content)"
		return
	fi

	if ! ip netns exec "$testns" $ynl_ethtool --set-ring "$NSIM_DEV_NAME" rx 64 2>/dev/null; then
		ktap_test_fail "YNL ethtool ring parameters (set-ring command failed unexpectedly)"
		return
	fi

	ktap_test_pass "YNL ethtool ring parameters (show/set)"
}
TESTS_NO=$((TESTS_NO + 1))

Annotation

Implementation Notes