tools/net/ynl/tests/test_ynl_cli.sh
Source file repositories/reference/linux-study-clean/tools/net/ynl/tests/test_ynl_cli.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/net/ynl/tests/test_ynl_cli.sh- Extension
.sh- Size
- 10312 bytes
- Lines
- 328
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Test YNL CLI 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 path for direct execution, can be overridden by make install
ynl="../pyynl/cli.py"
readonly NSIM_ID="1338"
readonly NSIM_DEV_NAME="nsim${NSIM_ID}"
readonly VETH_A="veth_a"
readonly VETH_B="veth_b"
testns="ynl-$(mktemp -u XXXXXX)"
TESTS_NO=0
# Test listing available families
cli_list_families()
{
if $ynl --list-families &>/dev/null; then
ktap_test_pass "YNL CLI list families"
else
ktap_test_fail "YNL CLI list families"
fi
}
TESTS_NO=$((TESTS_NO + 1))
# Test netdev family operations (dev-get, queue-get)
cli_netdev_ops()
{
local dev_output
local ifindex
ifindex=$(ip netns exec "$testns" cat /sys/class/net/"$NSIM_DEV_NAME"/ifindex 2>/dev/null)
dev_output=$(ip netns exec "$testns" $ynl --family netdev \
--do dev-get --json "{\"ifindex\": $ifindex}" 2>/dev/null)
if ! echo "$dev_output" | grep -q "ifindex"; then
ktap_test_fail "YNL CLI netdev operations (netdev dev-get output missing ifindex)"
return
fi
if ! ip netns exec "$testns" $ynl --family netdev \
--dump queue-get --json "{\"ifindex\": $ifindex}" &>/dev/null; then
ktap_test_fail "YNL CLI netdev operations (failed to get netdev queue info)"
return
fi
ktap_test_pass "YNL CLI netdev operations"
}
TESTS_NO=$((TESTS_NO + 1))
# Test ethtool family operations (rings-get, linkinfo-get)
cli_ethtool_ops()
{
local rings_output
local linkinfo_output
rings_output=$(ip netns exec "$testns" $ynl --family ethtool \
--do rings-get --json "{\"header\": {\"dev-name\": \"$NSIM_DEV_NAME\"}}" 2>/dev/null)
if ! echo "$rings_output" | grep -q "header"; then
ktap_test_fail "YNL CLI ethtool operations (ethtool rings-get output missing header)"
return
fi
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.