Skip to content

Commit bed365c

Browse files
leitaokuba-moo
authored andcommitted
selftests: net: Refactor cleanup logic in lib_netcons.sh
Extract the network device and namespace cleanup logic from the cleanup() function into a new do_cleanup() helper in lib_netcons.sh. The do_cleanup() function only unconfigure the network and printk, while cleanup() cleans the netconsole targets plus the network and printk. This refactoring let this code to be reused in cases netconsole dynamic is not being used, as in the upcoming patch. Signed-off-by: Breno Leitao <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d792064 commit bed365c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,9 @@ function disable_release_append() {
128128
echo 1 > "${NETCONS_PATH}"/enabled
129129
}
130130

131-
function cleanup() {
131+
function do_cleanup() {
132132
local NSIM_DEV_SYS_DEL="/sys/bus/netdevsim/del_device"
133133

134-
# delete netconsole dynamic reconfiguration
135-
echo 0 > "${NETCONS_PATH}"/enabled
136-
# Remove all the keys that got created during the selftest
137-
find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete
138-
# Remove the configfs entry
139-
rmdir "${NETCONS_PATH}"
140-
141134
# Delete netdevsim devices
142135
echo "$NSIM_DEV_2_ID" > "$NSIM_DEV_SYS_DEL"
143136
echo "$NSIM_DEV_1_ID" > "$NSIM_DEV_SYS_DEL"
@@ -149,6 +142,17 @@ function cleanup() {
149142
echo "${DEFAULT_PRINTK_VALUES}" > /proc/sys/kernel/printk
150143
}
151144

145+
function cleanup() {
146+
# delete netconsole dynamic reconfiguration
147+
echo 0 > "${NETCONS_PATH}"/enabled
148+
# Remove all the keys that got created during the selftest
149+
find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete
150+
# Remove the configfs entry
151+
rmdir "${NETCONS_PATH}"
152+
153+
do_cleanup
154+
}
155+
152156
function set_user_data() {
153157
if [[ ! -d "${NETCONS_PATH}""/userdata" ]]
154158
then

0 commit comments

Comments
 (0)