[PATCH] libosmocore[master]: fix ctrl_test sanitizer issues

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Apr 5 16:25:13 UTC 2018


Review at  https://gerrit.osmocom.org/7651

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
---
M tests/ctrl/ctrl_test.c
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/51/7651/1

diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index b7b30c3..8bb917b 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -397,6 +397,7 @@
 	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) {
@@ -407,6 +408,9 @@
 
 	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) {
@@ -438,7 +442,8 @@
 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 @@
 
 	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;
 }

-- 
To view, visit https://gerrit.osmocom.org/7651
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief3d5e7b6c4d781b3854e230e45a67d5281b94cd
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list