Commit dff1261f authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs[t:2603] inject errors from the poll callback into the extractor

git-svn-id: file:///svn/toku/tokudb@20424 c7de825b-a66e-492c-adef-691d508d4ae1
parent 99f264cc
...@@ -92,19 +92,19 @@ check_test-assert$(BINSUF): test-assert$(BINSUF) $(PTHREAD_LOCAL) ...@@ -92,19 +92,19 @@ check_test-assert$(BINSUF): test-assert$(BINSUF) $(PTHREAD_LOCAL)
@# one argument, "ok" should not error @# one argument, "ok" should not error
$(VGRIND) ./$< ok $(SUMMARIZE_CMD) $(VGRIND) ./$< ok $(SUMMARIZE_CMD)
check_brtloader-test-merge-files-dbufio: EXTRA_ARGS=dir.brtloader-test-merge-files-dbufio check_brtloader-test-merge-files-dbufio: EXTRA_ARGS=dir.$@
check_brtloader-test$(BINSUF): EXTRA_ARGS=dir.brtloader-test check_brtloader-test$(BINSUF): EXTRA_ARGS=dir.$@
check_brtloader-test-bad-generate$(BINSUF): EXTRA_ARGS=dir.brtloader-test-bad-generate check_brtloader-test-bad-generate$(BINSUF): EXTRA_ARGS=dir.$@
check_brtloader-test-extractor-errors$(BINSUF): EXTRA_ARGS=-s -f -m -r 1 dir.brtloader-test-extractor-errors check_brtloader-test-extractor-errors$(BINSUF): EXTRA_ARGS=-f -m -u -r 1 dir.$@
check_brtloader-test-open$(BINSUF): EXTRA_ARGS=dir.brtloader-test-open check_brtloader-test-open$(BINSUF): EXTRA_ARGS=dir_$@
check_brtloader-test-writer$(BINSUF): EXTRA_ARGS=-r 1000000 dir.brtloader-test-writer check_brtloader-test-writer$(BINSUF): EXTRA_ARGS=-r 1000000 dir.$@
check_brtloader-test-writer-errors$(BINSUF): EXTRA_ARGS=-s -f -m -u -r 10000 dir.brtloader-test-writer-errors check_brtloader-test-writer-errors$(BINSUF): EXTRA_ARGS=-f -m -u -r 1000000 dir.$@
brtloader-%$(BINSUF): brtloader-%.$(OEXT) brtloader-%$(BINSUF): brtloader-%.$(OEXT)
ifeq ($(BRTLOADER),cilk) ifeq ($(BRTLOADER),cilk)
......
...@@ -25,6 +25,19 @@ static void reset_event_counts(void) { ...@@ -25,6 +25,19 @@ static void reset_event_counts(void) {
static void event_hit(void) { static void event_hit(void) {
} }
static int do_user_errors = 0;
static int loader_poll_callback(void *UU(extra), float UU(progress)) {
int r;
if (do_user_errors && event_count_trigger == ++event_count) {
event_hit();
r = 1;
} else {
r = 0;
}
return r;
}
static int do_write_errors = 0; static int do_write_errors = 0;
static size_t bad_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream) { static size_t bad_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream) {
...@@ -192,12 +205,14 @@ static void test_extractor(int nrows, int nrowsets, BOOL expect_fail) { ...@@ -192,12 +205,14 @@ static void test_extractor(int nrows, int nrowsets, BOOL expect_fail) {
populate_rowset(rowset[i], i, nrows); populate_rowset(rowset[i], i, nrows);
} }
// setup error injection // setup error injection
toku_set_func_malloc(my_malloc); toku_set_func_malloc(my_malloc);
toku_set_func_realloc(my_realloc); toku_set_func_realloc(my_realloc);
brtloader_set_os_fwrite(bad_fwrite); brtloader_set_os_fwrite(bad_fwrite);
toku_set_func_write(bad_write); toku_set_func_write(bad_write);
toku_set_func_pwrite(bad_pwrite); toku_set_func_pwrite(bad_pwrite);
brt_loader_set_poll_function(&loader->poll_callback, loader_poll_callback, NULL);
// feed rowsets to the extractor // feed rowsets to the extractor
for (int i = 0; i < nrowsets; i++) { for (int i = 0; i < nrowsets; i++) {
...@@ -267,6 +282,8 @@ int test_main (int argc, const char *argv[]) { ...@@ -267,6 +282,8 @@ int test_main (int argc, const char *argv[]) {
do_write_errors = 1; do_write_errors = 1;
} else if (strcmp(argv[0],"-m") == 0) { } else if (strcmp(argv[0],"-m") == 0) {
do_malloc_errors = 1; do_malloc_errors = 1;
} else if (strcmp(argv[0],"-u") == 0) {
do_user_errors = 1;
} else if (strcmp(argv[0],"--max_error_limit") == 0 && argc >= 1) { } else if (strcmp(argv[0],"--max_error_limit") == 0 && argc >= 1) {
argc--; argv++; argc--; argv++;
max_error_limit = atoi(argv[0]); max_error_limit = atoi(argv[0]);
......
...@@ -169,25 +169,31 @@ static void test_write_dbfile (char *template, int n, char *output_name) { ...@@ -169,25 +169,31 @@ static void test_write_dbfile (char *template, int n, char *output_name) {
brt_loader_destroy_error_callback(&bl.error_callback); brt_loader_destroy_error_callback(&bl.error_callback);
} }
static int nrows = 1;
static int usage(const char *progname) {
fprintf(stderr, "Usage:\n %s [-h] [-v] [-q] [-r %d] [-s] directory\n", progname, nrows);
return 1;
}
int test_main (int argc, const char *argv[]) { int test_main (int argc, const char *argv[]) {
const char *progname=argv[0]; const char *progname=argv[0];
int n = 1;
argc--; argv++; argc--; argv++;
while (argc>0) { while (argc>0) {
if (strcmp(argv[0],"-v")==0) { if (strcmp(argv[0],"-h")==0) {
return usage(progname);
} else if (strcmp(argv[0],"-v")==0) {
verbose=1; verbose=1;
} else if (strcmp(argv[0],"-q")==0) { } else if (strcmp(argv[0],"-q")==0) {
verbose=0; verbose=0;
} else if (strcmp(argv[0],"-r") == 0) { } else if (strcmp(argv[0],"-r") == 0) {
argc--; argv++; argc--; argv++;
n = atoi(argv[0]); nrows = atoi(argv[0]);
} else if (strcmp(argv[0],"-s") == 0) { } else if (strcmp(argv[0],"-s") == 0) {
toku_brtloader_set_size_factor(1); toku_brtloader_set_size_factor(1);
} else if (argc!=1) { } else if (argc!=1) {
fprintf(stderr, "Usage:\n %s [-v] [-q] [-r %d] [-s] directory\n", progname, n); return usage(progname);
exit(1); } else {
}
else {
break; break;
} }
argc--; argv++; argc--; argv++;
...@@ -211,8 +217,7 @@ int test_main (int argc, const char *argv[]) { ...@@ -211,8 +217,7 @@ int test_main (int argc, const char *argv[]) {
int olen = snprintf(output_name, templen, "%s/test.tokudb", directory); int olen = snprintf(output_name, templen, "%s/test.tokudb", directory);
assert (olen>0 && olen<templen); assert (olen>0 && olen<templen);
test_write_dbfile(template, n, output_name); test_write_dbfile(template, nrows, output_name);
return 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