Commit 45a78f78 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Create a test for #632. Addresses #632.

git-svn-id: file:///svn/tokudb@3234 c7de825b-a66e-492c-adef-691d508d4ae1
parent fff5a354
...@@ -62,6 +62,7 @@ REGRESSION_TESTS = \ ...@@ -62,6 +62,7 @@ REGRESSION_TESTS = \
brt-test2 \ brt-test2 \
brt-test3 \ brt-test3 \
brt-test4 \ brt-test4 \
test-brt-overflow \
brt-test-named-db \ brt-test-named-db \
brt-test-cursor \ brt-test-cursor \
brt-test-cursor-2 \ brt-test-cursor-2 \
...@@ -121,6 +122,7 @@ CHECKS = \ ...@@ -121,6 +122,7 @@ CHECKS = \
brt-test2 \ brt-test2 \
brt-test3 \ brt-test3 \
brt-test4 \ brt-test4 \
test-brt-overflow \
brt-test-named-db \ brt-test-named-db \
fifo-test \ fifo-test \
test_toku_malloc_plain_free \ test_toku_malloc_plain_free \
...@@ -153,7 +155,7 @@ check-fanout: ...@@ -153,7 +155,7 @@ check-fanout:
let BRT_FANOUT=BRT_FANOUT+1; \ let BRT_FANOUT=BRT_FANOUT+1; \
done done
log-test log-test2 log-test3 log-test4 log-test5 log-test6 benchmark-test brt-test brt-test0 brt-test1 brt-test2 brt-test3 brt-test4 brt-test-named-db brt-test-cursor brt-test-cursor-2 test-brt-delete-both brt-serialize-test brtdump test-inc-split test-del-inorder: LDFLAGS+=-lz log-test log-test2 log-test3 log-test4 log-test5 log-test6 benchmark-test brt-test brt-test0 brt-test1 brt-test2 brt-test3 brt-test4 test-brt-overflow brt-test-named-db brt-test-cursor brt-test-cursor-2 test-brt-delete-both brt-serialize-test brtdump test-inc-split test-del-inorder: LDFLAGS+=-lz
# pma: PROF_FLAGS=-fprofile-arcs -ftest-coverage # pma: PROF_FLAGS=-fprofile-arcs -ftest-coverage
BRT_INTERNAL_H_INCLUDES = brt-internal.h cachetable.h fifo.h gpma.h brt.h brt-search.h brttypes.h yerror.h ybt.h log.h ../include/db.h kv-pair.h memory.h crc.h mempool.h BRT_INTERNAL_H_INCLUDES = brt-internal.h cachetable.h fifo.h gpma.h brt.h brt-search.h brttypes.h yerror.h ybt.h log.h ../include/db.h kv-pair.h memory.h crc.h mempool.h
...@@ -174,10 +176,10 @@ ybt.o: ybt.h brttypes.h ../include/db.h ...@@ -174,10 +176,10 @@ ybt.o: ybt.h brttypes.h ../include/db.h
ybt-test: ybt-test.o ybt.o memory.o toku_assert.o ybt-test: ybt-test.o ybt.o memory.o toku_assert.o
ybt-test.o: ybt.h ../include/db.h ybt-test.o: ybt.h ../include/db.h
cachetable.o: cachetable.h hashfun.h memory.h cachetable.o: cachetable.h hashfun.h memory.h
brt-test0 brt-test1 brt-test2 brt-test3 brt-test4 brt-test-named-db brt-test-cursor brt-test-cursor-2 brt-test: ybt.o brt.o fifo.o gpma.o memory.o brt-serialize.o cachetable.o ybt.o key.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o brt-test0 brt-test1 brt-test2 brt-test3 brt-test4 test-brt-overflow brt-test-named-db brt-test-cursor brt-test-cursor-2 brt-test: ybt.o brt.o fifo.o gpma.o memory.o brt-serialize.o cachetable.o ybt.o key.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o
log.o: log_header.h log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES) log.o: log_header.h log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES)
logformat: logformat.o toku_assert.o logformat: logformat.o toku_assert.o
brt-test0.o brt-test1.o brt-test2.o brt-test3.o brt-test4.o brt-test-named-db.o brt-test-cursor.o brt-test-cursor-2.o brt-test.o brt.o: brt.h brt-search.h ../include/db.h fifo.h gpma.h brttypes.h cachetable.h memory.h brt-test0.o brt-test1.o brt-test2.o brt-test3.o brt-test4.o test-brt-overflow.h brt-test-named-db.o brt-test-cursor.o brt-test-cursor-2.o brt-test.o brt.o: brt.h brt-search.h ../include/db.h fifo.h gpma.h brttypes.h cachetable.h memory.h
brt-serialize-test.o: $(BRT_INTERNAL_H_INCLUDES) brt-serialize-test.o: $(BRT_INTERNAL_H_INCLUDES)
brt.o: $(BRT_INTERNAL_H_INCLUDES) key.h log_header.h brt.o: $(BRT_INTERNAL_H_INCLUDES) key.h log_header.h
fifo.o: fifo.h brttypes.h fifo.o: fifo.h brttypes.h
......
...@@ -255,6 +255,15 @@ int malloc_diskblock (DISKOFF *res, BRT brt, int size, TOKULOGGER logger) { ...@@ -255,6 +255,15 @@ int malloc_diskblock (DISKOFF *res, BRT brt, int size, TOKULOGGER logger) {
#endif #endif
} }
u_int32_t mp_pool_size_for_nodesize (u_int32_t nodesize) {
#if 0
return nodesize+nodesize/4;
#else
return nodesize;
#endif
}
static void initialize_brtnode (BRT t, BRTNODE n, DISKOFF nodename, int height) { static void initialize_brtnode (BRT t, BRTNODE n, DISKOFF nodename, int height) {
n->tag = TYP_BRTNODE; n->tag = TYP_BRTNODE;
n->nodesize = t->h->nodesize; n->nodesize = t->h->nodesize;
...@@ -280,7 +289,7 @@ static void initialize_brtnode (BRT t, BRTNODE n, DISKOFF nodename, int height) ...@@ -280,7 +289,7 @@ static void initialize_brtnode (BRT t, BRTNODE n, DISKOFF nodename, int height)
{ {
void *mp = toku_malloc(n->nodesize); void *mp = toku_malloc(n->nodesize);
assert(mp); assert(mp);
toku_mempool_init(&n->u.l.buffer_mempool, mp, n->nodesize); toku_mempool_init(&n->u.l.buffer_mempool, mp, mp_pool_size_for_nodesize(n->nodesize));
} }
static int rcount=0; static int rcount=0;
......
/* Test an overflow condition on the leaf. See #632. */
#include "brt.h"
#include "key.h"
#include "toku_assert.h"
#include <string.h>
#include <unistd.h>
int verbose;
static const char fname[]= __FILE__ ".brt";
static TOKUTXN const null_txn = 0;
static DB * const null_db = 0;
void test_overflow (void) {
BRT t;
CACHETABLE ct;
u_int32_t nodesize = 1<<20;
int r;
unlink(fname);
r = toku_brt_create_cachetable(&ct, 0, ZERO_LSN, NULL_LOGGER); assert(r==0);
r = toku_open_brt(fname, 0, 1, &t, nodesize, ct, null_txn, toku_default_compare_fun, null_db); assert(r==0);
DBT k,v;
u_int32_t vsize = nodesize/8;
char buf[vsize];
memset(buf, 'a', vsize);
int i;
for (i=0; i<8; i++) {
char key[]={'a'+i, 0};
toku_brt_insert(t, toku_fill_dbt(&k, key, 2), toku_fill_dbt(&v,buf,sizeof(buf)), null_txn);
}
r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0);
}
int main (int argc, const char *argv[]) {
int i;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (0 == strcmp(arg, "-v") || 0 == strcmp(arg, "--verbose"))
verbose = 1;
else if (0 == strcmp(arg, "-q") || 0 == strcmp(arg, "--quiet"))
verbose = 0;
}
test_overflow();
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