svn commit: samba r23021 - in branches/SAMBA_4_0/source/lib/util/tests: .

tridge at samba.org tridge at samba.org
Sun May 20 10:21:15 GMT 2007


Author: tridge
Date: 2007-05-20 10:21:14 +0000 (Sun, 20 May 2007)
New Revision: 23021

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23021

Log:

test some boundary conditions for idtree, after I saw some suspicious
behaviour

Modified:
   branches/SAMBA_4_0/source/lib/util/tests/idtree.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/util/tests/idtree.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/tests/idtree.c	2007-05-20 09:44:03 UTC (rev 23020)
+++ branches/SAMBA_4_0/source/lib/util/tests/idtree.c	2007-05-20 10:21:14 UTC (rev 23021)
@@ -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 @@
 		}
 	}
 
+	/* 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;
 }



More information about the samba-cvs mailing list