From: Breno Leitao <leitao@debian.org>
To: Breno Leitao <leitao@debian.org>,
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>, Shuah Khan <shuah@kernel.org>,
Simon Horman <horms@kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org,
Manu Bretelle <chantr4@gmail.com>,
kernel-team@meta.com
Subject: [PATCH net-next 5/6] selftests: netconsole: Add tests for 'release' feature in sysdata
Date: Fri, 14 Mar 2025 10:58:49 -0700 [thread overview]
Message-ID: <20250314-netcons_release-v1-5-07979c4b86af@debian.org> (raw)
In-Reply-To: <20250314-netcons_release-v1-0-07979c4b86af@debian.org>
Expands the self-tests to include the 'release' feature in
sysdata.
Verifies that enabling the 'release' feature appends the
correct data and ensures that disabling it functions as expected.
When enabled, the message should have an item similar to in the
userdata: `release=$(uname -r)`
Signed-off-by: Breno Leitao <leitao@debian.org>
---
.../selftests/drivers/net/netcons_sysdata.sh | 44 ++++++++++++++++++++--
1 file changed, 41 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/netcons_sysdata.sh b/tools/testing/selftests/drivers/net/netcons_sysdata.sh
index f351206ed1bda..a737e377bf085 100755
--- a/tools/testing/selftests/drivers/net/netcons_sysdata.sh
+++ b/tools/testing/selftests/drivers/net/netcons_sysdata.sh
@@ -42,6 +42,17 @@ function set_taskname() {
echo 1 > "${NETCONS_PATH}/userdata/taskname_enabled"
}
+# Enable the release to be appended to sysdata
+function set_release() {
+ if [[ ! -f "${NETCONS_PATH}/userdata/release_enabled" ]]
+ then
+ echo "Not able to enable release sysdata append. Configfs not available in ${NETCONS_PATH}/userdata/release_enabled" >&2
+ exit "${ksft_skip}"
+ fi
+
+ echo 1 > "${NETCONS_PATH}/userdata/release_enabled"
+}
+
# Disable the sysdata cpu_nr feature
function unset_cpu_nr() {
echo 0 > "${NETCONS_PATH}/userdata/cpu_nr_enabled"
@@ -52,6 +63,10 @@ function unset_taskname() {
echo 0 > "${NETCONS_PATH}/userdata/taskname_enabled"
}
+function unset_release() {
+ echo 0 > "${NETCONS_PATH}/userdata/release_enabled"
+}
+
# Test if MSG contains sysdata
function validate_sysdata() {
# OUTPUT_FILE will contain something like:
@@ -93,6 +108,21 @@ function validate_sysdata() {
pkill_socat
}
+function validate_release() {
+ RELEASE=$(uname -r)
+
+ if [ ! -f "$OUTPUT_FILE" ]; then
+ echo "FAIL: File was not generated." >&2
+ exit "${ksft_fail}"
+ fi
+
+ if ! grep -q "release=${RELEASE}" "${OUTPUT_FILE}"; then
+ echo "FAIL: 'release=${RELEASE}' not found in ${OUTPUT_FILE}" >&2
+ cat "${OUTPUT_FILE}" >&2
+ exit "${ksft_fail}"
+ fi
+}
+
# Test if MSG content exists in OUTPUT_FILE but no `cpu=` and `taskname=`
# strings
function validate_no_sysdata() {
@@ -119,6 +149,12 @@ function validate_no_sysdata() {
exit "${ksft_fail}"
fi
+ if grep -q "release=" "${OUTPUT_FILE}"; then
+ echo "FAIL: 'release= found in ${OUTPUT_FILE}" >&2
+ cat "${OUTPUT_FILE}" >&2
+ exit "${ksft_fail}"
+ fi
+
rm "${OUTPUT_FILE}"
}
@@ -169,9 +205,11 @@ MSG="Test #1 from CPU${CPU}"
set_cpu_nr
# Enable taskname to be appended to sysdata
set_taskname
+set_release
runtest
# Make sure the message was received in the dst part
# and exit
+validate_release
validate_sysdata
#====================================================
@@ -184,19 +222,19 @@ OUTPUT_FILE="/tmp/${TARGET}_2"
MSG="Test #2 from CPU${CPU}"
set_user_data
runtest
+validate_release
validate_sysdata
# ===================================================
# TEST #3
-# Unset cpu_nr, so, no CPU should be appended.
-# userdata is still set
+# Unset all sysdata, fail if any userdata is set
# ===================================================
CPU=$((RANDOM % $(nproc)))
OUTPUT_FILE="/tmp/${TARGET}_3"
MSG="Test #3 from CPU${CPU}"
-# Enable the auto population of cpu_nr
unset_cpu_nr
unset_taskname
+unset_release
runtest
# At this time, cpu= shouldn't be present in the msg
validate_no_sysdata
--
2.47.1
next prev parent reply other threads:[~2025-03-14 17:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 17:58 [PATCH net-next 0/6] netconsole: Add support for userdata release Breno Leitao
2025-03-14 17:58 ` [PATCH net-next 1/6] netconsole: introduce 'release' as a new sysdata field Breno Leitao
2025-03-19 15:40 ` Simon Horman
2025-03-14 17:58 ` [PATCH net-next 2/6] netconsole: implement configfs for release_enabled Breno Leitao
2025-03-19 15:40 ` Simon Horman
2025-03-14 17:58 ` [PATCH net-next 3/6] netconsole: add 'sysdata' suffix to related functions Breno Leitao
2025-03-19 15:41 ` Simon Horman
2025-03-14 17:58 ` [PATCH net-next 4/6] netconsole: append release to sysdata Breno Leitao
2025-03-19 15:41 ` Simon Horman
2025-03-14 17:58 ` Breno Leitao [this message]
2025-03-19 15:41 ` [PATCH net-next 5/6] selftests: netconsole: Add tests for 'release' feature in sysdata Simon Horman
2025-03-14 17:58 ` [PATCH net-next 6/6] docs: netconsole: document release feature Breno Leitao
2025-03-19 15:42 ` Simon Horman
2025-03-21 18:10 ` [PATCH net-next 0/6] netconsole: Add support for userdata release patchwork-bot+netdevbpf
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=20250314-netcons_release-v1-5-07979c4b86af@debian.org \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=chantr4@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).