mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 23:04:20 +01:00
some cleanup
git-svn-id: file:///svn/tokudb@612 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
9e70133511
commit
c45b50b97f
3 changed files with 45 additions and 5 deletions
36
src/tests/test_db_env_open_nocreate.c
Normal file
36
src/tests/test_db_env_open_nocreate.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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 @@
|
|||
#include <assert.h>
|
||||
#include <db.h>
|
||||
|
||||
// DIR is defined in the Makefile
|
||||
|
||||
int main() {
|
||||
DB_ENV *dbenv;
|
||||
int r;
|
||||
|
@ -9,16 +11,16 @@ int main() {
|
|||
r = db_env_create(&dbenv, 0);
|
||||
assert(r == 0);
|
||||
|
||||
r = dbenv->set_data_dir(dbenv, ".");
|
||||
r = dbenv->set_data_dir(dbenv, DIR);
|
||||
assert(r == 0);
|
||||
|
||||
r = dbenv->set_data_dir(dbenv, ".");
|
||||
r = dbenv->set_data_dir(dbenv, DIR);
|
||||
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);
|
||||
|
||||
r = dbenv->set_data_dir(dbenv, ".");
|
||||
r = dbenv->set_data_dir(dbenv, DIR);
|
||||
assert(r != 0);
|
||||
|
||||
r = dbenv->close(dbenv, 0);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <assert.h>
|
||||
#include <db.h>
|
||||
|
||||
// DIR is defined in the Makefile
|
||||
|
||||
int main() {
|
||||
DB_ENV *dbenv;
|
||||
int r;
|
||||
|
@ -11,7 +13,7 @@ int main() {
|
|||
|
||||
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);
|
||||
|
||||
r = dbenv->close(dbenv, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue