summaryrefslogtreecommitdiff
path: root/source4/lib/util
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-20 10:21:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:40 -0500
commit36d7186e72adea723f67a706106c0d07d5f01379 (patch)
tree8cedf6c4e43ec9af9d91c7c71bfb92fbea2360f1 /source4/lib/util
parentd3e28ccd4824adce2feed9fe53cf2d4d393d607a (diff)
downloadsamba-36d7186e72adea723f67a706106c0d07d5f01379.tar.gz
samba-36d7186e72adea723f67a706106c0d07d5f01379.tar.bz2
samba-36d7186e72adea723f67a706106c0d07d5f01379.zip
r23021: test some boundary conditions for idtree, after I saw some suspicious
behaviour (This used to be commit e862cf17b891885f3a733819869a06895c1fb324)
Diffstat (limited to 'source4/lib/util')
-rw-r--r--source4/lib/util/tests/idtree.c19
1 files changed, 18 insertions, 1 deletions
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;
}