Commit ae278c10 authored by Yoni Fogel's avatar Yoni Fogel

[t:2530] Use Makefile and arguments to remove fork() from diskfull.tdbrun

git-svn-id: file:///svn/toku/tokudb@19622 c7de825b-a66e-492c-adef-691d508d4ae1
parent ef89d27b
...@@ -510,6 +510,23 @@ checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL) ...@@ -510,6 +510,23 @@ checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL)
test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \ test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
) $(MAYBEINVERTER) $(SUMMARIZE_CMD) ) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
ifeq ($(OS_CHOICE),windows)
DISKFULL_ABORTCODE=137
else
DISKFULL_ABORTCODE=134
endif
diskfull.tdbrun: SHELL=/bin/bash
diskfull.tdbrun: diskfull.tdb$(BINSUF) $(PTHREAD_LOCAL)
NUM_WRITES=$$($(VGRIND) ./$< -q) && \
(for (( i = 0; i < $$NUM_WRITES; i++ )); do \
{ ./$< -C $$i 2>/dev/null; } 2>/dev/null; \
if [ $$? -ne $(DISKFULL_ABORTCODE) ] ; then \
echo "Diskfull (iteration $$i) did not abort" ; \
exit 1; \
fi; \
done; ) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
recover_stress.tdbrun: SHELL=/bin/bash recover_stress.tdbrun: SHELL=/bin/bash
recover_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL) recover_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL)
$(VGRIND) ./$< -C -n $(STRESS_SIZE) -l $(VERBVERBOSE) && \ $(VGRIND) ./$< -C -n $(STRESS_SIZE) -l $(VERBVERBOSE) && \
......
...@@ -142,6 +142,7 @@ pwrite_counting_and_failing (int fd, const void *buf, size_t size, toku_off_t of ...@@ -142,6 +142,7 @@ pwrite_counting_and_failing (int fd, const void *buf, size_t size, toku_off_t of
{ {
write_count++; write_count++;
if (write_count>fail_at) { if (write_count>fail_at) {
if (verbose) fprintf(stderr, "Failure imminent at %d:\n", fail_at);
errno = ENOSPC; errno = ENOSPC;
return -1; return -1;
} else { } else {
...@@ -154,6 +155,7 @@ write_counting_and_failing (int fd, const void *buf, size_t size) ...@@ -154,6 +155,7 @@ write_counting_and_failing (int fd, const void *buf, size_t size)
{ {
write_count++; write_count++;
if (write_count>fail_at) { if (write_count>fail_at) {
if (verbose) fprintf(stderr, "Failure imminent at %d:\n", fail_at);
errno = ENOSPC; errno = ENOSPC;
return -1; return -1;
} else { } else {
...@@ -163,44 +165,45 @@ write_counting_and_failing (int fd, const void *buf, size_t size) ...@@ -163,44 +165,45 @@ write_counting_and_failing (int fd, const void *buf, size_t size)
static void static void
do_writes_that_fail (void) { do_writes_that_fail (void) {
if (verbose) fprintf(stderr, "About to fail at %d:\n", fail_at);
toku_set_assert_on_write_enospc(TRUE); toku_set_assert_on_write_enospc(TRUE);
db_env_set_func_pwrite(pwrite_counting_and_failing); db_env_set_func_pwrite(pwrite_counting_and_failing);
db_env_set_func_write (write_counting_and_failing); db_env_set_func_write (write_counting_and_failing);
write_count=0; write_count=0;
do_db_work(); do_db_work();
if (verbose) fprintf(stderr, "Write_count=%d\n", write_count); printf("%d\n", write_count);
}
int count = write_count;
// fail_at=83; write_count=0; do_db_work();
for (fail_at = 0; fail_at<count; fail_at++) { static void
if (verbose) fprintf(stderr, "About to fail at %d:\n", fail_at); diskfull_parse_args (int argc, char * const argv[]) {
write_count=0; int c;
pid_t child; char *argv0 = argv[0];
if ((child=fork())==0) { while ((c = getopt(argc, (char * const *)argv, "cC:vq")) != -1) {
int devnul = open(DEV_NULL_FILE, O_WRONLY); switch(c) {
assert(devnul>=0); case 'C':
{ int r = toku_dup2(devnul, fileno(stderr)); assert(r==fileno(stderr)); } fail_at = atoi(optarg);
{ int r = close(devnul); assert(r==0); } break;
do_db_work(); case 'v':
verbose++;
break;
case 'q':
verbose--;
if (verbose<0) verbose=0;
break;
default:
do_usage:
fprintf(stderr, "Usage:\n%s [-v|-q] [-C number]\n", argv0);
exit(1); exit(1);
} else {
int status;
pid_t r = waitpid(child, &status, 0);
assert(r==child);
assert(WIFSIGNALED(status));
assert(WTERMSIG(status)==SIGABRT);
} }
} }
if (argc!=optind) {
// fail_at = FAIL_NEVER; write_count=0; goto do_usage;
// do_db_work(); }
} }
int int
test_main (int argc, char * const argv[]) { test_main (int argc, char * const argv[]) {
parse_args(argc, argv); diskfull_parse_args(argc, argv);
do_writes_that_fail(); do_writes_that_fail();
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