[ovs-dev] [PATCH] tests: Make OVS_WAIT_UNTIL and OVS_WAIT_WHILE failures easier to debug.

Ben Pfaff blp at ovn.org
Thu Feb 1 18:08:05 UTC 2018


Until now, when OVS_WAIT_UNTIL or OVS_WAIT_WHILE ran, little information
was available: usually nothing at all in the log, unless the wait failed,
in which case there was a line number.  This commit adds a note saying
what is being waited for in any case, and a message saying that the wait
failed if it does.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 tests/ovs-macros.at | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index 324fdc887f78..f3ab3548a7fe 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -239,11 +239,13 @@ fi
 m4_divert_pop([PREPARE_TESTS])
 
 m4_define([OVS_WAIT], [dnl
+AS_ECHO(["AS_ESCAPE([$3: waiting $4...])"]) >&AS_MESSAGE_LOG_FD
 ovs_wait_cond () {
     $1
 }
 if ovs_wait; then :
 else
+    AS_ECHO(["AS_ESCAPE([$3: wait failed])"]) >&AS_MESSAGE_LOG_FD
     $2
     AT_FAIL_IF([:])
 fi
@@ -255,7 +257,8 @@ dnl Executes shell COMMAND in a loop until it returns
 dnl zero return code.  If COMMAND did not return
 dnl zero code within reasonable time limit, then
 dnl the test fails.
-m4_define([OVS_WAIT_UNTIL], [OVS_WAIT([$1], [$2])])
+m4_define([OVS_WAIT_UNTIL],
+  [OVS_WAIT([$1], [$2], [AT_LINE], [until $1])])
 
 dnl OVS_WAIT_WHILE(COMMAND)
 dnl
@@ -264,7 +267,8 @@ dnl non-zero return code.  If COMMAND did not return
 dnl non-zero code within reasonable time limit, then
 dnl the test fails.
 m4_define([OVS_WAIT_WHILE],
-  [OVS_WAIT([if $1; then return 1; else return 0; fi], [$2])])
+  [OVS_WAIT([if $1; then return 1; else return 0; fi], [$2],
+            [AT_LINE], [while $1])])
 
 dnl OVS_APP_EXIT_AND_WAIT(DAEMON)
 dnl
-- 
2.15.1



More information about the dev mailing list