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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tools/testing/selftests/drivers/net/netcons_basic.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

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.

-- 
2.43.5





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux