memcheck: Fixed client & runner leaks

This commit is contained in:
Snaipe 2016-08-10 12:39:08 +02:00
parent a1d690ffdb
commit 14f7f60ce7
3 changed files with 19 additions and 2 deletions

View file

@ -107,6 +107,8 @@ void destroy_client_context(struct client_ctx *ctx) {
if (rc < 0)
cr_panic("finalizing the worker failed: %s\n", strerror(-rc));
}
sfree(ctx->tstats);
sfree(ctx->sstats);
}
void destroy_server_context(struct server_ctx *sctx) {
@ -157,7 +159,7 @@ struct client_ctx *add_external_client(struct server_ctx *sctx, char *id) {
.category = "external",
},
.gstats = sctx->gstats,
.sstats = sctx->extern_sstats,
.sstats = sref(sctx->extern_sstats),
};
struct client_ctx *ctx = &kh_value(sctx->clients, k);

View file

@ -329,16 +329,25 @@ static int criterion_run_all_tests_impl(struct criterion_test_set *set)
cri_proto_close(g_client_socket);
cri_proto_close(sock);
int ok = stats->tests_failed == 0;
sfree(stats);
return stats->tests_failed == 0;
return ok;
}
CR_API int criterion_run_all_tests(struct criterion_test_set *set)
{
#ifndef ENABLE_VALGRIND_ERRORS
VALGRIND_DISABLE_ERROR_REPORTING;
#endif
if (criterion_options.pattern) {
disable_unmatching(set);
}
int res = criterion_run_all_tests_impl(set);
#ifndef ENABLE_VALGRIND_ERRORS
VALGRIND_ENABLE_ERROR_REPORTING;
#endif
return criterion_options.always_succeed || res;
}

View file

@ -215,6 +215,10 @@ static int run_test_child(void)
#endif
cri_proto_close(g_client_socket);
#ifndef ENABLE_VALGRIND_ERRORS
VALGRIND_ENABLE_ERROR_REPORTING;
#endif
return 0;
}
@ -282,6 +286,8 @@ static bxf_instance *run_test(struct run_next_context *ctx,
if (rc < 0)
cr_panic("Could not spawn test instance: %s", strerror(-rc));
bxf_context_term(inst_ctx);
*client = (struct client_ctx) {
.test = ctx->test,
.suite = &ctx->suite_set->suite,