osmo-iuh[master]: tests: sanitize: clean after tests
Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/4916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmo-iuh[master]: tests: sanitize: clean after tests
Hello Jenkins Builder, Holger Freyther, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/4916 to look at the new patch set (#3). tests: sanitize: clean after tests Add test_common_cleanup() in test_common.c, call in test-{helpers,hnbap,ranap}.c, so that any memleaks a sanitize build finds are real bugs. Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c --- M src/tests/test-helpers.c M src/tests/test-hnbap.c M src/tests/test-ranap.c M src/tests/test_common.c M src/tests/test_common.h 5 files changed, 19 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/16/4916/3 diff --git a/src/tests/test-helpers.c b/src/tests/test-helpers.c index 44fd735..33ef2e1 100644 --- a/src/tests/test-helpers.c +++ b/src/tests/test-helpers.c @@ -211,5 +211,6 @@ test_asn1_helpers(); test_ranap_common(); + test_common_cleanup(); return 0; } diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c index ef46070..1e3607b 100644 --- a/src/tests/test-hnbap.c +++ b/src/tests/test-hnbap.c @@ -175,6 +175,7 @@ test_asn1_decoding(); + test_common_cleanup(); return 0; } diff --git a/src/tests/test-ranap.c b/src/tests/test-ranap.c index c1c7003..05be874 100644 --- a/src/tests/test-ranap.c +++ b/src/tests/test-ranap.c @@ -197,6 +197,8 @@ talloc_report(talloc_asn1_ctx, stdout); talloc_report(tall_msgb_ctx, stdout); //talloc_report(NULL, stdout); + + test_common_cleanup(); printf("exit\n"); exit(0); } diff --git a/src/tests/test_common.c b/src/tests/test_common.c index c8aafdd..a487d0d 100644 --- a/src/tests/test_common.c +++ b/src/tests/test_common.c @@ -69,11 +69,13 @@ .num_cat = ARRAY_SIZE(log_cat), }; +static void *msgb_ctx; + int test_common_init(void) { int rc; - msgb_talloc_ctx_init(NULL, 0); + msgb_ctx = msgb_talloc_ctx_init(NULL, 0); talloc_asn1_ctx = talloc_named_const(NULL, 0, "asn1_context"); rc = osmo_init_logging(&test_log_info); @@ -85,3 +87,14 @@ log_set_print_filename(osmo_stderr_target, 0); log_set_use_color(osmo_stderr_target, 0); } + +void test_common_cleanup(void) +{ + OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1); + OSMO_ASSERT(talloc_total_size(msgb_ctx) == 0); + talloc_free(msgb_ctx); + + OSMO_ASSERT(talloc_total_blocks(talloc_asn1_ctx) == 1); + OSMO_ASSERT(talloc_total_size(talloc_asn1_ctx) == 0); + talloc_free(talloc_asn1_ctx); +} diff --git a/src/tests/test_common.h b/src/tests/test_common.h index 1af1abd..836d999 100644 --- a/src/tests/test_common.h +++ b/src/tests/test_common.h @@ -1,3 +1,4 @@ #pragma once int test_common_init(void); +void test_common_cleanup(void); -- To view, visit https://gerrit.osmocom.org/4916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c Gerrit-PatchSet: 3 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder
osmo-iuh[master]: tests: sanitize: clean after tests
Patch Set 2: Code-Review-1 Due the hierarchical nature of talloc we would silence all msgb's leaks? So the common code should print the leak count? -- To view, visit https://gerrit.osmocom.org/4916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Holger Freyther Gerrit-Reviewer: Jenkins Builder Gerrit-HasComments: No
[PATCH] osmo-iuh[master]: tests: sanitize: clean after tests
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/4916 to look at the new patch set (#2). tests: sanitize: clean after tests Add test_common_cleanup() in test_common.c, call in test-{helpers,hnbap,ranap}.c, so that any memleaks a sanitize build finds are real bugs. Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c --- M src/tests/test-helpers.c M src/tests/test-hnbap.c M src/tests/test-ranap.c M src/tests/test_common.c M src/tests/test_common.h 5 files changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/16/4916/2 diff --git a/src/tests/test-helpers.c b/src/tests/test-helpers.c index 44fd735..33ef2e1 100644 --- a/src/tests/test-helpers.c +++ b/src/tests/test-helpers.c @@ -211,5 +211,6 @@ test_asn1_helpers(); test_ranap_common(); + test_common_cleanup(); return 0; } diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c index ef46070..1e3607b 100644 --- a/src/tests/test-hnbap.c +++ b/src/tests/test-hnbap.c @@ -175,6 +175,7 @@ test_asn1_decoding(); + test_common_cleanup(); return 0; } diff --git a/src/tests/test-ranap.c b/src/tests/test-ranap.c index c1c7003..05be874 100644 --- a/src/tests/test-ranap.c +++ b/src/tests/test-ranap.c @@ -197,6 +197,8 @@ talloc_report(talloc_asn1_ctx, stdout); talloc_report(tall_msgb_ctx, stdout); //talloc_report(NULL, stdout); + + test_common_cleanup(); printf("exit\n"); exit(0); } diff --git a/src/tests/test_common.c b/src/tests/test_common.c index c8aafdd..5c33680 100644 --- a/src/tests/test_common.c +++ b/src/tests/test_common.c @@ -69,11 +69,13 @@ .num_cat = ARRAY_SIZE(log_cat), }; +static void *msgb_ctx; + int test_common_init(void) { int rc; - msgb_talloc_ctx_init(NULL, 0); + msgb_ctx = msgb_talloc_ctx_init(NULL, 0); talloc_asn1_ctx = talloc_named_const(NULL, 0, "asn1_context"); rc = osmo_init_logging(&test_log_info); @@ -85,3 +87,9 @@ log_set_print_filename(osmo_stderr_target, 0); log_set_use_color(osmo_stderr_target, 0); } + +void test_common_cleanup(void) +{ + talloc_free(msgb_ctx); + talloc_free(talloc_asn1_ctx); +} diff --git a/src/tests/test_common.h b/src/tests/test_common.h index 1af1abd..836d999 100644 --- a/src/tests/test_common.h +++ b/src/tests/test_common.h @@ -1,3 +1,4 @@ #pragma once int test_common_init(void); +void test_common_cleanup(void); -- To view, visit https://gerrit.osmocom.org/4916 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c Gerrit-PatchSet: 2 Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr Gerrit-Reviewer: Jenkins Builder