static void yaboot_finish(struct conf_context *conf)
{
struct yaboot_state *state = conf->parser_info;
+ const char *default_label;
struct boot_option *opt;
assert(state->opt);
conf_strip_str(opt->boot_args);
conf_strip_str(opt->description);
+ default_label = conf_get_global_option(conf, "default");
+ if (default_label &&
+ !strcasecmp(state->opt->option->name, default_label))
+ state->opt->option->is_default = true;
+
discover_context_add_boot_option(conf->dc, state->opt);
}
{ .name = "video" },
{ .name = "literal" },
{ .name = "ramdisk" },
+ { .name = "default" },
{ .name = NULL },
};
test-yaboot-root-global \
test-yaboot-root-override \
test-yaboot-device-override \
+ test-yaboot-default \
test-yaboot-rh8-ppc64 \
test-pxe-single \
test-pxe-initrd-in-append
#define check_name(opt, name) \
__check_name(opt, name, __FILE__, __LINE__)
+/**
+ * Check that a boot option @opt is marked as default
+ */
+void __check_is_default(struct discover_boot_option *opt,
+ const char *file, int line);
+#define check_is_default(opt) \
+ __check_is_default(opt, __FILE__, __LINE__)
+
/**
* Check that a resource (@res) is present, resolved, and has a local path
* (within @dev's mount point) of @path.
--- /dev/null
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+default=linux.2
+
+image=/vmlinux
+ label=linux.1
+
+image=/vmlinux
+ label=linux.2
+#endif
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt;
+ struct discover_context *ctx;
+
+ test_read_conf_embedded(test);
+ test_run_parser(test, "yaboot");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 2);
+
+ opt = get_boot_option(ctx, 1);
+ check_name(opt, "linux.2");
+ check_is_default(opt);
+}
}
}
+void __check_is_default(struct discover_boot_option *opt,
+ const char *file, int line)
+{
+ if (opt->option->is_default)
+ return;
+
+ fprintf(stderr, "%s:%d: default check failed\n", file, line);
+ exit(EXIT_FAILURE);
+}
+
void __check_resolved_local_resource(struct resource *res,
struct discover_device *dev, const char *local_path,
const char *file, int line)