Multi-line sed scripts in shell test helpers are echoed to stderr
when 'make check' runs with set -x, causing false failures in
output comparisons.  Use grep or single-line sed -e filters
instead.  Also fix a malformed AT_CHECK in add_flow_group_and_meter
that merged two commands via an embedded newline.

Assisted-by: composer-2.5-fast, Cursor
Signed-off-by: Eli Britstein <[email protected]>
---
 tests/ofproto-macros.at | 79 +++++++++++++++++++----------------------
 tests/ofproto.at        | 10 +++---
 tests/vlog.at           |  4 +--
 3 files changed, 42 insertions(+), 51 deletions(-)

diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index 4d6adbb78..e6e935812 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -3,22 +3,20 @@ m4_divert_push([PREPARE_TESTS])
 # 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/ table=0,//
-s/ n_packets=0,//
-s/ n_offload_packets=[0-9]*,//
-s/ n_bytes=0,//
-s/ n_offload_bytes=[0-9]*,//
-s/ idle_age=[0-9]*,//
-s/ hard_age=[0-9]*,//
-s/dp_hash=0x[0-9a-f]*\//dp_hash=0x0\//
-s/recirc_id=0x[0-9a-f]*,/recirc_id=0x0,/
-s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z|//
-s/dir\/[0-9]*\/br0.mgmt/dir\/XXXX\/br0.mgmt/
-'
+    sed -e 's/ (xid=0x[0-9a-fA-F]*)//' \
+        -e 's/ duration=[0-9.]*s,//' \
+        -e 's/ cookie=0x0,//' \
+        -e 's/ table=0,//' \
+        -e 's/ n_packets=0,//' \
+        -e 's/ n_offload_packets=[0-9]*,//' \
+        -e 's/ n_bytes=0,//' \
+        -e 's/ n_offload_bytes=[0-9]*,//' \
+        -e 's/ idle_age=[0-9]*,//' \
+        -e 's/ hard_age=[0-9]*,//' \
+        -e 's/dp_hash=0x[0-9a-f]*\//dp_hash=0x0\//' \
+        -e 's/recirc_id=0x[0-9a-f]*,/recirc_id=0x0,/' \
+        -e 
's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z|//'
 \
+        -e 's/dir\/[0-9]*\/br0.mgmt/dir\/XXXX\/br0.mgmt/'
 }
 
 # Strips out byte counters from ovs-ofctl output
@@ -37,10 +35,8 @@ prt==1 { sub(/[ \t]*$/, ""); print $0 }
 }
 
 vconn_sub() {
-    sed '
-s/tcp:127.0.0.1:[0-9][0-9]*:/unix:/
-s/unix#[0-9]*:/unix:/
-'
+    sed -e 's/tcp:127.0.0.1:[0-9][0-9]*:/unix:/' \
+        -e 's/unix#[0-9]*:/unix:/'
 }
 ]
 
@@ -138,8 +134,8 @@ strip_duration () {
 # Strips 'ufid:...' from output, to make it easier to compare.
 # (ufids are random.)
 strip_ufid () {
-    sed 's/mega_ufid:[[-0-9a-f]]* //
-    s/ufid:[[-0-9a-f]]* //'
+    sed -e 's/mega_ufid:[[-0-9a-f]]* //' \
+        -e 's/ufid:[[-0-9a-f]]* //'
 }
 
 parse_ufid () {
@@ -148,8 +144,8 @@ parse_ufid () {
 
 # Strips packets: and bytes: from output
 strip_stats () {
-    sed 's/packets:[[0-9]]*/packets:0/
-    s/bytes:[[0-9]]*/bytes:0/'
+    sed -e 's/packets:[[0-9]]*/packets:0/' \
+        -e 's/bytes:[[0-9]]*/bytes:0/'
 }
 
 # Strips key32 field from output.
@@ -171,9 +167,9 @@ strip_eth () {
 # 'recirc=<recirc_id>' respectively.  This should make output easier to
 # compare.
 strip_recirc() {
-   sed 's/recirc_id([[x0-9a-f]]*)/recirc_id(<recirc>)/
-        s/recirc_id=[[x0-9a-f]]*/recirc_id=<recirc>/
-        s/recirc([[x0-9a-f]]*)/recirc(<recirc>)/'
+    sed -e 's/recirc_id([[x0-9a-f]]*)/recirc_id(<recirc>)/' \
+        -e 's/recirc_id=[[x0-9a-f]]*/recirc_id=<recirc>/' \
+        -e 's/recirc([[x0-9a-f]]*)/recirc(<recirc>)/'
 }
 
 # Strips dp_hash from output.
@@ -296,22 +292,19 @@ check_logs () {
     #
     # We also ignore the "Spent an unreasonably long XXms dumping flows" as
     # they can appear when large time/warps are used during tests.
-    sed -n "$1
-/reset by peer/d
-/Broken pipe/d
-/is not connected/d
-/timeval.*Unreasonably long [[0-9]]*ms poll interval/d
-/timeval.*faults: [[0-9]]* minor, [[0-9]]* major/d
-/timeval.*disk: [[0-9]]* reads, [[0-9]]* writes/d
-/timeval.*context switches: [[0-9]]* voluntary, [[0-9]]* involuntary/d
-/ovs_rcu.*blocked [[0-9]]* ms waiting for .* to quiesce/d
-/Dropped [[0-9]]* log messages/d
-/setting extended ack support failed/d
-/ETHTOOL_GSSET_INFO/d
-/Spent an unreasonably long .*ms dumping flows/d
-/|WARN|/p
-/|ERR|/p
-/|EMER|/p" ${logs}
+    grep -h -E '\|WARN\||\|ERR\||\|EMER\|' ${logs} | sed -e "$1" \
+        -e '/reset by peer/d' \
+        -e '/Broken pipe/d' \
+        -e '/is not connected/d' \
+        -e '/timeval.*Unreasonably long [[0-9]]*ms poll interval/d' \
+        -e '/timeval.*faults: [[0-9]]* minor, [[0-9]]* major/d' \
+        -e '/timeval.*disk: [[0-9]]* reads, [[0-9]]* writes/d' \
+        -e '/timeval.*context switches: [[0-9]]* voluntary, [[0-9]]* 
involuntary/d' \
+        -e '/ovs_rcu.*blocked [[0-9]]* ms waiting for .* to quiesce/d' \
+        -e '/Dropped [[0-9]]* log messages/d' \
+        -e '/setting extended ack support failed/d' \
+        -e '/ETHTOOL_GSSET_INFO/d' \
+        -e '/Spent an unreasonably long .*ms dumping flows/d'
 }
 
 # Gets the last line number in ovs-vswitchd.log +1. This can be used to
diff --git a/tests/ofproto.at b/tests/ofproto.at
index a65e612bd..2825d12dd 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -3595,10 +3595,9 @@ table_desc:-
     AT_FAIL_IF([test X"$1" != X])
 
     normalize_log () {
-       sed '
-s/ (xid=0x[[0-9a-fA-F]]*)//
-s/ *duration.*//
-s/00:0.$/00:0x/' < monitor.log
+       sed -e 's/ (xid=0x[[0-9a-fA-F]]*)//' \
+           -e 's/ *duration.*//' \
+           -e 's/00:0.$/00:0x/' < monitor.log
     }
 
     OVS_WAIT_UNTIL([test `wc -l < "monitor.log"` -ge `wc -l < "expout"`],
@@ -6487,9 +6486,8 @@ OVS_VSWITCHD_START
 
 add_flow_group_and_meter () {
     AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
-    AT_CHECK([ovs-ofctl -O OpenFlow11 add-group br0 
group_id=1234,type=all,bucket=output:10
+    AT_CHECK([ovs-ofctl -O OpenFlow11 add-group br0 
group_id=1234,type=all,bucket=output:10])
     AT_CHECK([ovs-ofctl -O OpenFlow13 add-meter br0 'meter=1 pktps burst stats 
bands=type=drop rate=1 burst_size=1'])
-])
 }
 
 verify_added () {
diff --git a/tests/vlog.at b/tests/vlog.at
index 8a8b7511d..dad9d4d54 100644
--- a/tests/vlog.at
+++ b/tests/vlog.at
@@ -103,8 +103,8 @@ AT_CLEANUP
 
 m4_divert_push([PREPARE_TESTS])
 vlog_filt () {
-    sed 's/.*\(opened log file\).*/\1/
-s/.*|//' "$@"
+    sed -e 's/.*\(opened log file\).*/\1/' \
+        -e 's/.*|//' "$@"
 }
 m4_divert_pop([PREPARE_TESTS])
 
-- 
2.43.0

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

Reply via email to