Commit ac690d78 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Add {{{test_log9}}} to tests. It breaks. Addresses #547.

git-svn-id: file:///svn/tokudb@2881 c7de825b-a66e-492c-adef-691d508d4ae1
parent 60b6abe1
...@@ -135,7 +135,7 @@ libs: ...@@ -135,7 +135,7 @@ libs:
$(SETTOKUENV) cc -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@ $(SETTOKUENV) cc -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
.PHONY: %.recover .PHONY: %.recover
all.recover: test_log2.recover test_log3.recover test_log4.recover test_log5.recover test_log6.recover test_log7.recover all.recover: test_log2.recover test_log3.recover test_log4.recover test_log5.recover test_log6.recover test_log7.recover test_log8.recover test_log9.recover
%.recover: %.tdb %.recover: %.tdb
$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$<
$(MAYBEATSIGN) $(SETTOKUENV) rm -rf dir.$(patsubst %.tdb,%.c.tdb,$<).recover $(MAYBEATSIGN) $(SETTOKUENV) rm -rf dir.$(patsubst %.tdb,%.c.tdb,$<).recover
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
/* Test to see if we can do logging and recovery. */
/* This is very specific to TokuDB. It won't work with Berkeley DB. */
/* This test_log8 inserts to a db, closes, reopens, and inserts more to db. We want to make sure that the recovery of the buffers works. */
#include <assert.h>
#include <db.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
// ENVDIR is defined in the Makefile
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
struct in_db;
struct in_db {
long int r;
int i;
struct in_db *next;
} *items=0;
int maxcount = 10;
static void insert_some (int outeri) {
u_int32_t create_flag = outeri%2 ? DB_CREATE : 0; // Sometimes use DB_CREATE, sometimes don't.
int r;
DB_ENV *env;
DB *db;
DB_TXN *tid;
r=db_env_create(&env, 0); assert(r==0);
r=env->set_lk_max_locks(env, 2*maxcount); CKERR(r);
r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|create_flag, 0777); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
r=db->open(db, tid, "foo.db", 0, DB_BTREE, create_flag, 0777); CKERR(r);
r=tid->commit(tid, 0); assert(r==0);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
int i;
for (i=0; i<maxcount; i++) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
items = newitem;
snprintf(hello, sizeof(hello), "hello%ld.%d.%d", newitem->r, outeri, newitem->i);
snprintf(there, sizeof(hello), "there%d", i);
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
key.data = hello; key.size=strlen(hello)+1;
data.data = there; data.size=strlen(there)+1;
r=db->put(db, tid, &key, &data, 0); assert(r==0);
}
r=tid->commit(tid, 0); assert(r==0);
r=db->close(db, 0); assert(r==0);
r=env->close(env, 0); assert(r==0);
}
static void make_db (void) {
DB_ENV *env;
DB *db;
DB_TXN *tid;
int r;
int i;
system("rm -rf " ENVDIR);
r=mkdir(ENVDIR, 0777); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
r=env->set_lk_max_locks(env, 2*maxcount); CKERR(r);
r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, 0777); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
r=db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, 0777); CKERR(r);
r=tid->commit(tid, 0); assert(r==0);
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
for (i=0; i<2; i++)
insert_some(i);
while (items) {
struct in_db *next=items->next;
free(items);
items=next;
}
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
make_db();
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