From 07a5f9f1c50a9185851cd486d732976573d15c4f Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Mon, 23 May 2016 15:56:22 +1000 Subject: Update tests to support changes to pxe_parser Substitute load_url_async() when running tests to support direct callers of load_url_async() who will expect to read a file in a callback. Stub out device_handler_discover_context_commit() since it will remove discover_options from the given discover_context, but the tests will check the discover_context to count boot_options. Signed-off-by: Samuel Mendoza-Jonas --- discover/device-handler.c | 96 +++++++++++++++++++++++++---------------------- discover/paths.c | 31 +++++++++++++++ 2 files changed, 82 insertions(+), 45 deletions(-) (limited to 'discover') diff --git a/discover/device-handler.c b/discover/device-handler.c index 1c69de0..9fd9fab 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -708,50 +708,6 @@ struct discover_context *device_handler_discover_context_create( return ctx; } -/** - * context_commit - Commit a temporary discovery context to the handler, - * and notify the clients about any new options / devices - */ -void device_handler_discover_context_commit(struct device_handler *handler, - struct discover_context *ctx) -{ - struct discover_device *dev = ctx->device; - struct discover_boot_option *opt, *tmp; - - if (!device_lookup_by_id(handler, dev->device->id)) - device_handler_add_device(handler, dev); - - /* move boot options from the context to the device */ - list_for_each_entry_safe(&ctx->boot_options, opt, tmp, list) { - list_remove(&opt->list); - - if (boot_option_resolve(opt, handler)) { - pb_log("boot option %s is resolved, " - "sending to clients\n", - opt->option->id); - list_add_tail(&dev->boot_options, &opt->list); - talloc_steal(dev, opt); - boot_option_finalise(handler, opt); - notify_boot_option(handler, opt); - } else { - if (!opt->source->resolve_resource) { - pb_log("parser %s gave us an unresolved " - "resource (%s), but no way to " - "resolve it\n", - opt->source->name, opt->option->id); - talloc_free(opt); - } else { - pb_log("boot option %s is unresolved, " - "adding to queue\n", - opt->option->id); - list_add(&handler->unresolved_boot_options, - &opt->list); - talloc_steal(handler, opt); - } - } - } -} - void device_handler_add_device(struct device_handler *handler, struct discover_device *device) { @@ -1218,6 +1174,50 @@ msg: #ifndef PETITBOOT_TEST +/** + * context_commit - Commit a temporary discovery context to the handler, + * and notify the clients about any new options / devices + */ +void device_handler_discover_context_commit(struct device_handler *handler, + struct discover_context *ctx) +{ + struct discover_device *dev = ctx->device; + struct discover_boot_option *opt, *tmp; + + if (!device_lookup_by_id(handler, dev->device->id)) + device_handler_add_device(handler, dev); + + /* move boot options from the context to the device */ + list_for_each_entry_safe(&ctx->boot_options, opt, tmp, list) { + list_remove(&opt->list); + + if (boot_option_resolve(opt, handler)) { + pb_log("boot option %s is resolved, " + "sending to clients\n", + opt->option->id); + list_add_tail(&dev->boot_options, &opt->list); + talloc_steal(dev, opt); + boot_option_finalise(handler, opt); + notify_boot_option(handler, opt); + } else { + if (!opt->source->resolve_resource) { + pb_log("parser %s gave us an unresolved " + "resource (%s), but no way to " + "resolve it\n", + opt->source->name, opt->option->id); + talloc_free(opt); + } else { + pb_log("boot option %s is unresolved, " + "adding to queue\n", + opt->option->id); + list_add(&handler->unresolved_boot_options, + &opt->list); + talloc_steal(handler, opt); + } + } + } +} + static void device_handler_update_lang(const char *lang) { const char *cur_lang; @@ -1566,6 +1566,13 @@ void device_release_write(struct discover_device *dev, bool release) #else +void device_handler_discover_context_commit( + struct device_handler *handler __attribute__((unused)), + struct discover_context *ctx __attribute__((unused))) +{ + pb_log("%s stubbed out for test cases\n", __func__); +} + static void device_handler_update_lang(const char *lang __attribute__((unused))) { } @@ -1605,4 +1612,3 @@ void device_release_write(struct discover_device *dev __attribute__((unused)), } #endif - diff --git a/discover/paths.c b/discover/paths.c index 1269dde..7fcff9e 100644 --- a/discover/paths.c +++ b/discover/paths.c @@ -47,6 +47,7 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b) return full_path; } +#ifndef PETITBOOT_TEST static char *local_name(void *ctx) { @@ -449,3 +450,33 @@ void load_url_async_cancel(struct load_url_result *res) res->status = LOAD_CANCELLED; process_stop_async(task->process); } + +#else + +static void __attribute__((unused)) load_local( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_wget( + struct load_task *task __attribute__((unused)), + int flags __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_tftp( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_sftp( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_nfs( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_url_process_exit( + struct process *process __attribute__((unused))) +{ +} + +#endif -- cgit v1.2.1