Commit 5a23e289 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Improve test infrastructure. Addresses #27.

git-svn-id: file:///svn/tokudb@743 c7de825b-a66e-492c-adef-691d508d4ae1
parent 404af528
...@@ -52,7 +52,7 @@ foo: ...@@ -52,7 +52,7 @@ foo:
echo ALL_TESTS: $(ALL_TESTS) echo ALL_TESTS: $(ALL_TESTS)
.PHONY: check check.bdb check.tdb .PHONY: check check.bdb check.tdb
check: check.bdb check.tdb check.recover check: check.bdb check.tdb all.recover
@ echo ok @ echo ok
check.bdb: $(RUN_BDB_TESTS) check.bdb: $(RUN_BDB_TESTS)
check.tdb: $(RUN_TDB_TESTS) check.tdb: $(RUN_TDB_TESTS)
...@@ -102,14 +102,14 @@ $(patsubst %,test_%.bdbrun,$(NO_VGRIND)): VGRIND= ...@@ -102,14 +102,14 @@ $(patsubst %,test_%.bdbrun,$(NO_VGRIND)): VGRIND=
$(SETTOKUENV); cc -DDIR=\"dir.$<.tdb\" -DUSE_TDB $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@ $(SETTOKUENV); cc -DDIR=\"dir.$<.tdb\" -DUSE_TDB $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
.PHONY: %.recover .PHONY: %.recover
check.recover: logtest2.recover all.recover: test_log2.recover test_log3.recover
logtest2.recover: test_log2.tdb %.recover: %.tdb
cd ../../newbrt;make recover cd ../../newbrt;make recover
./test_log2.tdb ./$<
rm -rf dir.test_log2.c.tdb.recover rm -rf dir.$(patsubst %.tdb,%.c.tdb,$<).recover
mkdir dir.test_log2.c.tdb.recover mkdir dir.$(patsubst %.tdb,%.c.tdb,$<).recover
cd dir.test_log2.c.tdb.recover;../../../newbrt/recover ../dir.test_log2.c.tdb cd dir.$(patsubst %.tdb,%.c.tdb,$<).recover;../../../newbrt/recover ../dir.$(patsubst %.tdb,%.c.tdb,$<)
diff dir.test_log2.c.tdb/foo.db dir.test_log2.c.tdb.recover/foo.db diff dir.$(patsubst %.tdb,%.c.tdb,$<) dir.$(patsubst %.tdb,%.c.tdb,$<).recover/foo.db
make_libs: make_libs:
cd ..;make cd ..;make
......
/* Test to see if we can do logging and recovery. */
/* This is very specific to TokuDB. It won't work with Berkeley DB. */
#include <assert.h>
#include <db.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
// DIR 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);
static void make_db (void) {
DB_ENV *env;
DB *db;
DB_TXN *tid;
int r;
system("rm -rf " DIR);
r=mkdir(DIR, 0777); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
r=env->open(env, DIR, 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); assert(r==0);
r=env->close(env, 0); assert(r==0);
}
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