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 struct discover_device *device_lookup_by_name(
39 struct device_handler *handler __attribute__((unused)),
40 const char *name __attribute__((unused)))
45 struct discover_device *device_lookup_by_label(
46 struct device_handler *handler __attribute__((unused)),
47 const char *label __attribute__((unused)))
52 struct discover_device *device_lookup_by_uuid(
53 struct device_handler *handler __attribute__((unused)),
54 const char *uuid __attribute__((unused)))
60 void discover_context_add_boot_option(struct discover_context *ctx,
61 struct discover_boot_option *boot_option)
63 struct boot_option *opt = boot_option->option;
65 fprintf(testf, "%s: %s\n", __func__, ctx->device->device->id);
66 fprintf(testf, " id '%s'\n", opt->id);
67 fprintf(testf, " name '%s'\n", opt->name);
68 fprintf(testf, " descr '%s'\n", opt->description);
69 fprintf(testf, " icon '%s'\n", opt->icon_file);
70 fprintf(testf, " image '%s'\n", opt->boot_image_file);
71 fprintf(testf, " initrd '%s'\n", opt->initrd_file);
72 fprintf(testf, " args '%s'\n", opt->boot_args);
76 const char *generic_icon_file(
77 enum generic_icon_type __attribute__((unused)) type)
82 enum generic_icon_type guess_device_type(
83 struct discover_context __attribute__((unused)) *ctx)
85 return ICON_TYPE_UNKNOWN;
88 int main(int argc, char **argv)
90 struct discover_context *ctx;
93 fprintf(stderr, "usage: %s <basedir> <devname>\n", argv[0]);
97 /* Default to test on stdout, pb_log on stderr. */
101 pb_log_set_stream(stderr);
102 pb_log_always_flush(1);
103 pb_log("--- parser-test ---\n");
105 ctx = talloc_zero(NULL, struct discover_context);
107 ctx->device = talloc_zero(ctx, struct discover_device);
108 ctx->device->device = talloc_zero(ctx->device, struct device);
109 ctx->device->mount_path = talloc_asprintf(ctx, "%s/%s",
111 ctx->device->device->id = talloc_strdup(ctx->device->device, argv[2]);
113 iterate_parsers(ctx);
115 pb_log("--- end ---\n");