Skip to content

Commit 7dcb653

Browse files
leitaokuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 61f51cc commit 7dcb653

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ TARGET=$(mktemp -u netcons_XXXXX)
2323
DEFAULT_PRINTK_VALUES=$(cat /proc/sys/kernel/printk)
2424
NETCONS_CONFIGFS="/sys/kernel/config/netconsole"
2525
NETCONS_PATH="${NETCONS_CONFIGFS}"/"${TARGET}"
26-
KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}"
2726
# NAMESPACE will be populated by setup_ns with a random value
2827
NAMESPACE=""
2928

@@ -116,8 +115,8 @@ function cleanup() {
116115

117116
# delete netconsole dynamic reconfiguration
118117
echo 0 > "${NETCONS_PATH}"/enabled
119-
# Remove key
120-
rmdir "${KEY_PATH}"
118+
# Remove all the keys that got created during the selftest
119+
find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete
121120
# Remove the configfs entry
122121
rmdir "${NETCONS_PATH}"
123122

@@ -139,6 +138,7 @@ function set_user_data() {
139138
exit "${ksft_skip}"
140139
fi
141140

141+
KEY_PATH="${NETCONS_PATH}/userdata/${USERDATA_KEY}"
142142
mkdir -p "${KEY_PATH}"
143143
VALUE_PATH="${KEY_PATH}""/value"
144144
echo "${USERDATA_VALUE}" > "${VALUE_PATH}"

0 commit comments

Comments
 (0)