Commit 01bcc08d authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Some test cleanup

git-svn-id: file:///svn/tokudb@665 c7de825b-a66e-492c-adef-691d508d4ae1
parent caad2144
......@@ -6,7 +6,7 @@ ifeq ($(OSX),OSX)
LIBEXT=dylib
VGRIND=
TDB_LOADLIBES = -L../ -ldb
SETTOKUENV=export DYLD_LIBRARY_PATH=..
SETTOKUENV=DYLD_LIBRARY_PATH=..
UNSETTOKUENV=unset DYLD_LIBRARY_PATH
else
SETTOKUENV=true
......@@ -59,15 +59,18 @@ $(ALL_TESTS):
%.bdbrun: %.bdb
$(UNSETTOKUENV); $(VGRIND) ./$<
%.tdbrun: %.tdb
$(SETTOKUENV); $(VGRIND) ./$<
$(SETTOKUENV) $(VGRIND) ./$<
# For a few of the tests bdb is making valgrind unhappy.
NO_VGRIND = \
db_already_exists \
db_dup \
db_env_open_nocreate \
db_env_open_open_close \
db_open_notexist_reopen \
db_remove_subdb \
db_subdb \
rand_insert \
reverse_compare_fun \
# Comment to terminate list so the previous line can end with a slash
......
......@@ -21,41 +21,24 @@ int main() {
r=mkdir(DIR, 0777); assert(r==0);
r=chdir(DIR); 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);
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);
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db_create(&db, null_env, 0); CKERR(r);
r = db->set_flags(db, DB_DUP); CKERR(r);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_EXCL, 0666);
assert(r == EINVAL);
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
assert(r == 0);
r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE | DB_EXCL, 0666);
assert(r == EEXIST);
r = db->close(db, 0);
assert(r == 0);
r = db->close(db, 0); CKERR(r);
return 0;
}
......@@ -7,6 +7,8 @@
#include <arpa/inet.h>
#include <db.h>
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
/* verify that the dup flags are written and read from the database file correctly */
void test_dup_flags(int dup_flags) {
printf("test_dup_flags:%d\n", dup_flags);
......@@ -271,7 +273,7 @@ void test_nonleaf_insert(int n, int dup_mode) {
int v = values[i];
DBT key, val;
r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
assert(r == 0);
CKERR(r);
}
/* verify lookups */
......
......@@ -10,16 +10,18 @@
DB_ENV *env;
DB *db;
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
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_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);
r=mkdir(DIR, 0777); assert(r==0);
r=db_env_create(&env, 0); CKERR(r);
r=env->open(env, DIR, DB_INIT_MPOOL|DB_CREATE, 0777); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
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); CKERR(r);
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
return 0;
}
......@@ -25,16 +25,30 @@ int main() {
r=env->open(env, DIR, DB_INIT_MPOOL|DB_PRIVATE|DB_CREATE|DB_INIT_LOG, 0777); assert(r==0);
r = db_create(&db, env, 0);
assert(r == 0);
CKERR(r);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666);
assert(r == 0);
CKERR(r);
r = db->close(db, 0);
assert(r == 0);
CKERR(r);
#if 0
const char * const fname2 = "test2.db";
// This sequence segfaults in BDB 4.3.29
// See what happens if we open a database with a subdb, when the file has only the main db.
r = db->open(db, null_txn, fname2, 0, DB_BTREE, DB_CREATE, 0666);
CKERR(r);
r = db->close(db,0);
CKERR(r);
r = db->open(db, null_txn, fname2, "main", DB_BTREE, 0, 0666);
CKERR(r);
r = db->close(db, 0);
CKERR(r);
#endif
r = env->close(env, 0);
assert(r == 0);
CKERR(r);
return 0;
}
......@@ -11,7 +11,10 @@ int main (int argc, char *argv[]) {
r = db_env_create(&env, 0);
assert(r == 0);
r = db_create(&db, env, 0);
// BDB doesnt' actually barf on this case.
#ifdef USE_TDB
assert(r != 0);
#endif
r = env->close(env, 0);
assert(r == 0);
return 0;
......
......@@ -20,7 +20,7 @@ static void make_db (void) {
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); CKERR(r);
r=env->open(env, DIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE, 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);
......
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