diff mbox series

[net-next,4/4] netconsole: selftest: Validate CPU number auto-population in userdata

Message ID 20241113-netcon_cpu-v1-4-d187bf7c0321@debian.org (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series netconsole: Add support for CPU population | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success Errors and warnings before: 0 (+0) this patch: 0 (+0)
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch warning WARNING: line length of 111 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-14--03-00 (tests: 782)

Commit Message

Breno Leitao Nov. 13, 2024, 3:10 p.m. UTC
Expand the existing netconsole selftest to verify the functionality of
the recently added CPU number auto-population feature in the netconsole
userdata.

The changes include enabling the "populate_cpu_nr" option on the
netconsole target before sending the test data, and validating that the
received data on the listener side contains a "cpu=" entry in the
userdata, indicating that the CPU number was successfully
auto-populated.

This addition to the netconsole selftest ensures that the new CPU number
auto-population feature works as expected and helps catch any
regressions in this functionality.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 tools/testing/selftests/drivers/net/netcons_basic.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/drivers/net/netcons_basic.sh b/tools/testing/selftests/drivers/net/netcons_basic.sh
index b175f4d966e5056ddb62e335f212c03e55f50fb0..92538a188f0696b3e54071d1d32c7b2e523db839 100755
--- a/tools/testing/selftests/drivers/net/netcons_basic.sh
+++ b/tools/testing/selftests/drivers/net/netcons_basic.sh
@@ -153,6 +153,16 @@  function set_user_data() {
 	echo "${USERDATA_VALUE}" > "${VALUE_PATH}"
 }
 
+function set_cpu_nr() {
+	if [[ ! -f "${NETCONS_PATH}""/userdata/populate_cpu_nr" ]]
+	then
+		echo "Populate CPU configfs path not available in ${NETCONS_PATH}/userdata/populate_cpu_nr" >&2
+		exit "${ksft_skip}"
+	fi
+
+	echo 1 > "${NETCONS_PATH}""/userdata/populate_cpu_nr"
+}
+
 function listen_port_and_save_to() {
 	local OUTPUT=${1}
 	# Just wait for 2 seconds
@@ -185,6 +195,12 @@  function validate_result() {
 		exit "${ksft_fail}"
 	fi
 
+	if ! grep -q "cpu=[0-9]\+" "${TMPFILENAME}"; then
+		echo "FAIL: 'cpu=' not found in ${TMPFILENAME}" >&2
+		cat "${TMPFILENAME}" >&2
+		exit "${ksft_fail}"
+	fi
+
 	# Delete the file once it is validated, otherwise keep it
 	# for debugging purposes
 	rm "${TMPFILENAME}"
@@ -254,6 +270,8 @@  set_network
 create_dynamic_target
 # Set userdata "key" with the "value" value
 set_user_data
+# Auto populate CPU number
+set_cpu_nr
 # 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.