From 36d7186e72adea723f67a706106c0d07d5f01379 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 20 May 2007 10:21:14 +0000 Subject: r23021: test some boundary conditions for idtree, after I saw some suspicious behaviour (This used to be commit e862cf17b891885f3a733819869a06895c1fb324) --- source4/lib/util/tests/idtree.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source4/lib/util') diff --git a/source4/lib/util/tests/idtree.c b/source4/lib/util/tests/idtree.c index dd8618d0db..a9770d789b 100644 --- a/source4/lib/util/tests/idtree.c +++ b/source4/lib/util/tests/idtree.c @@ -26,7 +26,7 @@ static bool torture_local_idtree_simple(struct torture_context *tctx) { struct idr_context *idr; - int i; + int i, ret; int *ids; int *present; extern int torture_numops; @@ -92,6 +92,23 @@ static bool torture_local_idtree_simple(struct torture_context *tctx) } } + /* now test some limits */ + for (i=0;i<25000;i++) { + ret = idr_get_new_above(idr, &ids[0], random() % 25000, 0x10000-3); + torture_assert(tctx, ret != -1, "idr_get_new_above failed"); + } + + ret = idr_get_new_above(idr, &ids[0], 0x10000-2, 0x10000); + torture_assert_int_equal(tctx, ret, 0x10000-2, "idr_get_new_above failed"); + ret = idr_get_new_above(idr, &ids[0], 0x10000-1, 0x10000); + torture_assert_int_equal(tctx, ret, 0x10000-1, "idr_get_new_above failed"); + ret = idr_get_new_above(idr, &ids[0], 0x10000, 0x10000); + torture_assert_int_equal(tctx, ret, 0x10000, "idr_get_new_above failed"); + ret = idr_get_new_above(idr, &ids[0], 0x10000+1, 0x10000); + torture_assert_int_equal(tctx, ret, -1, "idr_get_new_above succeeded above limit"); + ret = idr_get_new_above(idr, &ids[0], 0x10000+2, 0x10000); + torture_assert_int_equal(tctx, ret, -1, "idr_get_new_above succeeded above limit"); + torture_comment(tctx, "cleaned up\n"); return true; } -- cgit