Skip to content

Commit 39acc6a

Browse files
leitaokuba-moo
authored andcommitted
selftest: netcons: refactor target creation
Extract the netconsole target creation from create_dynamic_target(), by moving it from create_dynamic_target() into a new helper function. This enables other tests to use the creation of netconsole targets with arbitrary parameters and no sleep. The new helper will be utilized by forthcoming torture-type selftests that require dynamic target management. Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20251107-netconsole_torture-v10-2-749227b55f63@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 49c8d2c commit 39acc6a

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,31 +113,39 @@ function set_network() {
113113
configure_ip
114114
}
115115

116-
function create_dynamic_target() {
117-
local FORMAT=${1:-"extended"}
116+
function _create_dynamic_target() {
117+
local FORMAT="${1:?FORMAT parameter required}"
118+
local NCPATH="${2:?NCPATH parameter required}"
118119

119120
DSTMAC=$(ip netns exec "${NAMESPACE}" \
120121
ip link show "${DSTIF}" | awk '/ether/ {print $2}')
121122

122123
# Create a dynamic target
123-
mkdir "${NETCONS_PATH}"
124+
mkdir "${NCPATH}"
124125

125-
echo "${DSTIP}" > "${NETCONS_PATH}"/remote_ip
126-
echo "${SRCIP}" > "${NETCONS_PATH}"/local_ip
127-
echo "${DSTMAC}" > "${NETCONS_PATH}"/remote_mac
128-
echo "${SRCIF}" > "${NETCONS_PATH}"/dev_name
126+
echo "${DSTIP}" > "${NCPATH}"/remote_ip
127+
echo "${SRCIP}" > "${NCPATH}"/local_ip
128+
echo "${DSTMAC}" > "${NCPATH}"/remote_mac
129+
echo "${SRCIF}" > "${NCPATH}"/dev_name
129130

130131
if [ "${FORMAT}" == "basic" ]
131132
then
132133
# Basic target does not support release
133-
echo 0 > "${NETCONS_PATH}"/release
134-
echo 0 > "${NETCONS_PATH}"/extended
134+
echo 0 > "${NCPATH}"/release
135+
echo 0 > "${NCPATH}"/extended
135136
elif [ "${FORMAT}" == "extended" ]
136137
then
137-
echo 1 > "${NETCONS_PATH}"/extended
138+
echo 1 > "${NCPATH}"/extended
138139
fi
139140

140-
echo 1 > "${NETCONS_PATH}"/enabled
141+
echo 1 > "${NCPATH}"/enabled
142+
143+
}
144+
145+
function create_dynamic_target() {
146+
local FORMAT=${1:-"extended"}
147+
local NCPATH=${2:-"$NETCONS_PATH"}
148+
_create_dynamic_target "${FORMAT}" "${NCPATH}"
141149

142150
# This will make sure that the kernel was able to
143151
# load the netconsole driver configuration. The console message

0 commit comments

Comments
 (0)