10 #include <types/types.h>
11 #include <talloc/talloc.h>
13 #include "discover/device-handler.h"
14 #include "discover/parser.h"
15 #include "discover/parser-utils.h"
16 #include "discover/paths.h"
20 struct device *discover_context_device(struct discover_context *ctx)
22 return ctx->device->device;
25 struct discover_boot_option *discover_boot_option_create(
26 struct discover_context *ctx,
27 struct discover_device *dev)
29 struct discover_boot_option *opt;
31 opt = talloc_zero(ctx, struct discover_boot_option);
32 opt->option = talloc(opt, struct boot_option);
38 void discover_context_add_boot_option(struct discover_context *ctx,
39 struct discover_boot_option *boot_option)
41 struct boot_option *opt = boot_option->option;
43 fprintf(testf, "%s: %s\n", __func__, ctx->device->device->id);
44 fprintf(testf, " id '%s'\n", opt->id);
45 fprintf(testf, " name '%s'\n", opt->name);
46 fprintf(testf, " descr '%s'\n", opt->description);
47 fprintf(testf, " icon '%s'\n", opt->icon_file);
48 fprintf(testf, " image '%s'\n", opt->boot_image_file);
49 fprintf(testf, " initrd '%s'\n", opt->initrd_file);
50 fprintf(testf, " args '%s'\n", opt->boot_args);
54 const char *generic_icon_file(
55 enum generic_icon_type __attribute__((unused)) type)
60 enum generic_icon_type guess_device_type(
61 struct discover_context __attribute__((unused)) *ctx)
63 return ICON_TYPE_UNKNOWN;
66 int main(int argc, char **argv)
68 struct discover_context *ctx;
71 fprintf(stderr, "usage: %s <basedir> <devname>\n", argv[0]);
75 /* Default to test on stdout, pb_log on stderr. */
79 pb_log_set_stream(stderr);
80 pb_log_always_flush(1);
81 pb_log("--- parser-test ---\n");
83 ctx = talloc_zero(NULL, struct discover_context);
85 ctx->device = talloc_zero(ctx, struct discover_device);
86 ctx->device->device = talloc_zero(ctx->device, struct device);
87 ctx->device->device_path = talloc_asprintf(ctx, "%s/%s",
89 ctx->device->device->id = talloc_strdup(ctx->device->device, argv[2]);
93 pb_log("--- end ---\n");