diff mbox series

[ovs-dev,branch-20.03,15/16] tests: Add ofctl_strip_all() to filter OVS flow outputs.

Message ID 17dab42b37b228a70327ec13481fec0e67142fba.1613636533.git.frode.nordahl@canonical.com
State New
Headers show
Series Backport rollup | expand

Commit Message

Frode Nordahl Feb. 18, 2021, 8:50 a.m. UTC
From: Dumitru Ceara <dceara@redhat.com>

Extend the already existing ofctl_strip() to also ignore n_packets,
n_bytes, cookie.  Use some helper functions from
tests/system-userspace-packet-type-aware.at, which will be removed
by a future commit.

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit 0879a0aa9f332bdc689769a1bc2f156f1c3149a5)
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
---
 tests/ofproto-macros.at | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 6c4ff60e7..22999c1ca 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -1,12 +1,27 @@ 
 m4_divert_push([PREPARE_TESTS])
 [
+# Strips 'n_packets=...' from ovs-ofctl output.
+strip_n_packets () {
+    sed 's/ n_packets=[0-9]*,//'
+}
+
+# Strips 'n_bytes=...' from ovs-ofctl output.
+strip_n_bytes () {
+    sed 's/ n_bytes=[0-9]*,//'
+}
+
+# Strips 'cookie=...' from ovs-ofctl output.
+strip_cookie () {
+    sed 's/ cookie=0x[0-9a-fA-F]*,//'
+}
+
 # Strips out uninteresting parts of ovs-ofctl output, as well as parts
 # that vary from one run to another.
 ofctl_strip () {
     sed '
 s/ (xid=0x[0-9a-fA-F]*)//
 s/ duration=[0-9.]*s,//
-s/ cookie=0x0,//
+s/ cookie=0,//
 s/ table=0,//
 s/ n_packets=0,//
 s/ n_bytes=0,//
@@ -19,6 +34,12 @@  s/dir\/[0-9]*\/br0.mgmt/dir\/XXXX\/br0.mgmt/
 '
 }
 
+# Strips out uninteresting parts of ovs-ofctl output, including n_packets=..
+# n_bytes=..
+ofctl_strip_all () {
+    ofctl_strip | strip_n_packets | strip_n_bytes | strip_cookie
+}
+
 # Filter (multiline) vconn debug messages from ovs-vswitchd.log.
 # Use with vconn_sub() and ofctl_strip()
 print_vconn_debug () { awk -F\| < ovs-vswitchd.log '