summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-05-23 15:56:22 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-06-28 16:17:21 +1000
commit07a5f9f1c50a9185851cd486d732976573d15c4f (patch)
treed30b4e52b9942965d12581b3f7502737c6c135e7 /discover/device-handler.c
parent1a72ffef7837cd2aa3e6be945ec03fb6b5caa51a (diff)
downloadtalos-petitboot-07a5f9f1c50a9185851cd486d732976573d15c4f.zip
talos-petitboot-07a5f9f1c50a9185851cd486d732976573d15c4f.tar.gz
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 <sam@mendozajonas.com>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c96
1 files changed, 51 insertions, 45 deletions
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
-
OpenPOWER on IntegriCloud