aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorBreno Leitao <leitao@debian.org>2025-01-08 03:50:27 -0800
committerJakub Kicinski <kuba@kernel.org>2025-01-09 18:06:36 -0800
commit7dcb65351b30500a759c857590b73b98c05ac7fd (patch)
tree16dd7bc8dd17e8928dbd5ad279ca997aa6a10f18
parentnetconsole: selftest: Split the helpers from the selftest (diff)
downloadwireguard-linux-7dcb65351b30500a759c857590b73b98c05ac7fd.tar.xz
wireguard-linux-7dcb65351b30500a759c857590b73b98c05ac7fd.zip
netconsole: selftest: Delete all userdata keys
Modify the cleanup function to remove all userdata keys created during the test, instead of just deleting a single predefined key. This ensures a more thorough cleanup of temporary resources. Move the KEY_PATH variable definition inside the set_user_data function to reduce global variables and improve encapsulation. The KEY_PATH variable is now dynamically created when setting user data. This change has no effect on the current test, while improving an upcoming test that would create several userdata entries. Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250108-netcons_overflow_test-v3-3-3d85eb091bec@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
index fdd45a3468f1..3acaba41ac7b 100644
--- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
+++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
@@ -23,7 +23,6 @@ TARGET=$(mktemp -u netcons_XXXXX)
DEFAULT_PRINTK_VALUES=$(cat /proc/sys/kernel/printk)
NETCONS_CONFIGFS="/sys/kernel/config/netconsole"
NETCONS_PATH="${NETCONS_CONFIGFS}"/"${TARGET}"
-KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}"
# NAMESPACE will be populated by setup_ns with a random value
NAMESPACE=""
@@ -116,8 +115,8 @@ function cleanup() {
# delete netconsole dynamic reconfiguration
echo 0 > "${NETCONS_PATH}"/enabled
- # Remove key
- rmdir "${KEY_PATH}"
+ # Remove all the keys that got created during the selftest
+ find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete
# Remove the configfs entry
rmdir "${NETCONS_PATH}"
@@ -139,6 +138,7 @@ function set_user_data() {
exit "${ksft_skip}"
fi
+ KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}"
mkdir -p "${KEY_PATH}"
VALUE_PATH="${KEY_PATH}""/value"
echo "${USERDATA_VALUE}" > "${VALUE_PATH}"