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

some cleanup

git-svn-id: file:///svn/tokudb@612 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9e701335
// Try to open an environment where the directory does not exist
// Try when the dir exists but is not an initialized env
#include <assert.h>
#include <db.h>
#include <errno.h>
#include <stdio.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);
int main() {
DB_ENV *dbenv;
int r;
system("rm -rf " DIR);
r = db_env_create(&dbenv, 0);
assert(r == 0);
r = dbenv->open(dbenv, DIR, DB_PRIVATE|DB_INIT_MPOOL, 0);
assert(r==ENOENT);
dbenv->close(dbenv,0); // free memory
system("rm -rf " DIR);
mkdir(DIR, 0777);
r = db_env_create(&dbenv, 0);
assert(r == 0);
r = dbenv->open(dbenv, DIR, DB_PRIVATE|DB_INIT_MPOOL, 0);
assert(r==ENOENT);
dbenv->close(dbenv,0); // free memory
return 0;
}
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include <assert.h> #include <assert.h>
#include <db.h> #include <db.h>
// DIR is defined in the Makefile
int main() { int main() {
DB_ENV *dbenv; DB_ENV *dbenv;
int r; int r;
...@@ -9,16 +11,16 @@ int main() { ...@@ -9,16 +11,16 @@ int main() {
r = db_env_create(&dbenv, 0); r = db_env_create(&dbenv, 0);
assert(r == 0); assert(r == 0);
r = dbenv->set_data_dir(dbenv, "."); r = dbenv->set_data_dir(dbenv, DIR);
assert(r == 0); assert(r == 0);
r = dbenv->set_data_dir(dbenv, "."); r = dbenv->set_data_dir(dbenv, DIR);
assert(r == 0); assert(r == 0);
r = dbenv->open(dbenv, ".", DB_PRIVATE+DB_INIT_MPOOL, 0); r = dbenv->open(dbenv, DIR, DB_PRIVATE+DB_INIT_MPOOL, 0);
assert(r == 0); assert(r == 0);
r = dbenv->set_data_dir(dbenv, "."); r = dbenv->set_data_dir(dbenv, DIR);
assert(r != 0); assert(r != 0);
r = dbenv->close(dbenv, 0); r = dbenv->close(dbenv, 0);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include <assert.h> #include <assert.h>
#include <db.h> #include <db.h>
// DIR is defined in the Makefile
int main() { int main() {
DB_ENV *dbenv; DB_ENV *dbenv;
int r; int r;
...@@ -11,7 +13,7 @@ int main() { ...@@ -11,7 +13,7 @@ int main() {
dbenv->set_errpfx(dbenv, "houdy partners: "); dbenv->set_errpfx(dbenv, "houdy partners: ");
r = dbenv->open(dbenv, ".", DB_PRIVATE+DB_INIT_MPOOL, 0); r = dbenv->open(dbenv, DIR, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0);
assert(r == 0); assert(r == 0);
r = dbenv->close(dbenv, 0); r = dbenv->close(dbenv, 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