X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=test%2Fparser%2Futils.c;h=70a40bbd5b60b2ce40daf3fec41c09b0b5d03a32;hp=68fc3debb333baf36cc2560dc8668393d0effe3e;hb=434a6c9c100bc8daca1e6c41137f993d88f20fe3;hpb=9974f2d82b9450eaccd7661b3bfabb686ab8e161 diff --git a/test/parser/utils.c b/test/parser/utils.c index 68fc3de..70a40bb 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -32,6 +32,14 @@ void __register_parser(struct parser *parser) list_add(&parsers, &i->list); } +static void __attribute__((destructor)) __cleanup_parsers(void) +{ + struct p_item *item, *tmp; + + list_for_each_entry_safe(&parsers, item, tmp, list) + talloc_free(item); +} + static struct discover_device *test_create_device_simple( struct discover_context *ctx) { @@ -78,7 +86,7 @@ struct parser_test *test_init(void) struct parser_test *test; test = talloc_zero(NULL, struct parser_test); - test->handler = device_handler_init(NULL, 0); + test->handler = device_handler_init(NULL, NULL, 0); test->ctx = test_create_context(test); return test; @@ -282,3 +290,10 @@ void __check_unresolved_resource(struct resource *res, if (res->resolved) errx(EXIT_FAILURE, "%s:%d: Resource is resolved", file, line); } + +void __check_not_present_resource(struct resource *res, + const char *file, int line) +{ + if (res) + errx(EXIT_FAILURE, "%s:%d: Resource present", file, line); +}