test_env_close_flags.c 2.06 KB
Newer Older
1
/* -*- mode: C; c-basic-offset: 4 -*- */
Yoni Fogel's avatar
Yoni Fogel committed
2
#include <toku_portability.h>
3 4
#ident "Copyright (c) 2007 Tokutek Inc.  All rights reserved."

Yoni Fogel's avatar
Yoni Fogel committed
5 6
#include "test.h"

7
#include <assert.h>
8
#include <toku_portability.h>
9 10 11 12 13 14 15
#include <db.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>


16
// ENVDIR is defined in the Makefile
17

Yoni Fogel's avatar
Yoni Fogel committed
18 19
int
test_main (int argc __attribute__((__unused__)), const char *argv[]  __attribute__((__unused__))) {
20 21
    DB_ENV *env;
    int r;
22
    system("rm -rf " ENVDIR);
23
    r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);        assert(r==0);
24
    r=db_env_create(&env, 0);  assert(r==0);
25
    env->set_errfile(env,0); // Turn off those annoying errors
26
    r=env->close   (env, 0);   assert(r==0);
27
    system("rm -rf " ENVDIR);
28
    r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);        assert(r==0);
29
    r=db_env_create(&env, 0);  assert(r==0);
30
    env->set_errfile(env,0); // Turn off those annoying errors
31
    r=env->close   (env, 1);  
32
    //BDB does not check this in some versions
Rich Prohaska's avatar
Rich Prohaska committed
33
#if defined(USE_TDB) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
34 35 36 37
    assert(r==EINVAL);
#else
    assert(r==0);
#endif
38
    system("rm -rf " ENVDIR); 
39
    r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);        assert(r==0);
40 41

    r=db_env_create(&env, 0);  assert(r==0);
42
    env->set_errfile(env,0); // Turn off those annoying errors
43
    r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
44 45
    r=env->close   (env, 0);  assert(r==0);
    
46
    system("rm -rf " ENVDIR); 
47
    r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);        assert(r==0);
48 49

    r=db_env_create(&env, 0);  assert(r==0);
50
    env->set_errfile(env,0); // Turn off those annoying errors
51
    r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_PRIVATE|DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
52 53
    r=env->close   (env, 1);
    //BDB does not check this.
Rich Prohaska's avatar
Rich Prohaska committed
54
#if defined(USE_TDB) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
55 56 57 58
    assert(r==EINVAL);
#else
    assert(r==0);
#endif
59 60
    return 0;
}