diff --git a/src/compat/process.c b/src/compat/process.c index c2d7f47..8a4ed82 100644 --- a/src/compat/process.c +++ b/src/compat/process.c @@ -183,18 +183,20 @@ int resume_child(void) { 0, MAPPING_SIZE); - if (ctx == NULL) + if (ctx == NULL) { + CloseHandle(sharedMem); exit(-1); + } local_ctx = *ctx; struct test_single_param *param = NULL; if (local_ctx.param.size != 0) { - param = malloc(sizeof (struct test_single_param) + local_ctx.param->size); + param = malloc(sizeof (struct test_single_param) + local_ctx.param.size); *param = (struct test_single_param) { - .size = local_ctx.param->size, + .size = local_ctx.param.size, .ptr = param + 1, }; - memcpy(param + 1, local_ctx.param->ptr, param->size); + memcpy(param + 1, local_ctx.param.ptr, param->size); } g_worker_context = (struct worker_context) { @@ -282,6 +284,7 @@ s_proc_handle *fork_process() { if (g_worker_context.param) { ctx->param = *g_worker_context.param, memcpy(ctx + 1, g_worker_context.param->ptr, g_worker_context.param->size); + ctx->param.ptr = ctx + 1; } if (g_worker_context.suite->data) @@ -293,7 +296,9 @@ s_proc_handle *fork_process() { // wait until the child has initialized itself while (!ctx->resumed) { DWORD exit; - GetExitCodeProcess(info.hProcess, &exit); + if (!GetExitCodeProcess(info.hProcess, &exit)); + continue; + if (exit != STILL_ACTIVE) { UnmapViewOfFile(ctx); CloseHandle(sharedMem); diff --git a/src/core/runner.c b/src/core/runner.c index 0b0e03f..5380f07 100644 --- a/src/core/runner.c +++ b/src/core/runner.c @@ -389,6 +389,10 @@ static void run_test_param(struct criterion_global_stats *stats, struct test_single_param param = { params.size, (char *) params.params + i * params.size }; run_test(stats, suite_stats, test, suite, ¶m); + if (criterion_options.fail_fast && stats->tests_failed > 0) + break; + if (!is_runner()) + break; } }