tools/testing/selftests/drivers/net/virtio_net/basic_features.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/virtio_net/basic_features.sh
Extension
.sh
Size
2357 bytes
Lines
132
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

# See virtio_net_common.sh comments for more details about assumed setup

ALL_TESTS="
	initial_ping_test
	f_mac_test
"

source virtio_net_common.sh

lib_dir=$(dirname "$0")
source "$lib_dir"/../../../net/forwarding/lib.sh

h1=${NETIFS[p1]}
h2=${NETIFS[p2]}

h1_create()
{
	simple_if_init $h1 $H1_IPV4/24 $H1_IPV6/64
}

h1_destroy()
{
	simple_if_fini $h1 $H1_IPV4/24 $H1_IPV6/64
}

h2_create()
{
	simple_if_init $h2 $H2_IPV4/24 $H2_IPV6/64
}

h2_destroy()
{
	simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
}

initial_ping_test()
{
	setup_cleanup
	setup_prepare
	ping_test $h1 $H2_IPV4 " simple"
}

f_mac_test()
{
	RET=0
	local test_name="mac feature filtered"

	virtio_feature_present $h1 $VIRTIO_NET_F_MAC
	if [ $? -ne 0 ]; then
		log_test_skip "$test_name" "Device $h1 is missing feature $VIRTIO_NET_F_MAC."
		return 0
	fi
	virtio_feature_present $h1 $VIRTIO_NET_F_MAC
	if [ $? -ne 0 ]; then
		log_test_skip "$test_name" "Device $h2 is missing feature $VIRTIO_NET_F_MAC."
		return 0
	fi

	setup_cleanup
	setup_prepare

	grep -q 0 /sys/class/net/$h1/addr_assign_type
	check_err $? "Permanent address assign type for $h1 is not set"
	grep -q 0 /sys/class/net/$h2/addr_assign_type
	check_err $? "Permanent address assign type for $h2 is not set"

	setup_cleanup

Annotation

Implementation Notes