Commit 29ac9b3c authored by Rich Prohaska's avatar Rich Prohaska

merge cachetable tests from the 1075 branch to main. addresses #1075

git-svn-id: file:///svn/tokudb@5849 c7de825b-a66e-492c-adef-691d508d4ae1
parent de17684f
......@@ -67,8 +67,10 @@ REGRESSION_TESTS = \
cachetable-unpin-test \
cachetable-rename-test \
cachetable-fd-test \
cachetable-flush-test \
cachetable-count-pinned-test \
cachetable-checkpoint-test \
cachetable-debug-test \
fifo-test \
list-test \
keyrange \
......
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include "test.h"
#include "cachetable.h"
......@@ -30,6 +31,17 @@ void cachetable_fd_test() {
r = toku_cachefile_set_fd(cf, fd3, "/dev/null"); assert(r != 0);
assert(toku_cachefile_fd(cf) == fd2);
// test the filenum functions
FILENUM fn = toku_cachefile_filenum(cf);
CACHEFILE newcf = 0;
r = toku_cachefile_of_filenum(ct, fn, &newcf);
assert(r == 0 && cf == newcf);
// test a bogus filenum
fn.fileid++;
r = toku_cachefile_of_filenum(ct, fn, &newcf);
assert(r == ENOENT);
r = toku_cachefile_close(&cf, NULL_LOGGER); assert(r == 0 && cf == 0);
r = toku_cachetable_close(&ct); assert(r == 0 && ct == 0);
}
......
......@@ -86,8 +86,9 @@ static void readit (void) {
int i, r;
void *block;
long current_size;
CACHEKEY key;
for (i=0; i<N; i++) {
CACHEKEY key = i*BLOCKSIZE;
key = i*BLOCKSIZE;
u_int32_t fullhash = toku_cachetable_hash(f, key);
r=toku_cachetable_get_and_pin(f, key, fullhash, &block, &current_size, f_flush, f_fetch, 0); assert(r==0);
r=toku_cachetable_unpin(f, key, fullhash, 0, BLOCKSIZE); assert(r==0);
......
......@@ -151,6 +151,10 @@ static void test0 (void) {
unlink(fname);
r = toku_cachetable_openf(&f, t, fname, O_RDWR|O_CREAT, 0777);
assert(r==0);
TOKULOGGER logger = toku_cachefile_logger(f);
assert(logger == NULL_LOGGER);
expect_f = f;
expect_n_flushes=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