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
This commit is contained in:
parent
11ac91ca1a
commit
75d905bbc7
|
@ -61,6 +61,8 @@ import from PFCP_Emulation all;
|
|||
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 @@ function f_init(charstring id := "HNBGW", float guard_timeout := 30.0) runs on t
|
|||
}
|
||||
|
||||
friend function f_shutdown_helper() runs on test_CT {
|
||||
f_verify_talloc_bytes(HNBGWVTY, {"asn1_context"}, 1);
|
||||
|
||||
all component.stop;
|
||||
setverdict(pass);
|
||||
mtc.stop;
|
||||
|
|
|
@ -310,4 +310,57 @@ public function f_str_split(charstring str, charstring delim := "\n") return ro_
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue