From c68d96e47369033074e1e91bdd113704ff5b792f Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 10 Mar 2020 23:24:58 +1030 Subject: [PATCH] test_seq: Clean up after each test case Free all allocated memory to avoid false-positive leak reports. Resolves: ==11106==ERROR: LeakSanitizer: detected memory leaks Indirect leak of 12288 byte(s) in 3 object(s) allocated from: #0 0x7f92a1347f1e in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10df1e) #1 0x7f92a1207065 in __mctp_realloc /home/andrew/src/openbmc/libmctp/alloc.c:48 #2 0x7f92a1201979 in mctp_msg_ctx_add_pkt /home/andrew/src/openbmc/libmctp/core.c:213 #3 0x7f92a1204a09 in mctp_bus_rx /home/andrew/src/openbmc/libmctp/core.c:383 #4 0x55ff747e1655 in mctp_binding_test_rx_raw tests/test-utils.c:50 #5 0x55ff747df302 in run_one_test tests/test_seq.c:122 #6 0x55ff747df6d6 in main tests/test_seq.c:141 #7 0x7f92a06b21e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Indirect leak of 2208 byte(s) in 4 object(s) allocated from: #0 0x7f92a1347ae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8) #1 0x7f92a1206cf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28 #2 0x7f92a1201edc in mctp_init /home/andrew/src/openbmc/libmctp/core.c:234 #3 0x55ff747e1738 in mctp_test_stack_init tests/test-utils.c:63 #4 0x55ff747def62 in run_one_test tests/test_seq.c:111 #5 0x55ff747df6d6 in main tests/test_seq.c:141 #6 0x7f92a06b21e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Indirect leak of 224 byte(s) in 4 object(s) allocated from: #0 0x7f92a1347ae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8) #1 0x7f92a1206cf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28 #2 0x55ff747e1169 in mctp_binding_test_init tests/test-utils.c:27 #3 0x55ff747e17b1 in mctp_test_stack_init tests/test-utils.c:66 #4 0x55ff747def62 in run_one_test tests/test_seq.c:111 #5 0x55ff747df6d6 in main tests/test_seq.c:141 #6 0x7f92a06b21e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Indirect leak of 160 byte(s) in 4 object(s) allocated from: #0 0x7f92a1347ae8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dae8) #1 0x7f92a1206cf0 in __mctp_alloc /home/andrew/src/openbmc/libmctp/alloc.c:28 #2 0x7f92a120255f in mctp_register_bus /home/andrew/src/openbmc/libmctp/core.c:277 #3 0x55ff747e16eb in mctp_binding_test_register_bus tests/test-utils.c:56 #4 0x55ff747e18d5 in mctp_test_stack_init tests/test-utils.c:69 #5 0x55ff747def62 in run_one_test tests/test_seq.c:111 #6 0x55ff747df6d6 in main tests/test_seq.c:141 #7 0x7f92a06b21e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) Signed-off-by: Andrew Jeffery Change-Id: I7fbc729740357eb89b679dd51bbf03d6735a75dc --- tests/test_seq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_seq.c b/tests/test_seq.c index 1fc5b8f7..e99dc941 100644 --- a/tests/test_seq.c +++ b/tests/test_seq.c @@ -129,6 +129,9 @@ static void run_one_test(struct test_ctx *ctx, struct test *test) /* ensure the payload data was reconstructed correctly */ for (i = 0; i < (int)ctx->rx_len; i++) assert(ctx->rx_data[i] == i); + + mctp_binding_test_destroy(ctx->binding); + mctp_destroy(ctx->mctp); }