From: Breno Leitao <leitao@debian.org>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH net-next 7/7] netconsole: selftest: add task name append testing
Date: Fri, 21 Feb 2025 05:52:12 -0800 [thread overview]
Message-ID: <20250221-netcons_current-v1-7-21c86ae8fc0d@debian.org> (raw)
In-Reply-To: <20250221-netcons_current-v1-0-21c86ae8fc0d@debian.org>
Add test coverage for the netconsole task name feature to the existing
sysdata selftest script. This extends the test infrastructure to verify
that task names are correctly appended when enabled and absent when
disabled.
The test validates that:
- Task names appear in the expected format "taskname=<name>"
- Task names are included when the feature is enabled
- Task names are excluded when the feature is disabled
- The feature works correctly alongside other sysdata fields like CPU
Signed-off-by: Breno Leitao <leitao@debian.org>
---
.../selftests/drivers/net/netcons_sysdata.sh | 51 +++++++++++++++++++---
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/netcons_sysdata.sh b/tools/testing/selftests/drivers/net/netcons_sysdata.sh
index 2b78fd1f5982fee81b379bf9ac6f64a38d915974..f351206ed1bda4d46269a521b27b9b8e56d524be 100755
--- a/tools/testing/selftests/drivers/net/netcons_sysdata.sh
+++ b/tools/testing/selftests/drivers/net/netcons_sysdata.sh
@@ -31,17 +31,38 @@ function set_cpu_nr() {
echo 1 > "${NETCONS_PATH}/userdata/cpu_nr_enabled"
}
+# Enable the taskname to be appended to sysdata
+function set_taskname() {
+ if [[ ! -f "${NETCONS_PATH}/userdata/taskname_enabled" ]]
+ then
+ echo "Not able to enable taskname sysdata append. Configfs not available in ${NETCONS_PATH}/userdata/taskname_enabled" >&2
+ exit "${ksft_skip}"
+ fi
+
+ echo 1 > "${NETCONS_PATH}/userdata/taskname_enabled"
+}
+
# Disable the sysdata cpu_nr feature
function unset_cpu_nr() {
echo 0 > "${NETCONS_PATH}/userdata/cpu_nr_enabled"
}
-# Test if MSG content and `cpu=${CPU}` exists in OUTPUT_FILE
-function validate_sysdata_cpu_exists() {
+# Once called, taskname=<..> will not be appended anymore
+function unset_taskname() {
+ echo 0 > "${NETCONS_PATH}/userdata/taskname_enabled"
+}
+
+# Test if MSG contains sysdata
+function validate_sysdata() {
# OUTPUT_FILE will contain something like:
# 6.11.1-0_fbk0_rc13_509_g30d75cea12f7,13,1822,115075213798,-;netconsole selftest: netcons_gtJHM
# userdatakey=userdatavalue
# cpu=X
+ # taskname=<taskname>
+
+ # Echo is what this test uses to create the message. See runtest()
+ # function
+ SENDER="echo"
if [ ! -f "$OUTPUT_FILE" ]; then
echo "FAIL: File was not generated." >&2
@@ -62,12 +83,19 @@ function validate_sysdata_cpu_exists() {
exit "${ksft_fail}"
fi
+ if ! grep -q "taskname=${SENDER}" "${OUTPUT_FILE}"; then
+ echo "FAIL: 'taskname=echo' not found in ${OUTPUT_FILE}" >&2
+ cat "${OUTPUT_FILE}" >&2
+ exit "${ksft_fail}"
+ fi
+
rm "${OUTPUT_FILE}"
pkill_socat
}
-# Test if MSG content exists in OUTPUT_FILE but no `cpu=` string
-function validate_sysdata_no_cpu() {
+# Test if MSG content exists in OUTPUT_FILE but no `cpu=` and `taskname=`
+# strings
+function validate_no_sysdata() {
if [ ! -f "$OUTPUT_FILE" ]; then
echo "FAIL: File was not generated." >&2
exit "${ksft_fail}"
@@ -85,6 +113,12 @@ function validate_sysdata_no_cpu() {
exit "${ksft_fail}"
fi
+ if grep -q "taskname=" "${OUTPUT_FILE}"; then
+ echo "FAIL: 'taskname= found in ${OUTPUT_FILE}" >&2
+ cat "${OUTPUT_FILE}" >&2
+ exit "${ksft_fail}"
+ fi
+
rm "${OUTPUT_FILE}"
}
@@ -133,10 +167,12 @@ OUTPUT_FILE="/tmp/${TARGET}_1"
MSG="Test #1 from CPU${CPU}"
# Enable the auto population of cpu_nr
set_cpu_nr
+# Enable taskname to be appended to sysdata
+set_taskname
runtest
# Make sure the message was received in the dst part
# and exit
-validate_sysdata_cpu_exists
+validate_sysdata
#====================================================
# TEST #2
@@ -148,7 +184,7 @@ OUTPUT_FILE="/tmp/${TARGET}_2"
MSG="Test #2 from CPU${CPU}"
set_user_data
runtest
-validate_sysdata_cpu_exists
+validate_sysdata
# ===================================================
# TEST #3
@@ -160,8 +196,9 @@ OUTPUT_FILE="/tmp/${TARGET}_3"
MSG="Test #3 from CPU${CPU}"
# Enable the auto population of cpu_nr
unset_cpu_nr
+unset_taskname
runtest
# At this time, cpu= shouldn't be present in the msg
-validate_sysdata_no_cpu
+validate_no_sysdata
exit "${ksft_pass}"
--
2.43.5
next prev parent reply other threads:[~2025-02-21 13:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 13:52 [PATCH net-next 0/7] netconsole: Add taskname sysdata support Breno Leitao
2025-02-21 13:52 ` [PATCH net-next 1/7] netconsole: prefix CPU_NR sysdata feature with SYSDATA_ Breno Leitao
2025-02-25 10:19 ` Simon Horman
2025-02-21 13:52 ` [PATCH net-next 2/7] netconsole: refactor CPU number formatting into separate function Breno Leitao
2025-02-25 10:17 ` Simon Horman
2025-02-25 11:09 ` Breno Leitao
2025-02-25 14:08 ` Simon Horman
2025-02-21 13:52 ` [PATCH net-next 3/7] netconsole: add taskname to extradata entry count Breno Leitao
2025-02-25 10:20 ` Simon Horman
2025-02-21 13:52 ` [PATCH net-next 4/7] netconsole: add configfs controls for taskname sysdata feature Breno Leitao
2025-02-25 10:20 ` Simon Horman
2025-02-25 11:41 ` Paolo Abeni
2025-02-25 13:12 ` Breno Leitao
2025-02-21 13:52 ` [PATCH net-next 5/7] netconsole: add task name to extra data fields Breno Leitao
2025-02-25 10:19 ` Simon Horman
2025-02-25 11:17 ` Breno Leitao
2025-02-25 11:53 ` Paolo Abeni
2025-02-25 13:11 ` Breno Leitao
2025-03-04 14:23 ` Paolo Abeni
2025-02-25 14:10 ` Simon Horman
2025-02-21 13:52 ` [PATCH net-next 6/7] netconsole: docs: document the task name feature Breno Leitao
2025-02-25 10:20 ` Simon Horman
2025-02-21 13:52 ` Breno Leitao [this message]
2025-02-25 10:21 ` [PATCH net-next 7/7] netconsole: selftest: add task name append testing Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250221-netcons_current-v1-7-21c86ae8fc0d@debian.org \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox