Commit 33326aba authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Separate test_get_both_range into many smaller pieces. Addresses #475.

git-svn-id: file:///svn/tokudb@3853 c7de825b-a66e-492c-adef-691d508d4ae1
parent 53b6dd9b
......@@ -120,7 +120,7 @@ endif
$(MAYBEATSIGN) $(UNSETTOKUENV) ./$< $(VERBVERBOSE)
%.tdbrun: %.tdb ../libtokudb.$(LIBEXT)
$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTERR)
@ touch $@
# Any test that should fail, we invert the result by using MAYBEINVERTERR
$(patsubst %,%.tdbrun,$(TDB_TESTS_THAT_SHOULD_FAIL)): MAYBEINVERTERR=;test $$? -ne 0
......@@ -198,6 +198,27 @@ test_db_assoc3.bdbrun: test_db_assoc3.bdb
$(MAYBEATSIGN) $(UNSETTOKUENV) ./test_db_assoc3.bdb --seed=2 --count=100000 $(VERBVERBOSE)
$(MAYBEATSIGN) $(UNSETTOKUENV) ./test_db_assoc3.bdb --seed=2 --count=100000 --more $(VERBVERBOSE)
# a bunch of little tests designed to run in parallel
test_get_both_range.tdbrun: \
tgbr_256_a.tdbrun tgbr_256_b.tdbrun tgbr_256_c.tdbrun \
tgbr_128_a.tdbrun tgbr_128_b.tdbrun tgbr_128_c.tdbrun \
tgbr_64_a.tdbrun tgbr_64_b.tdbrun tgbr_64_c.tdbrun \
tgbr_32_a.tdbrun tgbr_32_b.tdbrun tgbr_32_c.tdbrun \
tgbr_16_a.tdbrun tgbr_16_b.tdbrun tgbr_16_c.tdbrun \
tgbr_8_a.tdbrun tgbr_8_b.tdbrun tgbr_8_c.tdbrun \
tgbr_4_a.tdbrun tgbr_4_b.tdbrun tgbr_4_c.tdbrun \
tgbr_2_a.tdbrun tgbr_2_b.tdbrun tgbr_2_c.tdbrun \
tgbr_1_a.tdbrun tgbr_1_b.tdbrun tgbr_1_c.tdbrun \
# intentionally blank line
echo Did $@
tgbr_%_a.tdbrun: test_get_both_range.tdb
$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE) -i $(patsubst tgbr_%_a.tdbrun,%,$@) -a $(MAYBEINVERTERR)
tgbr_%_b.tdbrun: test_get_both_range.tdb
$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE) -i $(patsubst tgbr_%_b.tdbrun,%,$@) -b $(MAYBEINVERTERR)
tgbr_%_c.tdbrun: test_get_both_range.tdb
$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE) -i $(patsubst tgbr_%_c.tdbrun,%,$@) -c $(MAYBEINVERTERR)
dumpit:
../../newbrt/brtdump dir.test_log5.c.tdb.recover/foo.db > dump.r && ../../newbrt/brtdump dir.test_log5.c.tdb/foo.db > dump.o && diff dump.o dump.r
......
......@@ -98,13 +98,16 @@ void expect_cursor_get_current(DBC *cursor, int k, int v) {
free(key.data); free(val.data);
}
char annotated_envdir[]= ENVDIR " ";
void test_get_both(int n, int dup_mode, int op) {
if (verbose) printf("test_get_both_range:%d %d %d\n", n, dup_mode, op);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
char fname[sizeof(ENVDIR)+100];
snprintf(fname, sizeof(fname), "%s/test_icdi_search_brt", annotated_envdir);
int r;
unlink(fname);
......@@ -169,22 +172,83 @@ void test_get_both(int n, int dup_mode, int op) {
int main(int argc, const char *argv[]) {
unsigned long doi=0;
int i;
char flags = 0;
for (i=1; i<argc; i++) {
const char *arg = argv[i];
if (0 == strcmp(arg, "-v")) {
verbose++;
continue;
}
} else if (0 == strcmp(arg, "-q")) {
verbose--;
if (verbose<0) verbose=0;
} else if (0==strcmp(arg, "-i")) {
i++; assert(i<argc);
char *end;
doi = strtoul(argv[i], &end, 10);
assert(doi!=LONG_MAX);
assert(end!=argv[i]);
assert(*end==0);
} else if (0==strcmp(arg, "-a")) {
flags = 'a';
} else if (0==strcmp(arg, "-b")) {
flags = 'b';
} else if (0==strcmp(arg, "-c")) {
flags = 'c';
} else {
fprintf(stderr, "Usage: %s [-v] [-a|-b|-c] [-i I]\n", argv[0]);
exit(1);
}
}
system("rm -rf " ENVDIR);
mkdir(ENVDIR, 0777);
for (i=1; i <= 256; i *= 2) {
test_get_both(i, 0, DB_GET_BOTH);
test_get_both(i, 0, DB_GET_BOTH_RANGE);
test_get_both(i, DB_DUP + DB_DUPSORT, DB_GET_BOTH_RANGE);
{
char envdir_without_suffix[sizeof(ENVDIR)] = ENVDIR;
assert(sizeof(ENVDIR)>4);
//printf("envdir=%s\n(size=%ld) -5 char=%c\n", ENVDIR, sizeof(ENVDIR), envdir_without_suffix[sizeof(ENVDIR)-5]);
assert(envdir_without_suffix[sizeof(ENVDIR)-5]=='.');
assert(envdir_without_suffix[sizeof(ENVDIR)-4]=='t' || envdir_without_suffix[sizeof(ENVDIR)-4]=='b');
assert(envdir_without_suffix[sizeof(ENVDIR)-3]=='d');
assert(envdir_without_suffix[sizeof(ENVDIR)-2]=='b');
assert(envdir_without_suffix[sizeof(ENVDIR)-1]==0);
envdir_without_suffix[sizeof(ENVDIR)-5]=0;
char doi_string[10];
if (doi==0) doi_string[0]=0;
else snprintf(doi_string, sizeof(doi_string), ".%lu", doi);
char flags_string[10];
switch (flags) {
case 0: flags_string[0]=0; break;
case 'a': case 'b': case 'c': snprintf(flags_string, sizeof(flags_string), ".%c", flags); break;
default: assert(0);
}
#ifdef USE_TDB
char bdb_tdb_char='t';
#else
char bdb_tdb_char='b';
#endif
snprintf(annotated_envdir, sizeof(annotated_envdir), "%s%s%s.%cdb",
envdir_without_suffix, doi_string, flags_string, bdb_tdb_char);
}
{
char rmcmd[sizeof(annotated_envdir)+10];
snprintf(rmcmd, sizeof(rmcmd), "rm -rf %s", annotated_envdir);
system(rmcmd);
}
mkdir(annotated_envdir, 0777);
if (doi==0) {
for (i=1; i <= 256; i *= 2) {
if (flags==0 || flags=='a') test_get_both(i, 0, DB_GET_BOTH);
if (flags==0 || flags=='b') test_get_both(i, 0, DB_GET_BOTH_RANGE);
if (flags==0 || flags=='c') test_get_both(i, DB_DUP + DB_DUPSORT, DB_GET_BOTH_RANGE);
}
} else {
if (flags==0 || flags=='a') test_get_both(doi, 0, DB_GET_BOTH);
if (flags==0 || flags=='b') test_get_both(doi, 0, DB_GET_BOTH_RANGE);
if (flags==0 || flags=='c') test_get_both(doi, DB_DUP + DB_DUPSORT, DB_GET_BOTH_RANGE);
}
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