diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-05 18:11:08 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-05 18:23:45 +0200 |
commit | a8b6cc4cd90ef0649aada4469f91c4e58819f1a2 (patch) | |
tree | 7826c3a72feccac083ddc0c81f4e08dca072fde4 | |
parent | 7c0031fc8063771e604976233fb7b46d2b85c077 (diff) |
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
-rw-r--r-- | tests/ctrl/ctrl_test.c | 13 |
1 files changed, 12 insertions, 1 deletions
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; } |