tools/testing/selftests/drivers/net/netconsole/netcons_overflow.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/netconsole/netcons_overflow.sh
Extension
.sh
Size
1845 bytes
Lines
68
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

function create_userdata_max_entries() {
	# All these keys should be created without any error
	for i in $(seq $MAX_USERDATA_ITEMS)
	do
		# USERDATA_KEY is used by set_user_data
		USERDATA_KEY="key"${i}
		set_user_data
	done
}

# Function to verify the entry limit
function verify_entry_limit() {
	# Allowing the test to fail without exiting, since the next command
	# will fail
	set +e
	mkdir "${NETCONS_PATH}/userdata/key_that_will_fail" 2> /dev/null
	ret="$?"
	set -e
	if [ "$ret" -eq 0 ];
	then
		echo "Adding more than ${MAX_USERDATA_ITEMS} entries in userdata should fail, but it didn't" >&2
		ls "${NETCONS_PATH}/userdata/" >&2
		exit "${ksft_fail}"
	fi
}

# ========== #
# Start here #
# ========== #

modprobe netdevsim 2> /dev/null || true
modprobe netconsole 2> /dev/null || true

# Check for basic system dependency and exit if not found
check_for_dependencies

# Remove the namespace, interfaces and netconsole target on exit
trap cleanup EXIT
# Create one namespace and two interfaces
set_network
# Create a dynamic target for netconsole
create_dynamic_target
# populate the maximum number of supported keys in userdata
create_userdata_max_entries
# Verify an additional entry is not allowed
verify_entry_limit
exit "${ksft_pass}"

Annotation

Implementation Notes