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

Improve teh bugs

git-svn-id: file:///svn/tokudb@613 c7de825b-a66e-492c-adef-691d508d4ae1
parent c45b50b9
......@@ -48,15 +48,21 @@ $(ALL_TESTS):
echo $@
%.bdbrun: %.bdb
./$<
$(VGRIND) ./$<
%.tdbrun: %.tdb
$(VGRIND) ./$<
# For a few of the tests bdb is making valgrind unhappy.
test_db_already_exists.bdbrun: VGRIND=
test_db_dup.bdbrun: VGRIND=
test_reverse_compare_fun.bdbrun: VGRIND=
test_db_subdb.bdbrun: VGRIND=
test_db_env_open_open_close.bdbrun: VGRIND=
%.bdb: %.c
cc -DDIR=\"dir.$<.bdb\" $(CFLAGS) $< -ldb -o $@
cc -DDIR=\"dir.$<.bdb\" -DUSE_BDB $(CFLAGS) $< -ldb -o $@
%.tdb: %.c
cc -DDIR=\"dir.$<.tdb\" $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
cc -DDIR=\"dir.$<.tdb\" -DUSE_TDB $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
make_libs:
cd ..;make
......
......@@ -41,7 +41,5 @@ int main() {
r = db->close(db, 0);
assert(r == 0);
r=chdir(".."); assert(r==0);
return 0;
}
......@@ -23,7 +23,13 @@ int main() {
assert(r == 0);
r = dbenv->open(dbenv, DIR, DB_INIT_MPOOL|DB_PRIVATE, 0666);
#if defined(USE_TDB)
assert(r != 0);
#elif defined(USE_BDB)
assert(r == 0);
#else
#error huh?
#endif
r = dbenv->close(dbenv, 0);
assert(r == 0);
......
#include <stdio.h>
#include <assert.h>
#include <db.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#define CKERR(r) if (r!=0) fprintf(stderr, "%s:%d error %d %s\n", __FILE__, __LINE__, r, db_strerror(r)); assert(r==0);
// DIR is defined in the Makefile
......@@ -8,6 +13,9 @@ int main() {
DB_ENV *dbenv;
int r;
system("rm -rf " DIR);
mkdir(DIR, 0777);
r = db_env_create(&dbenv, 0);
assert(r == 0);
......@@ -17,11 +25,15 @@ int main() {
r = dbenv->set_data_dir(dbenv, DIR);
assert(r == 0);
r = dbenv->open(dbenv, DIR, DB_PRIVATE+DB_INIT_MPOOL, 0);
assert(r == 0);
r = dbenv->open(dbenv, DIR, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0);
CKERR(r);
r = dbenv->set_data_dir(dbenv, DIR);
#ifdef USE_TDB
// According to the BDB man page, you may not call set_data_dir after doing the open.
// Some versions of BDB don't actually check this or complain
r = dbenv->set_data_dir(dbenv, "foo" DIR);
assert(r != 0);
#endif
r = dbenv->close(dbenv, 0);
assert(r == 0);
......
......@@ -15,11 +15,14 @@ int main (int argc, char *argv[]) {
r=system("rm -rf " DIR); assert(r==0);
r=mkdir(DIR, 0777); assert(r==0);
r=db_env_create(&env, 0); assert(r==0);
// None of this stuff works with BDB. TDB does more error checking.
#ifdef USE_TDB
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);
#endif
r=env->close(env, 0); assert(r==0);
return 0;
}
......
......@@ -33,5 +33,8 @@ int main() {
r = db->close(db, 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