Multiple tests call ovn commands such as ovn-nbctl or ovn-sbctl or ovs
commands such as ovs-ofctl or ovs-dpctl within on_exit.
Avoid issuing those commands when ovn/ovs has been stopped.
When tests succeed, this was causing extra unnecessary error messages (when
a test succeeds, ovn and ovs are stopped before on_exit is executed), which made
debugging/understanding tests more difficult.

Signed-off-by: Xavier Simonart <xsimo...@redhat.com>

---
- v2: Updated based on Mark's feedback.
---
 tests/ovs-macros.at | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index 25b34791a..6a3dc51dc 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -382,7 +382,15 @@ dnl Cleanup commands are executed in the reverse order of 
calls to this
 dnl function.
 m4_divert_text([PREPARE_TESTS], [dnl
 on_exit () {
-    (echo "$1"; cat cleanup) > cleanup.tmp
+    if [ echo "$1" | grep -qe '^ovn-nbctl' ] ; then
+      (echo "test -e ovn-nb/ovn-nb.sock && $1"; cat cleanup;) > cleanup.tmp
+    elif [ echo "$1" | grep -qe '^ovn-sbctl' ]; then
+      (echo "test -e ovn-sb/ovn-sb.sock && $1"; cat cleanup) > cleanup.tmp
+    elif [ echo "$1" | grep -qe '^ovs-ofctl' -qe '^ovs-dpctl' ]; then
+      (echo "test -e $OVS_RUNDIR/ovs-vswitchd.pid && $1"; cat cleanup) > 
cleanup.tmp
+    else
+      (echo "$1"; cat cleanup) > cleanup.tmp
+    fi
     mv cleanup.tmp cleanup
 }
 ])
-- 
2.47.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to