AT_CHECK runs its commands in a subshell.  That means that (among other
effects), any variable assignments within its commands will disappear after
the commands' completion.  That doesn't matter for any of the existing
users, which don't do the sorts of things that affect an outer shell
environment anyhow, but an upcoming user wants to make a shell assignment
that persists.  This commit makes that possible, by using AT_CHECK
(actually AT_FAIL_IF but it's moot) only upon failure instead of bracketing
the entire test.

Signed-off-by: Ben Pfaff <b...@nicira.com>
---
 tests/ovs-macros.at | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at
index d550204..3c3d825 100644
--- a/tests/ovs-macros.at
+++ b/tests/ovs-macros.at
@@ -11,13 +11,14 @@ ovs_wait () {
     # in the normal case.  POSIX doesn't require fractional times to
     # work, so this might not work.
     sleep 0.1
-    ovs_wait_cond && exit 0
+    ovs_wait_cond && return 0
+
     # Then wait up to 10 seconds.
     for d in 0 1 2 3 4 5 6 7 8 9; do
         sleep 1
-        ovs_wait_cond && exit 0
+        ovs_wait_cond && return 0
     done
-    exit 1
+    return 1
 }
 
 # Prints the integers from $1 to $2, increasing by $3 (default 1) on stdout.
@@ -67,11 +68,16 @@ fi
 ]
 m4_divert_pop([PREPARE_TESTS])
 
-m4_define([OVS_WAIT],
-  [AT_CHECK(
-     [ovs_wait_cond () { $1
+m4_define([OVS_WAIT], [dnl
+ovs_wait_cond () {
+    $1
 }
-ovs_wait], [0], [ignore], [ignore], [$2])])
+if ovs_wait; then :
+else
+    $2
+    AT_FAIL_IF([:])
+fi
+])
 m4_define([OVS_WAIT_UNTIL], [OVS_WAIT([$1], [$2])])
 m4_define([OVS_WAIT_WHILE],
   [OVS_WAIT([if $1; then return 1; else return 0; fi], [$2])])
-- 
2.1.3

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to