#include "brt.h" #include "key.h" #include "memory.h" #include #include #include #include #include #include #include #include TOKUTXN const null_txn = 0; DB * const null_db = 0; extern long long n_items_malloced; static void test0 (void) { BRT t; int r; CACHETABLE ct; char fname[]="testbrt.brt"; printf("%s:%d test0\n", __FILE__, __LINE__); memory_check=1; memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); printf("%s:%d test0\n", __FILE__, __LINE__); unlink(fname); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun); assert(r==0); //printf("%s:%d test0\n", __FILE__, __LINE__); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); r = close_brt(t); assert(r==0); //printf("%s:%d n_items_malloced=%lld\n", __FILE__, __LINE__, n_items_malloced); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); } static void test1 (void) { BRT t; int r; CACHETABLE ct; char fname[]="testbrt.brt"; DBT k,v; memory_check=1; memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun); assert(r==0); brt_insert(t, fill_dbt(&k, "hello", 6), fill_dbt(&v, "there", 6), null_db, null_txn); { r = brt_lookup(t, fill_dbt(&k, "hello", 6), init_dbt(&v), 0); assert(r==0); assert(strcmp(v.data, "there")==0); assert(v.size==6); } r = close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); printf("test1 ok\n"); } static void test2 (int memcheck) { BRT t; int r; int i; CACHETABLE ct; char fname[]="testbrt.brt"; memory_check=memcheck; printf("%s:%d checking\n", __FILE__, __LINE__); memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun); printf("%s:%d did setup\n", __FILE__, __LINE__); assert(r==0); for (i=0; i<2048; i++) { DBT k,v; char key[100],val[100]; snprintf(key,100,"hello%d",i); snprintf(val,100,"there%d",i); brt_insert(t, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn); //printf("%s:%d did insert %d\n", __FILE__, __LINE__, i); if (0) { brt_flush(t); { int n = get_n_items_malloced(); printf("%s:%d i=%d n_items_malloced=%d\n", __FILE__, __LINE__, i, n); if (n!=3) print_malloced_items(); assert(n==3); } } } printf("%s:%d inserted\n", __FILE__, __LINE__); r = close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); printf("test2 ok\n"); } static void test3 (int nodesize, int count, int memcheck) { BRT t; int r; struct timeval t0,t1; int i; CACHETABLE ct; char fname[]="testbrt.brt"; memory_check=memcheck; memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); gettimeofday(&t0, 0); unlink(fname); r = open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun); assert(r==0); for (i=0; i=0) { char key[100], valexpected[100]; DBT k,v; if (i%1000==0) printf("r"); fflush(stdout); snprintf(key, 100, "key%d", rk); snprintf(valexpected, 100, "val%d", values[rk]); r = brt_lookup(t, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&v), 0); assert(r==0); assert(v.size==(1+strlen(valexpected))); assert(memcmp(v.data,valexpected,v.size)==0); } } printf("\n"); toku_free(values); r = close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); } static void test_dump_empty_db (void) { BRT t; CACHETABLE ct; int r; char fname[]="testbrt.brt"; memory_check=1; r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); unlink(fname); r = open_brt(fname, 0, 1, &t, 1024, ct, null_txn, toku_default_compare_fun); assert(r==0); dump_brt(t); r = close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); } /* Test running multiple trees in different files */ static void test_multiple_files_of_size (int size) { const char *n0 = "test0.brt"; const char *n1 = "test1.brt"; CACHETABLE ct; BRT t0,t1; int r,i; printf("test_multiple_files_of_size(%d)\n", size); unlink(n0); unlink(n1); memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(n0, 0, 1, &t0, size, ct, null_txn, toku_default_compare_fun); assert(r==0); r = open_brt(n1, 0, 1, &t1, size, ct, null_txn, toku_default_compare_fun); assert(r==0); for (i=0; i<10000; i++) { char key[100],val[100]; DBT k,v; snprintf(key, 100, "key%d", i); snprintf(val, 100, "val%d", i); brt_insert(t0, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn); snprintf(val, 100, "Val%d", i); brt_insert(t1, fill_dbt(&k, key, 1+strlen(key)), fill_dbt(&v, val, 1+strlen(val)), null_db, null_txn); } //toku_verify_brt(t0); //dump_brt(t0); //dump_brt(t1); toku_verify_brt(t0); toku_verify_brt(t1); r = close_brt(t0); assert(r==0); r = close_brt(t1); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); /* Now see if the data is all there. */ r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(n0, 0, 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); printf("%s:%d r=%d\n", __FILE__, __LINE__,r); assert(r==0); r = open_brt(n1, 0, 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); for (i=0; i<10000; i++) { char key[100],val[100]; DBT k,actual; snprintf(key, 100, "key%d", i); snprintf(val, 100, "val%d", i); r=brt_lookup(t0, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual), 0); assert(r==0); assert(strcmp(val,actual.data)==0); assert(actual.size==1+strlen(val)); snprintf(val, 100, "Val%d", i); r=brt_lookup(t1, fill_dbt(&k, key, 1+strlen(key)), init_dbt(&actual), 0); assert(r==0); assert(strcmp(val,actual.data)==0); assert(actual.size==1+strlen(val)); } r = close_brt(t0); assert(r==0); r = close_brt(t1); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); } static void test_multiple_files (void) { test_multiple_files_of_size (1<<12); test_multiple_files_of_size (1<<20); } static void test_named_db (void) { const char *n0 = "test0.brt"; const char *n1 = "test1.brt"; CACHETABLE ct; BRT t0; int r; DBT k,v; printf("test_named_db\n"); unlink(n0); unlink(n1); memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "day", 4), null_db, null_txn); assert(r==0); r = close_brt(t0); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); { r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0); assert(r==0); assert(v.size==4); assert(strcmp(v.data,"day")==0); } r = close_brt(t0); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); } static void test_multiple_dbs (void) { const char *n0 = "test0.brt"; const char *n1 = "test1.brt"; CACHETABLE ct; BRT t0,t1; int r; DBT k,v; printf("test_multiple_dbs: "); unlink(n0); unlink(n1); memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(n0, "db1", 1, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); r = open_brt(n1, "db2", 1, &t1, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); brt_insert(t0, fill_dbt(&k, "good", 5), fill_dbt(&v, "grief", 6), null_db, null_txn); assert(r==0); brt_insert(t1, fill_dbt(&k, "bad", 4), fill_dbt(&v, "night", 6), null_db, null_txn); assert(r==0); r = close_brt(t0); assert(r==0); r = close_brt(t1); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(n0, "db1", 0, &t0, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); r = open_brt(n1, "db2", 0, &t1, 1<<12, ct, null_txn, toku_default_compare_fun); assert(r==0); { r = brt_lookup(t0, fill_dbt(&k, "good", 5), init_dbt(&v), 0); assert(r==0); assert(v.size==6); assert(strcmp(v.data,"grief")==0); r = brt_lookup(t1, fill_dbt(&k, "good", 5), init_dbt(&v), 0); assert(r!=0); r = brt_lookup(t0, fill_dbt(&k, "bad", 4), init_dbt(&v), 0); assert(r!=0); r = brt_lookup(t1, fill_dbt(&k, "bad", 4), init_dbt(&v), 0); assert(r==0); assert(v.size==6); assert(strcmp(v.data,"night")==0); } r = close_brt(t0); assert(r==0); r = close_brt(t1); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); memory_check_all_free(); printf("ok\n"); } /* Test to see a single file can contain many databases. */ static void test_multiple_dbs_many (void) { enum { MANYN = 16 }; int i, r; const char *name = "test.brt"; CACHETABLE ct; BRT trees[MANYN]; printf("test_multiple_dbs_many:\n"); memory_check_all_free(); unlink(name); r = brt_create_cachetable(&ct, MANYN+4, ZERO_LSN, NULL_LOGGER); assert(r==0); for (i=0; idata; unsigned char *bd=b->data; unsigned int siz=a->size; assert(a->size==b->size); assert(db==&nonce_db); // make sure the db was passed down correctly for (i=0; ibd[siz-1-i]) return +1; } return 0; } static void test_wrongendian_compare (int wrong_p, unsigned int N) { const char *n="testbrt.brt"; CACHETABLE ct; BRT brt; BRT_CURSOR cursor; int r; DBT kbt, vbt; unsigned int i; unlink(n); memory_check_all_free(); { char a[4]={0,1,0,0}; char b[4]={1,0,0,0}; DBT at, bt; assert(wrong_compare_fun(&nonce_db, fill_dbt(&at, a, 4), fill_dbt(&bt, b, 4))>0); assert(wrong_compare_fun(&nonce_db, fill_dbt(&at, b, 4), fill_dbt(&bt, a, 4))<0); } r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); //printf("%s:%d WRONG=%d\n", __FILE__, __LINE__, wrong_p); if (0) { // ???? Why is this commented out? r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun); assert(r==0); for (i=1; i<257; i+=255) { unsigned char a[4],b[4]; b[3] = a[0] = i&255; b[2] = a[1] = (i>>8)&255; b[1] = a[2] = (i>>16)&255; b[0] = a[3] = (i>>24)&255; fill_dbt(&kbt, a, sizeof(a)); fill_dbt(&vbt, b, sizeof(b)); printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__, ((char*)kbt.data)[0], ((char*)kbt.data)[1], ((char*)kbt.data)[2], ((char*)kbt.data)[3], ((char*)vbt.data)[0], ((char*)vbt.data)[1], ((char*)vbt.data)[2], ((char*)vbt.data)[3]); r = brt_insert(brt, &kbt, &vbt, &nonce_db, null_txn); assert(r==0); } r = brt_cursor(brt, &cursor); assert(r==0); for (i=0; i<2; i++) { init_dbt(&kbt); init_dbt(&vbt); r = brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, null_db, null_txn); assert(r==0); assert(kbt.size==4 && vbt.size==4); printf("%s:%d %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__, ((char*)kbt.data)[0], ((char*)kbt.data)[1], ((char*)kbt.data)[2], ((char*)kbt.data)[3], ((char*)vbt.data)[0], ((char*)vbt.data)[1], ((char*)vbt.data)[2], ((char*)vbt.data)[3]); } r = close_brt(brt); } { toku_cachetable_verify(ct); r = open_brt(n, 0, 1, &brt, 1<<20, ct, null_txn, wrong_p ? wrong_compare_fun : toku_default_compare_fun); assert(r==0); toku_cachetable_verify(ct); for (i=0; i>8)&255; b[1] = a[2] = (i>>16)&255; b[0] = a[3] = (i>>24)&255; fill_dbt(&kbt, a, sizeof(a)); fill_dbt(&vbt, b, sizeof(b)); if (0) printf("%s:%d insert: %02x%02x%02x%02x -> %02x%02x%02x%02x\n", __FILE__, __LINE__, ((unsigned char*)kbt.data)[0], ((unsigned char*)kbt.data)[1], ((unsigned char*)kbt.data)[2], ((unsigned char*)kbt.data)[3], ((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]); r = brt_insert(brt, &kbt, &vbt, &nonce_db, null_txn); assert(r==0); toku_cachetable_verify(ct); } r = brt_cursor(brt, &cursor); assert(r==0); int prev=-1; for (i=0; i %02x%02x%02x%02x\n", __FILE__, __LINE__, ((unsigned char*)kbt.data)[0], ((unsigned char*)kbt.data)[1], ((unsigned char*)kbt.data)[2], ((unsigned char*)kbt.data)[3], ((unsigned char*)vbt.data)[0], ((unsigned char*)vbt.data)[1], ((unsigned char*)vbt.data)[2], ((unsigned char*)vbt.data)[3]); this= ( (((unsigned char*)kbt.data)[3] << 24) + (((unsigned char*)kbt.data)[2] << 16) + (((unsigned char*)kbt.data)[1] << 8) + (((unsigned char*)kbt.data)[0] << 0)); assert(prevdata, a->size, b->data, b->size); } void assert_cursor_notfound(BRT brt, int position, DB *db) { BRT_CURSOR cursor; int r; DBT kbt, vbt; r = brt_cursor(brt, &cursor); assert(r==0); init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = brt_cursor_get(cursor, &kbt, &vbt, position, db, null_txn); assert(r == DB_NOTFOUND); r = brt_cursor_close(cursor); assert(r==0); } void assert_cursor_value(BRT brt, int position, long long value, DB *db) { BRT_CURSOR cursor; int r; DBT kbt, vbt; long long v; r = brt_cursor(brt, &cursor); assert(r==0); if (test_cursor_debug) printf("key: "); init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = brt_cursor_get(cursor, &kbt, &vbt, position, db, null_txn); assert(r == 0); if (test_cursor_debug) printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == value); toku_free(kbt.data); toku_free(vbt.data); if (test_cursor_debug) printf("\n"); r = brt_cursor_close(cursor); assert(r==0); } void assert_cursor_first_last(BRT brt, long long firstv, long long lastv, DB *db) { BRT_CURSOR cursor; int r; DBT kbt, vbt; long long v; r = brt_cursor(brt, &cursor); assert(r==0); if (test_cursor_debug) printf("first key: "); init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = brt_cursor_get(cursor, &kbt, &vbt, DB_FIRST, db, null_txn); assert(r == 0); if (test_cursor_debug) printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == firstv); toku_free(kbt.data); toku_free(vbt.data); if (test_cursor_debug) printf("\n"); if (test_cursor_debug) printf("last key:"); init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = brt_cursor_get(cursor, &kbt, &vbt, DB_LAST, db, null_txn); assert(r == 0); if (test_cursor_debug)printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == lastv); toku_free(kbt.data); toku_free(vbt.data); if (test_cursor_debug) printf("\n"); r = brt_cursor_close(cursor); assert(r==0); } void test_brt_cursor_first(int n, DB *db) { const char *fname="testbrt.brt"; CACHETABLE ct; BRT brt; int r; int i; printf("test_brt_cursor_first:%d %p\n", n, db); unlink(fname); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare); assert(r==0); /* insert a bunch of kv pairs */ for (i=0; i=0; i--) { char key[8]; long long v; DBT kbt, vbt; snprintf(key, sizeof key, "%4.4d", i); fill_dbt(&kbt, key, strlen(key)+1); v = i; fill_dbt(&vbt, &v, sizeof v); r = brt_insert(brt, &kbt, &vbt, db, 0); assert(r==0); } if (n == 0) assert_cursor_notfound(brt, DB_FIRST, db); else assert_cursor_value(brt, DB_FIRST, 0, db); r = close_brt(brt); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } void assert_cursor_walk(BRT brt, int n, DB *db) { BRT_CURSOR cursor; int i; int r; r = brt_cursor(brt, &cursor); assert(r==0); if (test_cursor_debug) printf("key: "); for (i=0; ; i++) { DBT kbt, vbt; long long v; init_dbt(&kbt); kbt.flags = DB_DBT_MALLOC; init_dbt(&vbt); vbt.flags = DB_DBT_MALLOC; r = brt_cursor_get(cursor, &kbt, &vbt, DB_NEXT, db, null_txn); if (r != 0) break; if (test_cursor_debug) printf("%s ", (char*)kbt.data); assert(vbt.size == sizeof v); memcpy(&v, vbt.data, vbt.size); assert(v == i); toku_free(kbt.data); toku_free(vbt.data); } if (test_cursor_debug) printf("\n"); assert(i == n); r = brt_cursor_close(cursor); assert(r==0); } void test_brt_cursor_walk(int n, DB *db) { const char *fname="testbrt.brt"; CACHETABLE ct; BRT brt; int r; int i; printf("test_brt_cursor_walk:%d %p\n", n, db); unlink(fname); r = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0); r = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare); assert(r==0); /* insert a bunch of kv pairs */ for (i=0; i= v */ for (i=0; i max_key) /* there is no smallest key if v > the max key */ assert(r == DB_NOTFOUND); else { assert(r == 0); assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == (((v+9)/10)*10)); toku_free(val.data); } } r = brt_cursor_close(cursor); assert(r==0); r = close_brt(brt); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } void test_brt_cursor_delete(int n, DB *db) { printf("test_brt_cursor_delete:%d %p\n", n, db); int error; char fname[]="testbrt.brt"; CACHETABLE ct; BRT brt; BRT_CURSOR cursor; unlink(fname); error = brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(error == 0); error = open_brt(fname, 0, 1, &brt, 1<<12, ct, null_txn, test_brt_cursor_keycompare); assert(error == 0); error = brt_cursor(brt, &cursor); assert(error == 0); DBT key, val; int k, v; int i; /* insert keys 0, 1, 2, .. (n-1) */ for (i=0; i 0) { k = htonl(n-1); fill_dbt(&key, &k, sizeof k); r = brt_delete(t, &key, 0); assert(r == 0); k = htonl(n-1); fill_dbt(&key, &k, sizeof k); init_dbt(&val); val.flags = DB_DBT_MALLOC; r = brt_lookup(t, &key, &val, 0); assert(r == DB_NOTFOUND); } r = close_brt(t); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0); } void test_brt_delete() { test_brt_delete_empty(); memory_check_all_free(); test_brt_delete_present(1); memory_check_all_free(); test_brt_delete_present(100); memory_check_all_free(); test_brt_delete_present(500); memory_check_all_free(); test_brt_delete_not_present(1); memory_check_all_free(); test_brt_delete_not_present(100); memory_check_all_free(); test_brt_delete_not_present(500); memory_check_all_free(); test_brt_delete_cursor_first(1); memory_check_all_free(); test_brt_delete_cursor_first(100); memory_check_all_free(); test_brt_delete_cursor_first(500); memory_check_all_free(); test_brt_delete_cursor_first(10000); memory_check_all_free(); test_insert_delete_lookup(512); memory_check_all_free(); } static void brt_blackbox_test (void) { memory_check = 1; test_wrongendian_compare(0, 2); memory_check_all_free(); test_wrongendian_compare(1, 2); memory_check_all_free(); test_wrongendian_compare(1, 257); memory_check_all_free(); test_wrongendian_compare(1, 1000); memory_check_all_free(); test_read_what_was_written(); memory_check_all_free(); printf("did read_what_was_written\n"); test_cursor_next(); memory_check_all_free(); test_multiple_dbs_many(); memory_check_all_free(); test_cursor_last_empty(); memory_check_all_free(); test_multiple_brts_one_db_one_file(); memory_check_all_free(); test_dump_empty_db(); memory_check_all_free(); test_named_db(); memory_check_all_free(); test_multiple_dbs(); memory_check_all_free(); printf("test0 A\n"); test0(); printf("test0 B\n"); test0(); /* Make sure it works twice. */ printf("test1\n"); test1(); printf("test2 checking memory\n"); test2(1); printf("test2 faster\n"); test2(0); printf("test5\n"); test5(); printf("test_multiple_files\n"); test_multiple_files(); printf("test3 slow\n"); memory_check=0; test3(2048, 1<<15, 1); printf("test4 slow\n"); test4(2048, 1<<15, 1); printf("test3 fast\n"); toku_pma_show_stats(); test3(1<<15, 1024, 1); test4(1<<15, 1024, 1); printf("test3 fast\n"); 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); memory_check = 1; test_brt_limits(); DB a_db; DB *db = &a_db; test_brt_cursor(db); test_brt_delete(); int old_brt_do_push_cmd = brt_do_push_cmd; brt_do_push_cmd = 0; test_brt_delete(); test_brt_cursor(db); brt_do_push_cmd = old_brt_do_push_cmd; // test3(1<<19, 1<<20, 0); // test4(1<<19, 1<<20, 0); // test3(1<<20, 1<<20, 0); // test4(1<<20, 1<<20, 0); // test3(1<<20, 1<<21, 0); // test4(1<<20, 1<<21, 0); // test3(1<<20, 1<<22, 0); // test4(1<<20, 1<<22, 0); } int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { brt_blackbox_test(); malloc_cleanup(); printf("test ok\n"); return 0; }