tools/testing/selftests/drivers/net/team/options.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/team/options.sh
Extension
.sh
Size
8614 bytes
Lines
286
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

# These tests verify basic set and get functionality of the team
# driver options over netlink.

# Run in private netns.
test_dir="$(dirname "$0")"
if [[ $# -eq 0 ]]; then
        "${test_dir}"/../../../net/in_netns.sh "$0" __subprocess
        exit $?
fi

export ALL_TESTS="
        team_test_options
        team_test_enabled_implicit_changes
        team_test_rx_enabled_implicit_changes
        team_test_tx_enabled_implicit_changes
"

# shellcheck disable=SC1091
source "${test_dir}/../../../net/lib.sh"

TEAM_PORT="team0"
MEMBER_PORT="dummy0"

setup()
{
        ip link add name "${MEMBER_PORT}" type dummy
        ip link add name "${TEAM_PORT}" type team
}

get_and_check_value()
{
        local option_name="$1"
        local expected_value="$2"
        local port_flag="$3"

        local value_from_get

        if ! value_from_get=$(teamnl "${TEAM_PORT}" getoption "${option_name}" \
                        "${port_flag}"); then
                echo "Could not get option '${option_name}'" >&2
                return 1
        fi

        if [[ "${value_from_get}" != "${expected_value}" ]]; then
                echo "Incorrect value for option '${option_name}'" >&2
                echo "get (${value_from_get}) != set (${expected_value})" >&2
                return 1
        fi
}

set_and_check_get()
{
        local option_name="$1"
        local option_value="$2"
        local port_flag="$3"

        local value_from_get

        if ! teamnl "${TEAM_PORT}" setoption "${option_name}" \
                        "${option_value}" "${port_flag}"; then
                echo "'setoption ${option_name} ${option_value}' failed" >&2
                return 1
        fi

        get_and_check_value "${option_name}" "${option_value}" "${port_flag}"
        return $?
}

Annotation

Implementation Notes