neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/33479 )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: hnbgw: verify empty talloc asn1_context at end of tests ......................................................................
hnbgw: verify empty talloc asn1_context at end of tests
This allowed me to find massive memory leaks in osmo-hnbgw: at the end of each test, run f_shutdown_helper(), and in it query 'show talloc' for an empty asn1_context.
Hence verify that all the scenarios run in these ttcn3 tests have no asn1 de/encoding memory leaks.
Change-Id: I2948ee6f167369a2252f85b493e9653b93c7e4e9 --- M hnbgw/HNBGW_Tests.ttcn M library/Osmocom_VTY_Functions.ttcn 2 files changed, 73 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn index d4f101b..e9db214 100644 --- a/hnbgw/HNBGW_Tests.ttcn +++ b/hnbgw/HNBGW_Tests.ttcn @@ -61,6 +61,8 @@ import from PFCP_Templates all; import from PFCP_CodecPort all;
+import from TCCConversion_Functions all; + modulepar { /* IP address at which the HNodeB can be reached */ charstring mp_hnodeb_ip := "127.0.0.1"; @@ -372,6 +374,8 @@ }
friend function f_shutdown_helper() runs on test_CT { + f_verify_talloc_bytes(HNBGWVTY, {"asn1_context"}, 1); + all component.stop; setverdict(pass); mtc.stop; diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn index ed506a7..a448b8b 100644 --- a/library/Osmocom_VTY_Functions.ttcn +++ b/library/Osmocom_VTY_Functions.ttcn @@ -310,4 +310,57 @@ return parts; }
+public function f_verify_talloc_bytes(TELNETasp_PT pt, ro_charstring object_strs, integer expect_bytes := 0, + integer attempts := 5, float wait_time := 3.0) +{ + var charstring show_cmd := "show talloc-context application brief"; + + while (attempts > 0) { + attempts := attempts - 1; + var charstring ret := f_vty_transceive_ret(pt, show_cmd); + + var ro_charstring lines := f_str_split(ret); + + var boolean ok := true; + for (var integer i := 0; i < lengthof(object_strs); i := i + 1) { + var charstring object_str := object_strs[i]; + + var integer bytes := 0; + + for (var integer j := 0; j < lengthof(lines); j := j + 1) { + var charstring line := lines[j]; + if (f_strstr(line, object_str) < 0) { + continue; + } + var ro_charstring tokens := f_str_split(line, " "); + if (lengthof(tokens) < 4) { + continue; + } + if (tokens[3] != "bytes") { + continue; + } + bytes := f_str2int(tokens[2]); + } + + if (bytes != expect_bytes) { + ok := false; + log("ERROR: talloc reports ", object_str, " = ", bytes, " bytes, expecting ", expect_bytes, + " from VTY response ", lines); + } else { + log("ok: talloc reports ", object_str, " = ", bytes, " bytes"); + } + } + if (ok) { + return; + } + if (attempts == 0) { + break; + } + log("bytes count mismatch, retrying in ", wait_time); + f_sleep(wait_time); + } + setverdict(fail, "talloc bytes count mismatch"); + mtc.stop; +} + }