Commit 6088dfa4 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

test_errpfx was setting two data dirs. exceptions is broken out to its worn...

test_errpfx was setting two data dirs.  exceptions is broken out to its worn rule (and is failing because of #2284).  exceptions was also operating in the cwd, instead of a subdir.  The reverse_compare_fun was failing because it wasing cwd for some calls instead of the subdir. Refs #2285, #2284.  [t:2285] [t:2284]

git-svn-id: file:///svn/toku/tokudb@16835 c7de825b-a66e-492c-adef-691d508d4ae1
parent cd9c8900
...@@ -120,15 +120,18 @@ check: $(TARGETS) \ ...@@ -120,15 +120,18 @@ check: $(TARGETS) \
check_db_create_DSM \ check_db_create_DSM \
check_db_create_1 check_db_create_2 check_db_create_3 check_db_create_4 \ check_db_create_1 check_db_create_2 check_db_create_3 check_db_create_4 \
check_permissions \ check_permissions \
check_exceptions \
check_a_bunch check_a_bunch
check_a_bunch: check_a_bunch:
$(VGRIND) ./exceptions $(SUMMARIZE_CMD)
$(VGRIND) ./test_no_env $(SUMMARIZE_CMD) $(VGRIND) ./test_no_env $(SUMMARIZE_CMD)
$(VGRIND) ./test_fd $(SUMMARIZE_CMD) $(VGRIND) ./test_fd $(SUMMARIZE_CMD)
$(VGRIND) ./test_db_delete $(SUMMARIZE_CMD) $(VGRIND) ./test_db_delete $(SUMMARIZE_CMD)
$(VGRIND) ./test_get_not_found $(SUMMARIZE_CMD) $(VGRIND) ./test_get_not_found $(SUMMARIZE_CMD)
check_exceptions:
$(VGRIND) ./exceptions $(SUMMARIZE_CMD)
check_db_create: db_create check_db_create: db_create
rm -rf $@.tdb rm -rf $@.tdb
$(VGRIND) ./db_create -s main $@.tdb $(SUMMARIZE_CMD) $(VGRIND) ./db_create -s main $@.tdb $(SUMMARIZE_CMD)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define DB_KEYEMPTY DB_NOTFOUND #define DB_KEYEMPTY DB_NOTFOUND
#endif #endif
#define DIR __FILE__ ".dir"
int verbose = 0; int verbose = 0;
#define TC(expr, expect) \ #define TC(expr, expect) \
...@@ -41,54 +42,67 @@ int verbose = 0; ...@@ -41,54 +42,67 @@ int verbose = 0;
static void test_env_exceptions (void) { static void test_env_exceptions (void) {
{ {
DbEnv env(0); DbEnv env(0);
TC(env.open("no.such.dir", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0777), ENOENT); TC(env.open(DIR "no.such.dir", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0777), ENOENT);
} }
{ {
DbEnv env(0); DbEnv env(0);
TC(env.open("no.such.dir", -1, 0777), EINVAL); TC(env.open(DIR "no.such.dir", -1, 0777), EINVAL);
} }
{ {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0777), 0); TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE, 0777), 0);
DbTxn *txn; DbTxn *txn;
TC(env.txn_begin(0, &txn, 0), EINVAL); // not configured for transactions TC(env.txn_begin(0, &txn, 0), EINVAL); // not configured for transactions
} }
{ {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG, 0777), 0); TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG, 0777), EINVAL); // cannot do logging without txns
DbTxn *txn;
TC(env.txn_begin(0, &txn, 0), EINVAL); // not configured for transactions
} }
{ {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_TXN, 0777), 0); TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_TXN, 0777), 0);
DbTxn *txn; DbTxn *txn;
TC(env.txn_begin(0, &txn, 0), 0); TC(env.txn_begin(0, &txn, 0), 0);
TC(txn->commit(0), 0); TC(txn->commit(0), 0);
delete txn; delete txn;
} }
{ {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_LOCK | DB_INIT_TXN, 0777), 0); env.set_errfile(stderr);
TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_LOCK | DB_INIT_TXN, 0777), 0);
DbTxn *txn; DbTxn *txn;
TC(env.txn_begin(0, &txn, 0), 0); TC(env.txn_begin(0, &txn, 0), 0);
TC(txn->commit(0), 0); TC(txn->commit(0), 0);
delete txn; delete txn;
} }
{ {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_TXN, 0777), 0); TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_TXN, 0777), 0);
DbTxn *txn; DbTxn *txn;
TC(env.txn_begin(0, &txn, 0), 0); TC(env.txn_begin(0, &txn, 0), 0);
TC(txn->commit(-1), EINVAL); TC(txn->commit(-1), EINVAL);
delete txn; delete txn;
} }
system("rm -rf " DIR);
} }
static void test_db_exceptions (void) { static void test_db_exceptions (void) {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE , 0777), 0); TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE , 0777), 0);
env.set_errfile(stderr);
TC( ({ Db db(&env, -1); assert(0); }), EINVAL); // Create with flags=-1 should do an EINVAL TC( ({ Db db(&env, -1); assert(0); }), EINVAL); // Create with flags=-1 should do an EINVAL
Db db(&env, 0); Db db(&env, 0);
DB *dbdb=db.get_DB(); DB *dbdb=db.get_DB();
...@@ -152,8 +166,10 @@ static void test_db_exceptions (void) { ...@@ -152,8 +166,10 @@ static void test_db_exceptions (void) {
static void test_dbc_exceptions () { static void test_dbc_exceptions () {
system("rm -rf " DIR);
toku_os_mkdir(DIR, 0777);
DbEnv env(0); DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE , 0777), 0); TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE , 0777), 0);
Db db(&env, 0); Db db(&env, 0);
unlink(FNAME); unlink(FNAME);
TC(db.open(0, FNAME, 0, DB_BTREE, DB_CREATE, 0777), 0); TC(db.open(0, FNAME, 0, DB_BTREE, DB_CREATE, 0777), 0);
...@@ -187,6 +203,6 @@ int main(int argc, char *argv[]) { ...@@ -187,6 +203,6 @@ int main(int argc, char *argv[]) {
test_env_exceptions(); test_env_exceptions();
test_db_exceptions(); test_db_exceptions();
test_dbc_exceptions(); test_dbc_exceptions();
system("rm *.tokulog"); system("rm -rf " DIR);
return 0; return 0;
} }
...@@ -10,7 +10,6 @@ void test_db_env(void) { ...@@ -10,7 +10,6 @@ void test_db_env(void) {
DbEnv dbenv(DB_CXX_NO_EXCEPTIONS); DbEnv dbenv(DB_CXX_NO_EXCEPTIONS);
int r; int r;
r = dbenv.set_data_dir("."); assert(r == 0);
r = dbenv.set_data_dir(".."); assert(r == 0); r = dbenv.set_data_dir(".."); assert(r == 0);
r = dbenv.set_data_dir(NULL); assert(r == EINVAL); r = dbenv.set_data_dir(NULL); assert(r == EINVAL);
dbenv.set_errpfx("Prefix"); dbenv.set_errpfx("Prefix");
......
...@@ -58,7 +58,7 @@ void test_reverse_compare(int n, int dup_flags) { ...@@ -58,7 +58,7 @@ void test_reverse_compare(int n, int dup_flags) {
Db *db; Db *db;
DbTxn * const null_txn = 0; DbTxn * const null_txn = 0;
const char * const fname = DIR "/reverse.compare.db"; const char * const fname = "reverse.compare.db";
int r; int r;
int i; int i;
...@@ -68,7 +68,7 @@ void test_reverse_compare(int n, int dup_flags) { ...@@ -68,7 +68,7 @@ void test_reverse_compare(int n, int dup_flags) {
/* create the dup database file */ /* create the dup database file */
DbEnv env(DB_CXX_NO_EXCEPTIONS); DbEnv env(DB_CXX_NO_EXCEPTIONS);
r = env.open(".", DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0); r = env.open(DIR, DB_INIT_MPOOL + DB_CREATE + DB_PRIVATE, 0777); assert(r == 0);
db = new Db(&env, DB_CXX_NO_EXCEPTIONS); db = new Db(&env, DB_CXX_NO_EXCEPTIONS);
assert(db); assert(db);
r = db->set_flags(dup_flags); r = db->set_flags(dup_flags);
......
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