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

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

File Facts

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

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0

# Repeatedly send kernel messages, toggles netconsole targets on and off,
# creates and deletes targets in parallel, and toggles the source interface to
# simulate stress conditions.
#
# This test aims to verify the robustness of netconsole under dynamic
# configurations and concurrent operations.
#
# The major goal is to run this test with LOCKDEP, Kmemleak and KASAN to make
# sure no issues is reported.
#
# Author: Breno Leitao <leitao@debian.org>

set -euo pipefail

SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")

source "${SCRIPTDIR}"/../lib/sh/lib_netcons.sh

# Number of times the main loop run
ITERATIONS=${1:-150}

# Only test extended format
FORMAT="extended"
# And ipv6 only
IP_VERSION="ipv6"

# Create, enable and delete some targets.
create_and_delete_random_target() {
	COUNT=2
	RND_PREFIX=$(mktemp -u netcons_rnd_XXXX_)

	if [ -d "${NETCONS_CONFIGFS}/${RND_PREFIX}${COUNT}"  ] || \
	   [ -d "${NETCONS_CONFIGFS}/${RND_PREFIX}0" ]; then
		echo "Function didn't finish yet, skipping it." >&2
		return
	fi

	# enable COUNT targets
	for i in $(seq ${COUNT})
	do
		RND_TARGET="${RND_PREFIX}"${i}
		RND_TARGET_PATH="${NETCONS_CONFIGFS}"/"${RND_TARGET}"

		# Basic population so the target can come up
		_create_dynamic_target "${FORMAT}" "${RND_TARGET_PATH}"
	done

	echo "netconsole selftest: ${COUNT} additional targets were created" > /dev/kmsg
	# disable them all
	for i in $(seq ${COUNT})
	do
		RND_TARGET="${RND_PREFIX}"${i}
		RND_TARGET_PATH="${NETCONS_CONFIGFS}"/"${RND_TARGET}"
		if [[ $(cat "${RND_TARGET_PATH}/enabled") -eq 1 ]]
		then
			echo 0 > "${RND_TARGET_PATH}"/enabled
		fi
		rmdir "${RND_TARGET_PATH}"
	done
}

# Disable and enable the target mid-air, while messages
# are being transmitted.
toggle_netcons_target() {
	for i in $(seq 2)
	do
		if [ ! -d "${NETCONS_PATH}" ]

Annotation

Implementation Notes