Commit 1c8876ee authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Tests run again

git-svn-id: file:///svn/tokudb@68 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7896ccf7
......@@ -854,6 +854,11 @@ static void brt_blackbox_test (void) {
test3(1<<18, 1<<20, 0);
test4(1<<18, 1<<20, 0);
// Once upon a time srandom(8) caused this test to fail.
srandom(8); test4(2048, 1<<15, 1);
// test3(1<<19, 1<<20, 0);
// test4(1<<19, 1<<20, 0);
......
......@@ -677,6 +677,11 @@ static int push_some_kvpairs_down (BRT t, BRTNODE node, int childnum,
* good way to do it otherwise. I want to loop over the elements of the hash table, deleting some as I
* go. The HASHTABLE_ITERATE macro will break if I delete something from the hash table. */
if (0) {
static int count=0;
count++;
printf("%s:%d pushing %d count=%d\n", __FILE__, __LINE__, childnum, count);
}
{
bytevec key,val;
ITEMLEN keylen, vallen;
......
......@@ -15,7 +15,7 @@ int toku_hashtable_create (HASHTABLE *h) {
int i;
if (tab==0) return -1;
tab->n_keys=0;
tab->arraysize=128;
tab->arraysize=8;
assert(sizeof(*tab->array)==sizeof(void*));
tab->array = toku_calloc(tab->arraysize, sizeof(*tab->array));
for (i=0; i<tab->arraysize; i++) tab->array[i]=0;
......@@ -139,7 +139,7 @@ int toku_hashtable_random_pick(HASHTABLE h, bytevec *key, ITEMLEN *keylen, bytev
int i;
int usei = random()%h->arraysize;
for (i=0; i<h->arraysize; i++, usei++) {
if (usei>h->arraysize) usei=0;
if (usei>=h->arraysize) usei=0;
HASHELT he=h->array[usei];
if (he) {
*key = he->key;
......
......@@ -107,7 +107,31 @@ void test0 (void) {
}
}
void test1(void) {
HASHTABLE table;
int i, r;
r = toku_hashtable_create(&table); assert(r==0);
for (i=0; i<100; i++) {
char keys[4][100], vals[4][100];
int j;
for (j=0; j<4; j++) {
snprintf(keys[j], 100, "k%ld", random());
snprintf(vals[j], 100, "v%d", j);
toku_hash_insert(table, keys[j], strlen(keys[j])+1, vals[j], strlen(vals[j])+1);
}
for (j=0; j<4; j++) {
bytevec key, val;
ITEMLEN keylen, vallen;
r = toku_hashtable_random_pick(table, &key, &keylen, &val, &vallen);
assert(r==0);
r = toku_hash_delete(table, key, keylen);
assert(r==0);
}
}
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
test0();
test1();
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment