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
Review at https://gerrit.osmocom.org/4867
stats_test: clarify talloc contexts
Change-Id: I0eda27cd3e322fb43a825382b37185048ebcd509
---
M tests/stats/stats_test.c
1 file changed, 13 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/67/4867/1
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index b302b37..054fa78 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -313,6 +313,8 @@
struct osmo_stat_item_group *statg1, *statg2;
struct rate_ctr_group *ctrg1, *ctrg2, *ctrg3;
void *stats_ctx = talloc_named_const(NULL, 1, "stats test context");
+ void *ctr_ctx = talloc_named_const(NULL, 1, "rate counter context");
+ void *ctr_with_dot_ctx = talloc_named_const(NULL, 1, "rate counter with dot context");
int rc;
@@ -323,11 +325,11 @@
OSMO_ASSERT(statg1 != NULL);
statg2 = osmo_stat_item_group_alloc(stats_ctx, &statg_desc, 2);
OSMO_ASSERT(statg2 != NULL);
- ctrg1 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 1);
+ ctrg1 = rate_ctr_group_alloc(ctr_ctx, &ctrg_desc, 1);
OSMO_ASSERT(ctrg1 != NULL);
- ctrg2 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2);
+ ctrg2 = rate_ctr_group_alloc(ctr_ctx, &ctrg_desc, 2);
OSMO_ASSERT(ctrg2 != NULL);
- ctrg3 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc_dot, 3);
+ ctrg3 = rate_ctr_group_alloc(ctr_with_dot_ctx, &ctrg_desc_dot, 3);
OSMO_ASSERT(ctrg3 != NULL);
srep1 = stats_reporter_create_test("test1");
@@ -462,10 +464,17 @@
rate_ctr_group_free(ctrg3);
- /* Leak check */
+ /* Leak check -- expecting one block each (= just the context itself), except for
+ * ctr_with_dot_ctx, where we expect a mangled rate counter group desc to be allocated. */
OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1);
talloc_free(stats_ctx);
+ OSMO_ASSERT(talloc_total_blocks(ctr_ctx) == 1);
+ talloc_free(ctr_ctx);
+
+ OSMO_ASSERT(talloc_total_blocks(ctr_with_dot_ctx) == 1);
+ talloc_free(ctr_with_dot_ctx);
+
printf("End test: %s\n", __func__);
}
--
To view, visit https://gerrit.osmocom.org/4867
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0eda27cd3e322fb43a825382b37185048ebcd509
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>