tools/testing/selftests/drivers/net/netconsole/netcons_cmdline.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/netconsole/netcons_cmdline.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/netconsole/netcons_cmdline.sh- Extension
.sh- Size
- 1988 bytes
- Lines
- 66
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0
# This is a selftest to test cmdline arguments on netconsole.
# It exercises loading of netconsole from cmdline instead of the dynamic
# reconfiguration. This includes parsing the long netconsole= line and all the
# flow through init_netconsole().
#
# Author: Breno Leitao <leitao@debian.org>
set -euo pipefail
SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
source "${SCRIPTDIR}"/../lib/sh/lib_netcons.sh
check_netconsole_module
modprobe netdevsim 2> /dev/null || true
rmmod netconsole 2> /dev/null || true
# Check for basic system dependency and exit if not found
# check_for_dependencies
# Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5)
echo "6 5" > /proc/sys/kernel/printk
# Remove the namespace and network interfaces
trap do_cleanup EXIT
# Create one namespace and two interfaces
set_network
# Run the test twice, with different cmdline parameters
for BINDMODE in "ifname" "mac"
do
echo "Running with bind mode: ${BINDMODE}" >&2
# Create the command line for netconsole, with the configuration from
# the function above
CMDLINE=$(create_cmdline_str "${BINDMODE}")
# The content of kmsg will be save to the following file
OUTPUT_FILE="/tmp/${TARGET}-${BINDMODE}"
# Load the module, with the cmdline set
modprobe netconsole "${CMDLINE}"
# Listed for netconsole port inside the namespace and destination
# interface
listen_port_and_save_to "${OUTPUT_FILE}" &
# Wait for socat to start and listen to the port.
wait_local_port_listen "${NAMESPACE}" "${PORT}" udp
# Send the message
echo "${MSG}: ${TARGET}" > /dev/kmsg
# Wait until socat saves the file to disk
busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}"
# Make sure the message was received in the dst part
# and exit
validate_msg "${OUTPUT_FILE}"
# kill socat in case it is still running
pkill_socat
# Unload the module
rmmod netconsole
echo "${BINDMODE} : Test passed" >&2
done
exit "${ksft_pass}"
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.