From a0d531d515690ef83512655c00e09de0ce2aff6c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 7 Sep 2021 13:36:06 +0930 Subject: [PATCH] pytest: annotate name_option against leak detection in test_libplugin Signed-off-by: Rusty Russell --- tests/plugins/test_libplugin.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/plugins/test_libplugin.c b/tests/plugins/test_libplugin.c index 39774e64d..63f9d7134 100644 --- a/tests/plugins/test_libplugin.c +++ b/tests/plugins/test_libplugin.c @@ -1,6 +1,7 @@ #include #include #include +#include #include @@ -99,6 +100,14 @@ static struct command_result *json_testrpc(struct command *cmd, return send_outreq(cmd->plugin, req); } +#if DEVELOPER +static void memleak_mark(struct plugin *p, struct htable *memtable) +{ + /* name_option is not a leak! */ + memleak_remove_region(memtable, &name_option, sizeof(name_option)); +} +#endif /* DEVELOPER */ + static const char *init(struct plugin *p, const char *buf UNUSED, const jsmntok_t *config UNUSED) @@ -107,6 +116,11 @@ static const char *init(struct plugin *p, if (self_disable) return "Disabled via selfdisable option"; + +#if DEVELOPER + plugin_set_memleak_handler(p, memleak_mark); +#endif + return NULL; }