diff mbox series

[ovs-dev,1/3] tests: Add ofctl_strip_all() to filter OVS flow outputs.

Message ID 20201207203039.28249.50242.stgit@dceara.remote.csb
State Accepted
Headers show
Series tests: Improve unpredictable self test. | expand

Commit Message

Dumitru Ceara Dec. 7, 2020, 8:30 p.m. UTC
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>
---
 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 a6e89a9..dd5d384 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 '