Commit 834b1601 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs[t:2656] cilkscreen some brtloader-test-writer-errors

git-svn-id: file:///svn/toku/tokudb@20658 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1c2ace7e
...@@ -158,11 +158,11 @@ cilkscreen_brtloader-test-1: brtloader-test$(BINSUF) ...@@ -158,11 +158,11 @@ cilkscreen_brtloader-test-1: brtloader-test$(BINSUF)
cilkscreen ./$< dir.$@ $(SUMMARIZE_CMD) cilkscreen ./$< dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-extractor-1: brtloader-test-extractor$(BINSUF) cilkscreen_brtloader-test-extractor-1: brtloader-test-extractor$(BINSUF)
cilkscreen ./$< xdir.$@ $(SUMMARIZE_CMD) cilkscreen ./$< dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-extractor-2: brtloader-test-extractor$(BINSUF) cilkscreen_brtloader-test-extractor-2: brtloader-test-extractor$(BINSUF)
cilkscreen ./$< -s xdir.$@ $(SUMMARIZE_CMD) cilkscreen ./$< -s dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-extractor-3: brtloader-test-extractor$(BINSUF) cilkscreen_brtloader-test-extractor-3: brtloader-test-extractor$(BINSUF)
cilkscreen ./$< -s -r 100 --rowsets 100 xdir.$@ $(SUMMARIZE_CMD) cilkscreen ./$< -s -r 100 --rowsets 100 dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-1: brtloader-test-writer$(BINSUF) cilkscreen_brtloader-test-writer-1: brtloader-test-writer$(BINSUF)
cilkscreen ./$< -s -r 1000 dir.$@ $(SUMMARIZE_CMD) cilkscreen ./$< -s -r 1000 dir.$@ $(SUMMARIZE_CMD)
...@@ -171,6 +171,15 @@ cilkscreen_brtloader-test-writer-2: brtloader-test-writer$(BINSUF) ...@@ -171,6 +171,15 @@ cilkscreen_brtloader-test-writer-2: brtloader-test-writer$(BINSUF)
cilkscreen_brtloader-test-writer-3: brtloader-test-writer$(BINSUF) cilkscreen_brtloader-test-writer-3: brtloader-test-writer$(BINSUF)
cilkscreen ./$< -s -r 100000 dir.$@ $(SUMMARIZE_CMD) cilkscreen ./$< -s -r 100000 dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-1: brtloader-test-writer-errors$(BINSUF)
cilkscreen ./$< -v -s -r 10000 -u dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-2: brtloader-test-writer-errors$(BINSUF)
cilkscreen ./$< -v -s -r 10000 -w dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-3: brtloader-test-writer-errors$(BINSUF)
cilkscreen ./$< -v -s -r 10000 -m dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-4: brtloader-test-writer-errors$(BINSUF)
cilkscreen ./$< -v -s -r 10000 --realloc_errors dir.$@ $(SUMMARIZE_CMD)
clean: clean:
rm -rf log-test7.c.dir_* rm -rf log-test7.c.dir_*
rm -rf *.dir dir.* rm -rf *.dir dir.*
......
...@@ -13,8 +13,10 @@ ...@@ -13,8 +13,10 @@
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#if 0
}
#endif
#endif #endif
static int event_count, event_count_trigger; static int event_count, event_count_trigger;
...@@ -25,11 +27,15 @@ static void reset_event_counts(void) { ...@@ -25,11 +27,15 @@ static void reset_event_counts(void) {
static void event_hit(void) { static void event_hit(void) {
} }
static int event_add_and_fetch(void) {
return __sync_add_and_fetch(&event_count, 1);
}
static int do_user_errors = 0; static int do_user_errors = 0;
static int loader_poll_callback(void *UU(extra), float UU(progress)) { static int loader_poll_callback(void *UU(extra), float UU(progress)) {
int r; int r;
if (do_user_errors && event_count_trigger == ++event_count) { if (do_user_errors && event_count_trigger == event_add_and_fetch()) {
event_hit(); event_hit();
r = 1; r = 1;
} else { } else {
...@@ -42,7 +48,7 @@ static int do_write_errors = 0; ...@@ -42,7 +48,7 @@ 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) {
size_t r; size_t r;
if (do_write_errors && event_count_trigger == ++event_count) { if (do_write_errors && event_count_trigger == event_add_and_fetch()) {
event_hit(); event_hit();
errno = ENOSPC; errno = ENOSPC;
r = -1; r = -1;
...@@ -57,7 +63,7 @@ static size_t bad_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stre ...@@ -57,7 +63,7 @@ static size_t bad_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stre
static ssize_t bad_write(int fd, const void * bp, size_t len) { static ssize_t bad_write(int fd, const void * bp, size_t len) {
ssize_t r; ssize_t r;
if (do_write_errors && event_count_trigger == ++event_count) { if (do_write_errors && event_count_trigger == event_add_and_fetch()) {
event_hit(); event_hit();
errno = ENOSPC; errno = ENOSPC;
r = -1; r = -1;
...@@ -69,7 +75,7 @@ static ssize_t bad_write(int fd, const void * bp, size_t len) { ...@@ -69,7 +75,7 @@ static ssize_t bad_write(int fd, const void * bp, size_t len) {
static ssize_t bad_pwrite(int fd, const void * bp, size_t len, toku_off_t off) { static ssize_t bad_pwrite(int fd, const void * bp, size_t len, toku_off_t off) {
ssize_t r; ssize_t r;
if (do_write_errors && event_count_trigger == ++event_count) { if (do_write_errors && event_count_trigger == event_add_and_fetch()) {
event_hit(); event_hit();
errno = ENOSPC; errno = ENOSPC;
r = -1; r = -1;
...@@ -93,15 +99,14 @@ static void *my_malloc(size_t n) { ...@@ -93,15 +99,14 @@ static void *my_malloc(size_t n) {
void *caller = __builtin_return_address(0); void *caller = __builtin_return_address(0);
if (!((void*)toku_malloc <= caller && caller <= (void*)toku_free)) if (!((void*)toku_malloc <= caller && caller <= (void*)toku_free))
goto skip; goto skip;
my_malloc_count++; (void) __sync_fetch_and_add(&my_malloc_count, 1); // my_malloc_count++;
if (n >= my_big_malloc_limit) { if (n >= my_big_malloc_limit) {
my_big_malloc_count++; (void) __sync_fetch_and_add(&my_big_malloc_count, 1); // my_big_malloc_count++;
if (do_malloc_errors) { if (do_malloc_errors) {
caller = __builtin_return_address(1); caller = __builtin_return_address(1);
if ((void*)toku_xmalloc <= caller && caller <= (void*)toku_malloc_report) if ((void*)toku_xmalloc <= caller && caller <= (void*)toku_malloc_report)
goto skip; goto skip;
event_count++; if (event_add_and_fetch()== event_count_trigger) {
if (event_count == event_count_trigger) {
event_hit(); event_hit();
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
...@@ -118,15 +123,14 @@ static void *my_realloc(void *p, size_t n) { ...@@ -118,15 +123,14 @@ static void *my_realloc(void *p, size_t n) {
void *caller = __builtin_return_address(0); void *caller = __builtin_return_address(0);
if (!((void*)toku_realloc <= caller && caller <= (void*)toku_free)) if (!((void*)toku_realloc <= caller && caller <= (void*)toku_free))
goto skip; goto skip;
my_realloc_count++; (void) __sync_fetch_and_add(&my_realloc_count, 1); // my_realloc_count++;
if (n >= my_big_malloc_limit) { if (n >= my_big_malloc_limit) {
my_big_realloc_count++; (void) __sync_fetch_and_add(&my_big_realloc_count, 1); // my_big_realloc_count++;
if (do_realloc_errors) { if (do_realloc_errors) {
caller = __builtin_return_address(1); caller = __builtin_return_address(1);
if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_malloc_report) if ((void*)toku_xrealloc <= caller && caller <= (void*)toku_malloc_report)
goto skip; goto skip;
event_count++; if (event_add_and_fetch() == event_count_trigger) {
if (event_count == event_count_trigger) {
event_hit(); event_hit();
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
...@@ -275,6 +279,7 @@ static int usage(const char *progname, int n) { ...@@ -275,6 +279,7 @@ static int usage(const char *progname, int n) {
fprintf(stderr, "[-s] set the small loader size factor\n"); fprintf(stderr, "[-s] set the small loader size factor\n");
fprintf(stderr, "[-m] inject big malloc and realloc errors\n"); fprintf(stderr, "[-m] inject big malloc and realloc errors\n");
fprintf(stderr, "[--malloc_limit %u] set the threshold for failing malloc and realloc\n", (unsigned) my_big_malloc_limit); fprintf(stderr, "[--malloc_limit %u] set the threshold for failing malloc and realloc\n", (unsigned) my_big_malloc_limit);
fprintf(stderr, "[--realloc_errors] inject realloc errors\n");
fprintf(stderr, "[-w] inject write errors\n"); fprintf(stderr, "[-w] inject write errors\n");
fprintf(stderr, "[-u] inject user errors\n"); fprintf(stderr, "[-u] inject user errors\n");
return 1; return 1;
......
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