aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Machata <petrm@mellanox.com>2018-07-31 18:38:59 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-01 12:52:30 -0400
commit989133bf7ff3fe6ebcb9c1e7b5e13bebac175d35 (patch)
tree1b7dd08ee36f91fe41571e7776596b1a55b09f9e
parent6495342365e859400023c09063c2b31a12d68261 (diff)
selftests: forwarding: Move lldpad waiting to lib.sh
The function lldpad_wait() will be useful for a test added by a following patch. Likewise would the "sleep 5" with its extensive comment. Therefore move lldpad_wait() to lib.sh in order to allow reuse. Rename it to lldpad_app_wait_set() to recognize that what this is intended to wait on are the pending APP sets. For the sleeping, add a function lldpad_app_wait_del(). That will serve to hold the related explanatory comment (which edit for clarity), and as a token in the caller to identify the sites where this sort of waiting takes place. That will serve when/if a better way to handle this business is found. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rwxr-xr-xtools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh23
-rw-r--r--tools/testing/selftests/net/forwarding/lib.sh21
2 files changed, 24 insertions, 20 deletions
diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
index cc527660a022..9e875ee8dc1c 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
@@ -103,16 +103,6 @@ dscp_map()
103 done 103 done
104} 104}
105 105
106lldpad_wait()
107{
108 local dev=$1; shift
109
110 while lldptool -t -i $dev -V APP -c app | grep -q pending; do
111 echo "$dev: waiting for lldpad to push pending APP updates"
112 sleep 5
113 done
114}
115
116switch_create() 106switch_create()
117{ 107{
118 ip link add name br1 type bridge vlan_filtering 1 108 ip link add name br1 type bridge vlan_filtering 1
@@ -124,22 +114,15 @@ switch_create()
124 114
125 lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null 115 lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null
126 lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null 116 lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null
127 lldpad_wait $swp1 117 lldpad_app_wait_set $swp1
128 lldpad_wait $swp2 118 lldpad_app_wait_set $swp2
129} 119}
130 120
131switch_destroy() 121switch_destroy()
132{ 122{
133 lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null 123 lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null
134 lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null 124 lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null
135 125 lldpad_app_wait_del
136 # Give lldpad a chance to push down the changes. If the device is downed
137 # too soon, the updates will be left pending, but will have been struck
138 # off the lldpad's DB already, and we won't be able to tell. Then on
139 # next test iteration this would cause weirdness as newly-added APP
140 # rules conflict with the old ones, sometimes getting stuck in an
141 # "unknown" state.
142 sleep 5
143 126
144 ip link set dev $swp2 nomaster 127 ip link set dev $swp2 nomaster
145 ip link set dev $swp1 nomaster 128 ip link set dev $swp1 nomaster
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 843a6715924f..90af5cd23417 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -247,6 +247,27 @@ setup_wait()
247 sleep $WAIT_TIME 247 sleep $WAIT_TIME
248} 248}
249 249
250lldpad_app_wait_set()
251{
252 local dev=$1; shift
253
254 while lldptool -t -i $dev -V APP -c app | grep -q pending; do
255 echo "$dev: waiting for lldpad to push pending APP updates"
256 sleep 5
257 done
258}
259
260lldpad_app_wait_del()
261{
262 # Give lldpad a chance to push down the changes. If the device is downed
263 # too soon, the updates will be left pending. However, they will have
264 # been struck off the lldpad's DB already, so we won't be able to tell
265 # they are pending. Then on next test iteration this would cause
266 # weirdness as newly-added APP rules conflict with the old ones,
267 # sometimes getting stuck in an "unknown" state.
268 sleep 5
269}
270
250pre_cleanup() 271pre_cleanup()
251{ 272{
252 if [ "${PAUSE_ON_CLEANUP}" = "yes" ]; then 273 if [ "${PAUSE_ON_CLEANUP}" = "yes" ]; then