mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-05-09 21:42:09 +02:00
dfa77c0dd4
The script uses set -euo pipefail, so when busywait times out waiting
for the netconsole message to arrive, it returns 1 and the script exits
immediately without printing any error message. As reported by Jakub,
this makes failures hard to diagnose since the test reports exit=1 with
no explanation.
Handle the busywait failure explicitly so that a FAIL message is printed
before exiting. This is how it looks like now:
Running with target mode: basic (ipv6)
[ 167.452561] netconsole selftest: netcons_QdMay
FAIL: Timed out waiting (20000 ms) for netconsole message in /tmp/netcons_QdMay
The remaining silent failures under set -e can only happen during the
setup phase (netdevsim creation, interface configuration, configfs
writes). So, it is not expected to have any silent failure once the test
starts.
Note that this issue might be less frequent now, since commit
a68a9bd086 ("selftests: netconsole: Increase port listening timeout")
increased the timeout that _might_ have been the root cause of these
random failures in NIPA.
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260302-netconsole_test_verbose-v1-1-b1be5d30cd7d@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
79 lines
2.5 KiB
Bash
Executable File
79 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# This test creates two netdevsim virtual interfaces, assigns one of them (the
|
|
# "destination interface") to a new namespace, and assigns IP addresses to both
|
|
# interfaces.
|
|
#
|
|
# It listens on the destination interface using socat and configures a dynamic
|
|
# target on netconsole, pointing to the destination IP address.
|
|
#
|
|
# Finally, it checks whether the message was received properly on the
|
|
# destination interface. Note that this test may pollute the kernel log buffer
|
|
# (dmesg) and relies on dynamic configuration and namespaces being configured.
|
|
#
|
|
# Author: Breno Leitao <leitao@debian.org>
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
|
|
|
|
source "${SCRIPTDIR}"/../lib/sh/lib_netcons.sh
|
|
|
|
modprobe netdevsim 2> /dev/null || true
|
|
modprobe netconsole 2> /dev/null || true
|
|
|
|
# The content of kmsg will be save to the following file
|
|
OUTPUT_FILE="/tmp/${TARGET}"
|
|
|
|
# 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
|
|
|
|
# Run the test twice, with different format modes
|
|
for FORMAT in "basic" "extended"
|
|
do
|
|
for IP_VERSION in "ipv6" "ipv4"
|
|
do
|
|
echo "Running with target mode: ${FORMAT} (${IP_VERSION})"
|
|
# Set current loglevel to KERN_INFO(6), and default to
|
|
# KERN_NOTICE(5)
|
|
echo "6 5" > /proc/sys/kernel/printk
|
|
# Create one namespace and two interfaces
|
|
set_network "${IP_VERSION}"
|
|
# Create a dynamic target for netconsole
|
|
create_dynamic_target "${FORMAT}"
|
|
# Only set userdata for extended format
|
|
if [ "$FORMAT" == "extended" ]
|
|
then
|
|
# Set userdata "key" with the "value" value
|
|
set_user_data
|
|
fi
|
|
# Listed for netconsole port inside the namespace and
|
|
# destination interface
|
|
listen_port_and_save_to "${OUTPUT_FILE}" "${IP_VERSION}" &
|
|
# Wait for socat to start and listen to the port.
|
|
wait_for_port "${NAMESPACE}" "${PORT}" "${IP_VERSION}"
|
|
# Send the message
|
|
echo "${MSG}: ${TARGET}" > /dev/kmsg
|
|
# Wait until socat saves the file to disk
|
|
if ! busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}"
|
|
then
|
|
echo "FAIL: Timed out waiting (${BUSYWAIT_TIMEOUT} ms) for netconsole message in ${OUTPUT_FILE}" >&2
|
|
exit "${ksft_fail}"
|
|
fi
|
|
|
|
# Make sure the message was received in the dst part
|
|
# and exit
|
|
validate_result "${OUTPUT_FILE}" "${FORMAT}"
|
|
# kill socat in case it is still running
|
|
pkill_socat
|
|
cleanup
|
|
echo "${FORMAT} : ${IP_VERSION} : Test passed" >&2
|
|
done
|
|
done
|
|
|
|
trap - EXIT
|
|
exit "${ksft_pass}"
|