aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-11-21 23:01:39 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2017-11-22 02:57:07 +0100
commit0442ea22b86e5c008dae5d452cdbfbd3f5020ff6 (patch)
treea09bdc0925bd6246f8d8314841560f9d6fff57ae
parent5900c84bd3e121177032e0f3f95098038de0eaf2 (diff)
sms_queue_test: sanitize: clean up talloc contexts when done
To avoid sanitizer build failures, ensure that the talloc contexts are empty when done and free them. Separate the msgb context from the overall talloc context for clarity: if nested, the outer one would contain two blocks. Change the "sms_queue_test" context from 1 byte to 0 in order to get a size of zero in the end. Change-Id: If08ba48ab9c28bf3c2db4014837c1304cec04aaf
-rw-r--r--tests/sms_queue/sms_queue_test.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/sms_queue/sms_queue_test.c b/tests/sms_queue/sms_queue_test.c
index 0d073db01..0ff636e79 100644
--- a/tests/sms_queue/sms_queue_test.c
+++ b/tests/sms_queue/sms_queue_test.c
@@ -197,8 +197,10 @@ static struct log_info info = {
int main(int argc, char **argv)
{
- talloc_ctx = talloc_named_const(NULL, 1, "sms_queue_test");
- msgb_talloc_ctx_init(talloc_ctx, 0);
+ void *msgb_ctx;
+
+ talloc_ctx = talloc_named_const(NULL, 0, "sms_queue_test");
+ msgb_ctx = msgb_talloc_ctx_init(NULL, 0);
osmo_init_logging(&info);
OSMO_ASSERT(osmo_stderr_target);
@@ -211,5 +213,23 @@ int main(int argc, char **argv)
test_next_sms();
printf("Done\n");
+ if (talloc_total_blocks(msgb_ctx) != 1
+ || talloc_total_size(msgb_ctx) != 0) {
+ talloc_report_full(msgb_ctx, stderr);
+ fflush(stderr);
+ }
+
+ OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);
+ OSMO_ASSERT(talloc_total_size(msgb_ctx) == 0);
+ talloc_free(msgb_ctx);
+
+ if (talloc_total_blocks(talloc_ctx) != 1
+ || talloc_total_size(talloc_ctx) != 0)
+ talloc_report_full(talloc_ctx, stderr);
+
+ OSMO_ASSERT(talloc_total_blocks(talloc_ctx) == 1);
+ OSMO_ASSERT(talloc_total_size(talloc_ctx) == 0);
+ talloc_free(talloc_ctx);
+
return 0;
}