aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-02-13 14:47:53 -0800
committerBen Pfaff <blp@nicira.com>2012-03-07 14:15:22 -0800
commitf17e0c2582b5008f70e26d329de485fe4d75e4a6 (patch)
tree1d3e17470bec4f659aabe3100075187eae49d340 /tests
parentc78cd7deff9b1fdc7770b4ab2c84667562c27b3c (diff)
tests: Convert OVS_WAIT_* macros to shell functions.
This reduces tests/testsuite by about 35 kB, by collapsing a number of macro expansions into just one copy in a shell function. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/testsuite.at38
1 files changed, 24 insertions, 14 deletions
diff --git a/tests/testsuite.at b/tests/testsuite.at
index c9561e77..755462cb 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -18,22 +18,32 @@ AT_TESTED([ovs-vswitchd])
AT_TESTED([ovs-vsctl])
AT_TESTED([perl])
+m4_divert_push([PREPARE_TESTS])
+[
+ovs_wait () {
+ # 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
+ ovs_wait_cond && exit 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
+ done
+ exit 1
+}
+]
+m4_divert_pop([PREPARE_TESTS])
+
m4_define([OVS_WAIT],
[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], [$2])])
-
-m4_define([OVS_WAIT_UNTIL], [OVS_WAIT([if $1; then exit 0; fi], [$2])])
-m4_define([OVS_WAIT_WHILE], [OVS_WAIT([if $1; then :; else exit 0; fi], [$2])])
+ [ovs_wait_cond () { $1
+}
+ovs_wait], [0], [ignore], [ignore], [$2])])
+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])])
m4_include([tests/ovsdb-macros.at])
m4_include([tests/ofproto-macros.at])