Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'selftest-netconsole-enhance-selftest-to-validate-userdata-transmission'

Breno Leitao says:

====================
selftest: netconsole: Enhance selftest to validate userdata transmission

The netconsole selftest has been extended to cover userdata, a
significant subsystem within netconsole. This patch introduces support
for testing userdata by appending a key-value pair and verifying its
successful transmission via netconsole/netpoll.

Additionally, this patchseries addresses a pending change in the subnet
configuration for the selftest.

v1: https://lore.kernel.org/20241025161415.238215-1-leitao@debian.org
====================

Link: https://patch.msgid.link/20241029090030.1793551-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+31 -2
+31 -2
tools/testing/selftests/drivers/net/netcons_basic.sh
··· 20 20 21 21 # Simple script to test dynamic targets in netconsole 22 22 SRCIF="" # to be populated later 23 - SRCIP=192.168.1.1 23 + SRCIP=192.0.2.1 24 24 DSTIF="" # to be populated later 25 - DSTIP=192.168.1.2 25 + DSTIP=192.0.2.2 26 26 27 27 PORT="6666" 28 28 MSG="netconsole selftest" 29 + USERDATA_KEY="key" 30 + USERDATA_VALUE="value" 29 31 TARGET=$(mktemp -u netcons_XXXXX) 30 32 DEFAULT_PRINTK_VALUES=$(cat /proc/sys/kernel/printk) 31 33 NETCONS_CONFIGFS="/sys/kernel/config/netconsole" 32 34 NETCONS_PATH="${NETCONS_CONFIGFS}"/"${TARGET}" 35 + KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}" 33 36 # NAMESPACE will be populated by setup_ns with a random value 34 37 NAMESPACE="" 35 38 ··· 125 122 126 123 # delete netconsole dynamic reconfiguration 127 124 echo 0 > "${NETCONS_PATH}"/enabled 125 + # Remove key 126 + rmdir "${KEY_PATH}" 128 127 # Remove the configfs entry 129 128 rmdir "${NETCONS_PATH}" 130 129 ··· 141 136 echo "${DEFAULT_PRINTK_VALUES}" > /proc/sys/kernel/printk 142 137 } 143 138 139 + function set_user_data() { 140 + if [[ ! -d "${NETCONS_PATH}""/userdata" ]] 141 + then 142 + echo "Userdata path not available in ${NETCONS_PATH}/userdata" 143 + exit "${ksft_skip}" 144 + fi 145 + 146 + mkdir -p "${KEY_PATH}" 147 + VALUE_PATH="${KEY_PATH}""/value" 148 + echo "${USERDATA_VALUE}" > "${VALUE_PATH}" 149 + } 150 + 144 151 function listen_port_and_save_to() { 145 152 local OUTPUT=${1} 146 153 # Just wait for 2 seconds ··· 163 146 function validate_result() { 164 147 local TMPFILENAME="$1" 165 148 149 + # TMPFILENAME will contain something like: 150 + # 6.11.1-0_fbk0_rc13_509_g30d75cea12f7,13,1822,115075213798,-;netconsole selftest: netcons_gtJHM 151 + # key=value 152 + 166 153 # Check if the file exists 167 154 if [ ! -f "$TMPFILENAME" ]; then 168 155 echo "FAIL: File was not generated." >&2 ··· 175 154 176 155 if ! grep -q "${MSG}" "${TMPFILENAME}"; then 177 156 echo "FAIL: ${MSG} not found in ${TMPFILENAME}" >&2 157 + cat "${TMPFILENAME}" >&2 158 + exit "${ksft_fail}" 159 + fi 160 + 161 + if ! grep -q "${USERDATA_KEY}=${USERDATA_VALUE}" "${TMPFILENAME}"; then 162 + echo "FAIL: ${USERDATA_KEY}=${USERDATA_VALUE} not found in ${TMPFILENAME}" >&2 178 163 cat "${TMPFILENAME}" >&2 179 164 exit "${ksft_fail}" 180 165 fi ··· 247 220 set_network 248 221 # Create a dynamic target for netconsole 249 222 create_dynamic_target 223 + # Set userdata "key" with the "value" value 224 + set_user_data 250 225 # Listed for netconsole port inside the namespace and destination interface 251 226 listen_port_and_save_to "${OUTPUT_FILE}" & 252 227 # Wait for socat to start and listen to the port.