tests: sanitize: fix mem leaks, clean after tests
Fix various mem leaks in the testing code.
Add test_common_cleanup() in test_common.c, to free talloc contexts; call in
test-{helpers,hnbap,ranap}.c. Upon talloc ctx cleanup, ensure that they are
actually empty, in order to catch newly introduced mem leaks.
If non-empty, print talloc context reports.
Change-Id: Ic66c005f2a264774e18bb54e58b87bef5944511c
diff --git a/src/tests/test-hnbap.c b/src/tests/test-hnbap.c
index ef46070..dfd5ae9 100644
--- a/src/tests/test-hnbap.c
+++ b/src/tests/test-hnbap.c
@@ -142,6 +142,8 @@
printf("HNBAP UE Register request from IMSI %s\n", imsi);
hnbap_free_ueregisterrequesties(&ue_req_ies);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, pdu);
+
memset(pdu, 0, sizeof(*pdu));
dec_ret = aper_decode(NULL, &asn_DEF_HNBAP_PDU, (void **) &pdu,
hnbap_ue_reg_acc, sizeof(hnbap_ue_reg_acc), 0, 0);
@@ -163,6 +165,7 @@
printf("HNBAP UE Register accept to IMSI %s\n", imsi);
hnbap_free_ueregisteraccepties(&ue_acc_ies);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, pdu);
}
int main(int argc, char **argv)
@@ -175,6 +178,7 @@
test_asn1_decoding();
+ test_common_cleanup();
return 0;
}