ovsdb: Fix race conditions in test suite.
[sliver-openvswitch.git] / tests / testsuite.at
index d5eadc2..ceded7e 100644 (file)
@@ -18,6 +18,20 @@ AT_TESTED([ovs-vswitchd])
 AT_TESTED([ovs-vsctl])
 AT_TESTED([perl])
 
+m4_define([OVS_WAIT_UNTIL],
+  [AT_CHECK(
+    [# First 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
+     $1
+     # Then wait up to 10 seconds.
+     for d in 0 1 2 3 4 5 6 7 8 9; do
+       sleep 1
+       $1
+     done
+     exit 1], [0], [ignore], [ignore])])
+
 m4_include([tests/lcov-pre.at])
 m4_include([tests/library.at])
 m4_include([tests/dir_name.at])