From 1afda7bdde90948027e3230c19753280afb16e96 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Mar 2007 14:53:09 +0000 Subject: r21656: Move tests a bit closer to the things they test, should make syncing with samba3 easier. (This used to be commit 4d755fb5d7adedd1dd8bad917b921324411bfd59) --- source4/lib/util/tests/idtree.c | 104 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 source4/lib/util/tests/idtree.c (limited to 'source4/lib/util/tests/idtree.c') diff --git a/source4/lib/util/tests/idtree.c b/source4/lib/util/tests/idtree.c new file mode 100644 index 0000000000..dd8618d0db --- /dev/null +++ b/source4/lib/util/tests/idtree.c @@ -0,0 +1,104 @@ +/* + Unix SMB/CIFS implementation. + + local testing of idtree routines. + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "torture/torture.h" + +static bool torture_local_idtree_simple(struct torture_context *tctx) +{ + struct idr_context *idr; + int i; + int *ids; + int *present; + extern int torture_numops; + int n = torture_numops; + TALLOC_CTX *mem_ctx = tctx; + + idr = idr_init(mem_ctx); + + ids = talloc_zero_array(mem_ctx, int, n); + present = talloc_zero_array(mem_ctx, int, n); + + for (i=0;i 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/tests/idtree.c') 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 From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/util/tests/idtree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/util/tests/idtree.c') diff --git a/source4/lib/util/tests/idtree.c b/source4/lib/util/tests/idtree.c index a9770d789b..448abb5c04 100644 --- a/source4/lib/util/tests/idtree.c +++ b/source4/lib/util/tests/idtree.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From dfa4e5f78440e375a9c47eab913c5980c1aa640b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 Aug 2007 02:10:17 +0000 Subject: r24631: Fix up format warnings, found on my Fedora 7 x86_64 workstation. Andrew Bartlett (This used to be commit 3d74d178bfd89127ff387939e848b240e638cc35) --- source4/lib/util/tests/idtree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/util/tests/idtree.c') diff --git a/source4/lib/util/tests/idtree.c b/source4/lib/util/tests/idtree.c index 448abb5c04..d89fb8c489 100644 --- a/source4/lib/util/tests/idtree.c +++ b/source4/lib/util/tests/idtree.c @@ -61,10 +61,11 @@ static bool torture_local_idtree_simple(struct torture_context *tctx) } } else { if (p != NULL) { - torture_fail(tctx, talloc_asprintf(tctx, - "non-present at %d gave %p (would be %d)", - ii, p, - (int)(((char *)p) - (char *)(&ids[0])) / sizeof(int))); + torture_fail(tctx, + talloc_asprintf(tctx, + "non-present at %d gave %p (would be %d)", + ii, p, + (int)((((char *)p) - (char *)(&ids[0])) / sizeof(int)))); } if (random() % 5) { ids[ii] = idr_get_new(idr, &ids[ii], n); -- cgit