Commit 2185eda8 authored by Yoni Fogel's avatar Yoni Fogel

refs #5902 Add hooks for testing 5902 upgrade and dump-env test

git-svn-id: file:///svn/toku/tokudb@52171 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7cbb89fa
......@@ -365,6 +365,7 @@ static void print_db_env_struct (void) {
"int (*txn_xa_recover) (DB_ENV*, TOKU_XA_XID list[/*count*/], long count, /*out*/ long *retp, uint32_t flags)",
"int (*get_txn_from_xid) (DB_ENV*, /*in*/ TOKU_XA_XID *, /*out*/ DB_TXN **)",
"int (*get_cursor_for_directory) (DB_ENV*, /*in*/ DB_TXN *, /*out*/ DBC **)",
"int (*get_cursor_for_persistent_environment) (DB_ENV*, /*in*/ DB_TXN *, /*out*/ DBC **)",
NULL};
sort_and_dump_fields("db_env", true, extra);
......
......@@ -513,6 +513,8 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
endif ()
endforeach(src)
configure_file(run_with_env.sh . COPYONLY)
## for some reason this rule doesn't run with the makefile and it crashes with this rule, so I'm disabling this special case
#declare_custom_tests(test_thread_stack.tdb)
#add_custom_command(OUTPUT run_test_thread_stack.sh
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id: cursor-more-than-a-leaf-provdel.cc 49851 2012-11-12 00:43:22Z esmet $"
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include "test.h"
#include <db.h>
#include <sys/stat.h>
static DB_ENV *env;
static DB *db;
DB_TXN *txn;
const int num_insert = 25000;
static void
setup (void) {
int r;
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
if (r != 0) {
CKERR2(errno, EEXIST);
}
r=db_env_create(&env, 0); CKERR(r);
#ifdef TOKUDB
r=env->set_redzone(env, 0); CKERR(r);
r=env->set_default_bt_compare(env, int_dbt_cmp); CKERR(r);
#endif
env->set_errfile(env, stderr);
#ifdef USE_BDB
r=env->set_lk_max_objects(env, 2*num_insert); CKERR(r);
#endif
r=env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_create(&db, env, 0); CKERR(r);
r=env->txn_begin(env, 0, &txn, 0); assert(r==0);
#ifdef USE_BDB
r=db->set_bt_compare(db, int_dbt_cmp); CKERR(r);
#endif
r=db->open(db, txn, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=txn->commit(txn, 0); assert(r==0);
}
static void
test_shutdown (void) {
int r;
r= db->close(db, 0); CKERR(r);
r= env->close(env, 0); CKERR(r);
}
static void
doit(void) {
int r;
DBC *dbc;
r=env->txn_begin(env, 0, &txn, 0); CKERR(r);
r = env->get_cursor_for_persistent_environment(env, txn, &dbc); CKERR(r);
DBT key;
DBT val;
dbt_init_realloc(&key);
dbt_init_realloc(&val);
while ((r = dbc->c_get(dbc, &key, &val, DB_NEXT)) == 0) {
if (verbose) {
printf("ENTRY\n\tKEY [%.*s]",
key.size,
(char*)key.data);
if (val.size == sizeof(uint32_t)) {
//assume integer
printf("\n\tVAL [%" PRIu32"]\n",
toku_dtoh32(*(uint32_t*)val.data));
} else if (val.size == sizeof(uint64_t)) {
//assume 64 bit integer
printf("\n\tVAL [%" PRIu64"]\n",
toku_dtoh64(*(uint64_t*)val.data));
} else {
printf("\n\tVAL [%.*s]\n",
val.size,
(char*)val.data);
}
}
}
CKERR2(r, DB_NOTFOUND);
r = dbc->c_close(dbc);
CKERR(r);
r = txn->commit(txn, 0);
CKERR(r);
toku_free(key.data);
toku_free(val.data);
}
int
test_main (int argc, char * const argv[]) {
parse_args(argc, argv);
setup();
doit();
test_shutdown();
return 0;
}
#!/usr/bin/env bash
if [[ $# -lt 3 ]]; then exit 1; fi
bin=$1; shift
saveddir=$1; shift
envdir=$1; shift
rm -rf $envdir
cp -r $saveddir $envdir
$bin "$@"
......@@ -2084,6 +2084,14 @@ env_crash(DB_ENV * UU(db_env), const char* msg, const char * fun, const char* fi
return -1; // placate compiler
}
static int
env_get_cursor_for_persistent_environment(DB_ENV* env, DB_TXN* txn, DBC** c) {
if (!env_opened(env)) {
return EINVAL;
}
return toku_db_cursor(env->i->persistent_environment, txn, c, 0);
}
static int
env_get_cursor_for_directory(DB_ENV* env, DB_TXN* txn, DBC** c) {
if (!env_opened(env)) {
......@@ -2159,6 +2167,7 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) {
USENV(log_flush);
USENV(log_archive);
USENV(create_loader);
USENV(get_cursor_for_persistent_environment);
USENV(get_cursor_for_directory);
#undef USENV
......
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