From a8b6cc4cd90ef0649aada4469f91c4e58819f1a2 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 5 Apr 2018 18:11:08 +0200 Subject: fix ctrl_test sanitizer issues Add logging to root ctx, add msgb ctx to root ctx, free wqueue to simulate the msgb being sent, and assert final talloc size. Change-Id: Ief3d5e7b6c4d781b3854e230e45a67d5281b94cd --- tests/ctrl/ctrl_test.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c index b7b30c3e..8bb917b9 100644 --- a/tests/ctrl/ctrl_test.c +++ b/tests/ctrl/ctrl_test.c @@ -397,6 +397,7 @@ static void test_deferred_cmd() printf("ctrl_handle_msg() returned %d\n", result); OSMO_ASSERT(result == CTRL_CMD_HANDLED); + talloc_free(msg); /* Expecting a ctrl_cmd_def as well as the cmd to still be allocated */ if (talloc_total_size(ctx) <= ctx_size_before_defer) { @@ -408,6 +409,9 @@ static void test_deferred_cmd() printf("invoking ctrl_test_defer_cb() asynchronously\n"); ctrl_test_defer_cb(test_defer_cd); + /* simulate sending of the reply */ + osmo_wqueue_clear(&ccon->write_queue); + /* And now the deferred cmd should be cleaned up completely. */ if (talloc_total_size(ctx) != ctx_size_before_defer) { printf("mem leak!\n"); @@ -438,7 +442,8 @@ static struct log_info info = { int main(int argc, char **argv) { ctx = talloc_named_const(NULL, 1, "ctrl_test"); - osmo_init_logging(&info); + osmo_init_logging2(ctx, &info); + msgb_talloc_ctx_init(ctx, 0); printf("Checking ctrl types...\n"); @@ -455,5 +460,11 @@ int main(int argc, char **argv) test_deferred_cmd(); + /* Expecting root ctx + msgb root ctx + 5 logging elements */ + if (talloc_total_blocks(ctx) != 7) { + talloc_report_full(ctx, stdout); + OSMO_ASSERT(false); + } + return 0; } -- cgit v1.2.3