浏览代码

selftests: forwarding: lib: Parameterize NUM_NETIFS in two functions

setup_wait() and tc_offload_check() both assume that all NUM_NETIFS
interfaces are relevant for a given test. However, the scale test script
acts as an umbrella for a number of sub-tests, some of which may not
require all the interfaces.

Thus it's suboptimal for tc_offload_check() to query all the interfaces.
In case of setup_wait() it's incorrect, because the sub-test in question
of course doesn't configure any interfaces beyond what it needs, and
setup_wait() then ends up waiting indefinitely for the extraneous
interfaces to come up.

For that reason, give setup_wait() and tc_offload_check() an optional
parameter with a number of interfaces to probe. Fall back to global
NUM_NETIFS if the parameter is not given.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Yuval Mintz <yuvalm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Petr Machata 7 年之前
父节点
当前提交
68d9cea594
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      tools/testing/selftests/net/forwarding/lib.sh

+ 6 - 2
tools/testing/selftests/net/forwarding/lib.sh

@@ -220,7 +220,9 @@ setup_wait_dev()
 
 
 setup_wait()
 setup_wait()
 {
 {
-	for i in $(eval echo {1..$NUM_NETIFS}); do
+	local num_netifs=${1:-$NUM_NETIFS}
+
+	for ((i = 1; i <= num_netifs; ++i)); do
 		setup_wait_dev ${NETIFS[p$i]}
 		setup_wait_dev ${NETIFS[p$i]}
 	done
 	done
 
 
@@ -481,7 +483,9 @@ forwarding_restore()
 
 
 tc_offload_check()
 tc_offload_check()
 {
 {
-	for i in $(eval echo {1..$NUM_NETIFS}); do
+	local num_netifs=${1:-$NUM_NETIFS}
+
+	for ((i = 1; i <= num_netifs; ++i)); do
 		ethtool -k ${NETIFS[p$i]} \
 		ethtool -k ${NETIFS[p$i]} \
 			| grep "hw-tc-offload: on" &> /dev/null
 			| grep "hw-tc-offload: on" &> /dev/null
 		if [[ $? -ne 0 ]]; then
 		if [[ $? -ne 0 ]]; then