Path: blob/master/tools/testing/selftests/drivers/net/netcons_overflow.sh
26288 views
#!/usr/bin/env bash1# SPDX-License-Identifier: GPL-2.023# This test verifies that users can successfully create up to4# MAX_USERDATA_ITEMS userdata entries without encountering any failures.5#6# Additionally, it tests for expected failure when attempting to exceed this7# maximum limit.8#9# Author: Breno Leitao <[email protected]>1011set -euo pipefail1213SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")1415source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh16# This is coming from netconsole code. Check for it in drivers/net/netconsole.c17MAX_USERDATA_ITEMS=161819# Function to create userdata entries20function create_userdata_max_entries() {21# All these keys should be created without any error22for i in $(seq $MAX_USERDATA_ITEMS)23do24# USERDATA_KEY is used by set_user_data25USERDATA_KEY="key"${i}26set_user_data27done28}2930# Function to verify the entry limit31function verify_entry_limit() {32# Allowing the test to fail without exiting, since the next command33# will fail34set +e35mkdir "${NETCONS_PATH}/userdata/key_that_will_fail" 2> /dev/null36ret="$?"37set -e38if [ "$ret" -eq 0 ];39then40echo "Adding more than ${MAX_USERDATA_ITEMS} entries in userdata should fail, but it didn't" >&241ls "${NETCONS_PATH}/userdata/" >&242exit "${ksft_fail}"43fi44}4546# ========== #47# Start here #48# ========== #4950modprobe netdevsim 2> /dev/null || true51modprobe netconsole 2> /dev/null || true5253# Check for basic system dependency and exit if not found54check_for_dependencies5556# Remove the namespace, interfaces and netconsole target on exit57trap cleanup EXIT58# Create one namespace and two interfaces59set_network60# Create a dynamic target for netconsole61create_dynamic_target62# populate the maximum number of supported keys in userdata63create_userdata_max_entries64# Verify an additional entry is not allowed65verify_entry_limit66exit "${ksft_pass}"676869