#include #include #include #include "test.h" #include "cachetable.h" const int item_size = 1; int n_flush, n_write_me, n_keep_me, n_fetch; void flush(CACHEFILE cf, CACHEKEY key, void *value, long size, BOOL write_me, BOOL keep_me, LSN modified_lsn, BOOL rename_p) { cf = cf; modified_lsn = modified_lsn; rename_p = rename_p; assert(key == (CACHEKEY)(long)value); assert(size == item_size); n_flush++; if (write_me) n_write_me++; if (keep_me) n_keep_me++; } int fetch() { n_fetch++; return 0; } // put n items into the cachetable, maybe mark them dirty, do a checkpoint, and // verify that all of the items have been written and are clean. void cachetable_checkpoint_test(int n, int dirty) { const int test_limit = n; int r; CACHETABLE ct; r = toku_create_cachetable(&ct, test_limit, ZERO_LSN, NULL_LOGGER); assert(r == 0); char fname1[] = __FILE__ "test1.dat"; unlink(fname1); CACHEFILE f1; r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); // insert items into the cachetable. all should be dirty int i; for (i=0; i