[ovs-dev,repost,2/3] tests: Make OVS_WAIT_WHILE, OVS_WAIT_UNTIL run even faster in some cases.
diff mbox

Message ID 1443550635-29312-2-git-send-email-blp@nicira.com
State Accepted
Headers show

Commit Message

Ben Pfaff Sept. 29, 2015, 6:17 p.m. UTC
Sometimes OVS_WAIT_WHILE and OVS_WAIT_UNTIL are used for conditions that
tend to be true immediately but sometimes take a moment or two.  This
change makes such cases 0.1 seconds faster (which could add up over
hundreds of tests).

Signed-off-by: Ben Pfaff <blp@nicira.com>
---
 tests/ovs-macros.at | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Flavio Leitner Nov. 26, 2015, 5:50 p.m. UTC | #1
On Tue, Sep 29, 2015 at 11:17:14AM -0700, Ben Pfaff wrote:
> Sometimes OVS_WAIT_WHILE and OVS_WAIT_UNTIL are used for conditions that
> tend to be true immediately but sometimes take a moment or two.  This
> change makes such cases 0.1 seconds faster (which could add up over
> hundreds of tests).
> 
> Signed-off-by: Ben Pfaff <blp@nicira.com>
> ---

Nice little improvement.

Acked-by: Flavio Leitner <fbl@sysclose.org>

Patch
diff mbox

diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index 535d923..a585500 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -27,7 +27,10 @@  ovs_init() {
 }
 
 ovs_wait () {
-    # First try a quick sleep, so that the test completes very quickly
+    # First try the condition without waiting.
+    ovs_wait_cond && return 0
+
+    # Try a quick sleep, so that the test completes very quickly
     # in the normal case.  POSIX doesn't require fractional times to
     # work, so this might not work.
     sleep 0.1