Commit 2a285b1d authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

[t:4015] Include 4015 test on main, even though it doesn't seem to ever see a...

[t:4015] Include 4015 test on main, even though it doesn't seem to ever see a problem.  At least it runs fast. Refs #4015

git-svn-id: file:///svn/toku/tokudb@37825 c7de825b-a66e-492c-adef-691d508d4ae1
parent 78dd2320
......@@ -253,6 +253,7 @@ BDB_DONTRUN_TESTS = \
test938c \
test_3645 \
test_3755 \
test_4015 \
test_abort1 \
test_abort4 \
test_abort5 \
......@@ -267,7 +268,7 @@ BDB_DONTRUN_TESTS = \
test_dupsort_set_range_reverse \
test_large_update_broadcast_small_cachetable \
test_logflush \
test_query \
test_query \
test_redirect_func \
test_stress1 \
test_stress2 \
......@@ -433,6 +434,7 @@ EXTRA_TDB_TESTS = \
$(patsubst %,test_log%.recover,$(TLRECOVER)) \
test_groupcommit_count_hgrind.tdbrun \
test_groupcommit_count_vgrind.tdbrun \
test_4015.drdrun \
#\ ends prev line
ifeq ($(OS_CHOICE),windows)
......@@ -995,6 +997,9 @@ large_%.drdrun: %.tdb
$(VALGRIND) --tool=drd --quiet --suppressions=drd.suppressions --error-exitcode=1 ./$< $(VERBVERBOSE) --only_stress --num_seconds 1000 --envdir dir.$@ \
$(MAYBEINVERTER) $(SUMMARIZE_CMD)
test_4015.drdrun: test_4015.tdb
$(VALGRIND) --tool=drd --quiet --suppressions=drd.suppressions --error-exitcode=1 ./$< --envdir dir.tdb.$@
# upgrade tests
UPGRADE_TEST_SRCS = $(wildcard upgrade-test-*.c)
UPGRADE_TESTS = $(patsubst %.c,%,$(UPGRADE_TEST_SRCS))
......
......@@ -4,9 +4,118 @@
#include "test.h"
#include "toku_pthread.h"
static int my_compare (DB *db, const DBT *a, const DBT *b) {
assert(db);
assert(db->descriptor);
assert(db->descriptor->dbt.size >= 3);
char *data = db->descriptor->dbt.data;
assert(data[0]=='f');
assert(data[1]=='o');
assert(data[2]=='o');
if (verbose) printf("compare descriptor=%s\n", data);
usleep(1000);
return uint_dbt_cmp(db, a, b);
}
DB_ENV *env;
DB *db;
char *env_dir = ENVDIR;
static void *startA (void *ignore __attribute__((__unused__))) {
for (int i=0;i<3; i++) {
DBT k,v;
int a=1;
dbt_init(&k, &a, sizeof(a));
dbt_init(&v, &a, sizeof(a));
IN_TXN_COMMIT(env, NULL, txn, 0,
CHK(db->put(db, txn, &k, &v, 0)));
}
return NULL;
}
static void change_descriptor (DB_TXN *txn, int i) {
DBT desc;
char foo[100];
snprintf(foo, 99, "foo%d", i);
dbt_init(&desc, foo, 1+strlen(foo));
int r;
if (verbose) printf("trying to change to %s\n", foo);
while ((r=db->change_descriptor(db, txn, &desc, 0))) {
if (verbose) printf("Change failed r=%d, try again\n", r);
}
if (verbose) printf("ok\n");
}
static void startB (void) {
for (int i=0; i<10; i++) {
IN_TXN_COMMIT(env, NULL, txn, 0,
change_descriptor(txn, i));
}
}
static void my_parse_args (int argc, char * const argv[]) {
const char *argv0=argv[0];
while (argc>1) {
int resultcode=0;
if (strcmp(argv[1], "-v")==0) {
verbose++;
} else if (strcmp(argv[1],"-q")==0) {
verbose--;
if (verbose<0) verbose=0;
} else if (strcmp(argv[1],"--envdir")==0) {
assert(argc>2);
env_dir = argv[2];
argc--;
argv++;
} else if (strcmp(argv[1], "-h")==0) {
do_usage:
fprintf(stderr, "Usage:\n%s [-v|-q] [-h] [--envdir <envdir>]\n", argv0);
exit(resultcode);
} else {
resultcode=1;
goto do_usage;
}
argc--;
argv++;
}
}
int test_main(int argc, char * const argv[]) {
parse_args(argc, argv);
my_parse_args(argc, argv);
CHK(db_env_create(&env, 0));
CHK(env->set_redzone(env, 0));
CHK(env->set_default_bt_compare(env, my_compare));
{
const int size = 10+strlen(env_dir);
char cmd[size];
snprintf(cmd, size, "rm -rf %s", env_dir);
system(cmd);
}
CHK(toku_os_mkdir(env_dir, S_IRWXU+S_IRWXG+S_IRWXO));
const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE;
CHK(env->open(env, env_dir, envflags, S_IRWXU+S_IRWXG+S_IRWXO));
CHK(db_create(&db, env, 0));
CHK(db->open(db, NULL, "db", NULL, DB_BTREE, DB_CREATE, 0666));
DBT desc;
dbt_init(&desc, "foo", sizeof("foo"));
IN_TXN_COMMIT(env, NULL, txn, 0,
CHK(db->change_descriptor(db, txn, &desc, 0)));
pthread_t thd;
CHK(toku_pthread_create(&thd, NULL, startA, NULL));
startB();
void *retval;
CHK(toku_pthread_join(thd, &retval));
assert(retval==NULL);
CHK(db->close(db, 0));
CHK(env->close(env, 0));
return 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