diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-15 16:41:56 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-05-16 11:53:34 +0800 |
commit | 22b9ca8f4b9d28b4405576b39a87d3d0c945dd07 (patch) | |
tree | d01e69d0c64a8dceb54ee1b391b6190208d4aabd /test/parser/utils.c | |
parent | 31998343c5eb5533ef85b97f5bb2ffe200eb2ad0 (diff) | |
download | petitboot-22b9ca8f4b9d28b4405576b39a87d3d0c945dd07.zip petitboot-22b9ca8f4b9d28b4405576b39a87d3d0c945dd07.tar.gz |
test/parser: Add test device hotplug functions
Add a function, test_hotplug_device(), to simulate the addition of
devices during tests. This should make it possible to observe boot
options' resources changing from unresolved state to resolved.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test/parser/utils.c')
-rw-r--r-- | test/parser/utils.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/parser/utils.c b/test/parser/utils.c index fb558cf..43479b1 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -141,6 +141,41 @@ int test_run_parser(struct parser_test *test, const char *parser_name) return rc; } +bool resource_resolve(struct device_handler *handler, struct parser *parser, + struct resource *resource) +{ + if (!resource) + return true; + if (resource->resolved) + return true; + + assert(parser); + assert(parser->resolve_resource); + + return parser->resolve_resource(handler, resource); +} + +void boot_option_resolve(struct device_handler *handler, + struct discover_boot_option *opt) +{ + resource_resolve(handler, opt->source, opt->boot_image); + resource_resolve(handler, opt->source, opt->initrd); + resource_resolve(handler, opt->source, opt->icon); +} + +extern void device_handler_add_device(struct device_handler *handler, + struct discover_device *dev); + +void test_hotplug_device(struct parser_test *test, struct discover_device *dev) +{ + struct discover_boot_option *opt; + + device_handler_add_device(test->handler, dev); + + list_for_each_entry(&test->ctx->boot_options, opt, list) + boot_option_resolve(test->handler, opt); +} + struct discover_boot_option *get_boot_option(struct discover_context *ctx, int idx) { |