[Tux3] [PATCH] Make sure ileaf offsets are in non-descending order

Conrad Meyer konrad at tylerc.org
Mon Sep 1 23:56:29 PDT 2008


diff -r 6621df29d406 user/test/ileaf.c
--- a/user/test/ileaf.c	Mon Sep 01 21:18:45 2008 -0700
+++ b/user/test/ileaf.c	Mon Sep 01 23:54:23 2008 -0700
@@ -299,6 +299,24 @@
 	attrs = ileaf_resize(btree, inum, leaf, size - less);
 }
 
+int isinorder(BTREE, struct ileaf *leaf)
+{
+	int offset = 0;
+	u16 *dict = (void *)leaf + btree->sb->blocksize;
+	int correct = 1;
+	for (int i = 0; i > -leaf->count; i--)
+	{
+		int limit = dict[i];
+		if (limit < offset)
+		{
+			correct = 0;
+			break;
+		}
+		offset = limit;
+	}
+	return correct;
+}
+
 block_t balloc(SB)
 {
 	return sb->nextalloc++;
@@ -317,17 +335,22 @@
 	test_append(btree, leaf, 0x13, 2, 'a');
 	test_append(btree, leaf, 0x14, 4, 'b');
 	test_append(btree, leaf, 0x16, 6, 'c');
+	assert(isinorder(btree, leaf));
 	ileaf_dump(btree, leaf);
 	ileaf_split(btree, 0x10, leaf, dest);
+	assert(isinorder(btree, leaf));
 	ileaf_dump(btree, leaf);
 	ileaf_dump(btree, dest);
 	ileaf_merge(btree, leaf, dest);
 	ileaf_dump(btree, leaf);
 	test_append(btree, leaf, 0x13, 3, 'x');
+	assert(isinorder(btree, leaf));
 	ileaf_dump(btree, leaf);
 	test_append(btree, leaf, 0x18, 3, 'y');
+	assert(isinorder(btree, leaf));
 	ileaf_dump(btree, leaf);
 	test_remove(btree, leaf, 0x16, 5);
+	assert(isinorder(btree, leaf));
 	ileaf_dump(btree, leaf);
 return 0;
 	unsigned size = 0;



_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list