mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 07:14:17 +01:00
4a88cb22b4
git-svn-id: file:///svn/toku/tokudb@32519 c7de825b-a66e-492c-adef-691d508d4ae1
86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
#include "includes.h"
|
|
#include "test.h"
|
|
|
|
static void
|
|
flush (CACHEFILE f __attribute__((__unused__)),
|
|
int UU(fd),
|
|
CACHEKEY k __attribute__((__unused__)),
|
|
void *v __attribute__((__unused__)),
|
|
void *e __attribute__((__unused__)),
|
|
long s __attribute__((__unused__)),
|
|
BOOL w __attribute__((__unused__)),
|
|
BOOL keep __attribute__((__unused__)),
|
|
BOOL c __attribute__((__unused__))
|
|
) {
|
|
/* Do nothing */
|
|
printf("FLUSH: %d\n", (int)k.b);
|
|
//usleep (5*1024*1024);
|
|
}
|
|
|
|
static int
|
|
fetch (CACHEFILE f __attribute__((__unused__)),
|
|
int UU(fd),
|
|
CACHEKEY k __attribute__((__unused__)),
|
|
u_int32_t fullhash __attribute__((__unused__)),
|
|
void **value __attribute__((__unused__)),
|
|
long *sizep __attribute__((__unused__)),
|
|
int *dirtyp,
|
|
void *extraargs __attribute__((__unused__))
|
|
) {
|
|
*dirtyp = 0;
|
|
*value = NULL;
|
|
*sizep = 8;
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
pe_callback (
|
|
void *brtnode_pv __attribute__((__unused__)),
|
|
long bytes_to_free __attribute__((__unused__)),
|
|
long* bytes_freed,
|
|
void* extraargs __attribute__((__unused__))
|
|
)
|
|
{
|
|
*bytes_freed = 0;
|
|
return 0;
|
|
}
|
|
|
|
static BOOL pf_req_callback(void* UU(brtnode_pv), void* UU(read_extraargs)) {
|
|
return FALSE;
|
|
}
|
|
|
|
static int pf_callback(void* UU(brtnode_pv), void* UU(read_extraargs), long* UU(sizep)) {
|
|
assert(FALSE);
|
|
}
|
|
|
|
|
|
static void
|
|
cachetable_test (void) {
|
|
const int test_limit = 12;
|
|
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);
|
|
|
|
void* v1;
|
|
//void* v2;
|
|
long s1;
|
|
//long s2;
|
|
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, flush, fetch, pe_callback, pf_req_callback, pf_callback, NULL, NULL);
|
|
r = toku_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, 8);
|
|
toku_cachetable_verify(ct);
|
|
r = toku_cachefile_close(&f1, 0, FALSE, ZERO_LSN); assert(r == 0 && f1 == 0);
|
|
r = toku_cachetable_close(&ct); lazy_assert_zero(r);
|
|
|
|
|
|
}
|
|
|
|
int
|
|
test_main(int argc, const char *argv[]) {
|
|
default_parse_args(argc, argv);
|
|
cachetable_test();
|
|
return 0;
|
|
}
|