Commit 24bcc114 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

up

git-svn-id: file:///svn/tokudb@516 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1df53726
CFLAGS = -Wall -Werror -O2 -g
CPPFLAGS = -I../../include
# On OSX do:
# make OSX=OSX
#Note: On OSX, ld does not support -rpath, so /usr/lib/libdb.dylib must be the tokudb library.
ifeq ($(OSX),OSX)
LIBEXT=dylib
TEST=
LOADLIBES = -L../ -ldb
else
LIBEXT=so
LOADLIBES = -L../ -ldb -Wl,-rpath,..
TEST=valgrind --quiet --error-exitcode=1
endif
LIBNAME=libdb.$(LIBEXT)
CFLAGS = -Wall -Werror -O0 -g
CPPFLAGS = -I../../include
SRCS = $(wildcard *.c)
TESTS = $(patsubst %.c,%,$(SRCS))
all: make_libs $(TESTS)
test_log1.bdb: test_log1
test_log1 test_log0: ../libdb.so
check_log0: ./test_log0
valgrind --quiet ./test_log0
$(TEST) ./test_log0
test -f dir.test_log0/log000000000000.tokulog
check_log1: ./test_log1
valgrind --quiet ./test_log1
$(TEST) ./test_log1
check_db_close_no_open: ./test_db_close_no_open
valgrind --quiet ./test_db_close_no_open
$(TEST) ./test_db_close_no_open
check_db_version: ./test_db_version
valgrind --quiet ./test_db_version
$(TEST) ./test_db_version
check_db_open_notexist_reopen : ./test_db_open_notexist_reopen
$(TEST) ./test_db_open_notexist_reopen
.PHONY: check_log0 make_libs
make_libs:
cd ..;make
check: make_libs check_log0 check_log1 check_db_close_no_open check_db_version
check: $(TESTS) check_log0
for testcase in $(TESTS) ; do echo $(TEST) ./$$testcase ; if ! $(TEST) ./$$testcase; then echo "Test Failed!" ; exit 1; fi; done
test_log1.bdb: test_log1.c
cc -Wall -Werror -O2 -g test_log1.c -o $@ -ldb -DDBVERSION=\"bdb\"
......@@ -28,4 +51,4 @@ test_log1.tokudb_link: test_log1.c
cc -Wall -Werror -O2 -g test_log1.c -o $@ $(LOADLIBES)
clean:
rm -f test_log0 test_log1 test_db_close_no_open test_db_version
rm -f $(TESTS)
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <db.h>
int main() {
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = "test.already.exists.brt";
int r;
r = unlink(fname);
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->set_flags(db, DB_DUP);
assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
assert(r == 0);
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
assert(r != 0);
r = db->close(db, 0);
assert(r == 0);
return 0;
}
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <db.h>
int main() {
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = "test.dup.brt";
int r;
unlink(fname);
/* create the dup database file */
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->set_flags(db, DB_DUP);
assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
assert(r == 0);
r = db->close(db, 0);
assert(r == 0);
/* verify dup flags match */
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
assert(r != 0);
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->set_flags(db, DB_DUP);
assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
assert(r == 0);
r = db->close(db, 0);
assert(r == 0);
/* verify nodesize match */
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->set_flags(db, DB_DUP);
assert(r == 0);
r = db->set_pagesize(db, 4096);
assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
assert(r == 0);
r = db->close(db, 0);
assert(r == 0);
return 0;
}
#include <stdio.h>
#include <assert.h>
#include <db.h>
int main() {
DB_ENV *dbenv;
int r;
r = db_env_create(&dbenv, 0);
assert(r == 0);
r = dbenv->close(dbenv, 0);
assert(r == 0);
return 0;
}
#include <stdio.h>
#include <assert.h>
#include <db.h>
int main() {
DB_ENV *dbenv;
int r;
r = db_env_create(&dbenv, 0);
assert(r == 0);
r = dbenv->open(dbenv, ".", DB_PRIVATE, 0);
assert(r == 0);
r = dbenv->open(dbenv, ".", DB_PRIVATE, 0);
assert(r != 0);
r = dbenv->close(dbenv, 0);
assert(r == 0);
return 0;
}
#include <stdio.h>
#include <assert.h>
#include <db.h>
int main() {
DB_ENV *dbenv;
int r;
r = db_env_create(&dbenv, 0);
assert(r == 0);
r = dbenv->set_data_dir(dbenv, ".");
assert(r == 0);
r = dbenv->set_data_dir(dbenv, ".");
assert(r == 0);
r = dbenv->open(dbenv, ".", DB_PRIVATE+DB_INIT_MPOOL, 0);
assert(r == 0);
r = dbenv->set_data_dir(dbenv, ".");
assert(r != 0);
r = dbenv->close(dbenv, 0);
assert(r == 0);
return 0;
}
#include <stdio.h>
#include <assert.h>
#include <db.h>
int main() {
DB_ENV *dbenv;
int r;
r = db_env_create(&dbenv, 0);
assert(r == 0);
dbenv->set_errpfx(dbenv, "houdy partners: ");
r = dbenv->open(dbenv, ".", DB_PRIVATE+DB_INIT_MPOOL, 0);
assert(r == 0);
r = dbenv->close(dbenv, 0);
assert(r == 0);
return 0;
}
#include <stdio.h>
#include <assert.h>
#include <db.h>
int main() {
DB_ENV *dbenv;
int r;
r = db_env_create(&dbenv, 0);
assert(r == 0);
r = dbenv->set_tmp_dir(dbenv, ".");
// assert(r == 0);
r = dbenv->set_tmp_dir(dbenv, ".");
// assert(r == 0);
r = dbenv->close(dbenv, 0);
assert(r == 0);
return 0;
}
/* Do I return EINVAL when passing in NULL for something that would otherwise be strdup'd? */
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#include <db.h>
#define DIR "dir.test_db_open_notexist_reopen"
DB_ENV *env;
DB *db;
int main (int argc, char *argv[]) {
int r;
r=system("rm -rf " DIR); assert(r==0);
r=mkdir(DIR, 0777); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
r=env->set_data_dir(env, NULL); assert(r==EINVAL);
r=env->open(env, NULL, DB_PRIVATE, 0777); assert(r==EINVAL);
r=env->open(env, DIR, DB_PRIVATE, 0777); assert(r==0);
env->set_errpfx(env, NULL); assert(1); //Did not crash.
r=env->set_tmp_dir(env, NULL); assert(r==EINVAL);
r=env->close(env, 0); assert(r==0);
return 0;
}
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <db.h>
int main (int argc, char *argv[]) {
DB *db;
int r;
r = db_create(&db, 0, 0);
assert(r == 0);
r = db->close(db, 0);
assert(r == 0);
return 0;
}
/* Simple test of logging. Can I start a TokuDB with logging enabled? */
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#include <db.h>
#define DIR "dir.test_db_open_notexist_reopen"
DB_ENV *env;
DB *db;
int main (int argc, char *argv[]) {
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_PRIVATE|DB_CREATE, 0777); assert(r==0);
r=db_create(&db, env, 0); assert(r==0);
r=db->open(db, NULL, "doesnotexist.db", "testdb", DB_BTREE, 0, 0666); assert(r==ENOENT);
r=db->open(db, NULL, "doesnotexist.db", "testdb", DB_BTREE, DB_CREATE, 0666); assert(r==0);
r=db->close(db, 0); assert(r==0);
r=env->close(env, 0); assert(r==0);
return 0;
}
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <db.h>
int main (int argc, char *argv[]) {
DB_ENV *env;
DB *db;
int r;
r = db_env_create(&env, 0);
assert(r == 0);
r = db_create(&db, env, 0);
assert(r != 0);
r = env->close(env, 0);
assert(r == 0);
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