From: Rusty Russell Date: Thu, 7 Feb 2013 00:25:01 +0000 (+1030) Subject: foreach: fix overzealous test. X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;ds=sidebyside;h=42b45378bfcc8db48e8811a114201c7a41c21420;p=ccan foreach: fix overzealous test. Andreas Schlick reported a failure on 64-bit systems; we should simply test that the number of iterators does not grow on second iteration, rather than assuming an explicit limit as compilers may vary. Signed-off-by: Rusty Russell --- diff --git a/ccan/foreach/test/run-nested.c b/ccan/foreach/test/run-nested.c index 17fa2f16..aa20437e 100644 --- a/ccan/foreach/test/run-nested.c +++ b/ccan/foreach/test/run-nested.c @@ -44,10 +44,10 @@ static int count_iters(void) int main(void) { - int i, j, sum; + int i, j, sum, max_iters; const char *istr, *jstr; - plan_tests(16); + plan_tests(13); sum = 0; foreach_int(i, 0, 1, 2, 3, 4) @@ -93,13 +93,15 @@ int main(void) diag("sum = %i\n", sum); diag("iters = %i\n", count_iters()); ok1(sum == 160); - ok1(count_iters() <= 2 + 2 + 5); /* 5 is max depth of recursion. */ sum = test_ptr_recursion("0"); diag("sum = %i\n", sum); diag("iters = %i\n", count_iters()); ok1(sum == 160); - ok1(count_iters() <= 2 + 2 + 5); + if (i == 0) + max_iters = count_iters(); + else + ok1(count_iters() <= max_iters); } return exit_status(); }