When starting multiple tcpdumps on same node, it is faster to use
the new M_START_TCPDUMPS macro instead of multiple M_START_TCPDUMP.
The former usually waits only one second for all tcpdump to be
listening while the latter waits one second for each tcpdump to be
listening.

Signed-off-by: Xavier Simonart <[email protected]>
---
 tests/multinode-macros.at | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/multinode-macros.at b/tests/multinode-macros.at
index 06efee69b..ade4d167c 100644
--- a/tests/multinode-macros.at
+++ b/tests/multinode-macros.at
@@ -41,6 +41,30 @@ m4_define([M_START_TCPDUMP],
     ]
 )
 
+m4_define([M_START_TCPDUMPS_RECURSIVE_], [
+     m4_if(m4_eval($# >= 3), [1], [dnl
+        names="$names $3"
+        echo "Running podman exec $1 tcpdump -l $2 >$3.tcpdump 2>$3.stderr"
+        podman exec $1 tcpdump -l $2 >$3.tcpdump 2>$3.stderr &
+        echo "podman exec $1 ps -ef | grep -v grep | grep tcpdump && podman 
exec $1 killall tcpdump" >> cleanup
+        M_START_TCPDUMPS_RECURSIVE_(m4_shift(m4_shift(m4_shift($@))))
+        ])
+    ]
+)
+
+# M_START_TCPDUMPS([fake node1], [params1], [name1],
+#                  [fake node2], [params2], [name2], ...)
+# Start multiple tcpdump. Useful to speed up when many tcpdump
+# must be started as waiting for "listening" takes usually 1 second.
+m4_define([M_START_TCPDUMPS],
+    [
+     names=""
+     M_START_TCPDUMPS_RECURSIVE_($@)
+     for name in $names; do
+         OVS_WAIT_UNTIL([grep -q "listening" ${name}.stderr])
+     done
+    ]
+)
 
 # M_FORMAT_CT([ip-addr])
 #
-- 
2.47.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to