summaryrefslogtreecommitdiffstats
path: root/test/parser-test.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-12-15 15:22:34 +1100
committerJeremy Kerr <jk@ozlabs.org>2008-12-15 15:22:34 +1100
commit32e6a41f33e5576716b351bd473a27939fe94fa1 (patch)
tree0d6b75ac0a02d2496416095405cb9498777c3beb /test/parser-test.c
parent000a92b4fa909c432732ac3ed8f28eeeaeac70ee (diff)
downloadtalos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.tar.gz
talos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.zip
Initial support for multiple UIs
Move the device discovery code from separate udev helpers to a single process to listen on two sockets: one SOCK_DGRAM for incoming udev events, and one SOCK_STREAM for UIs to connect. Initial support for client/server infrastructure, still need to wire-up the udev messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test/parser-test.c')
-rw-r--r--test/parser-test.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/parser-test.c b/test/parser-test.c
new file mode 100644
index 0000000..8c94d3f
--- /dev/null
+++ b/test/parser-test.c
@@ -0,0 +1,85 @@
+#define _GNU_SOURCE
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "parser.h"
+#include "paths.h"
+
+void pb_log(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+int mount_device(const char *dev_path)
+{
+ printf("[mount] %s\n", dev_path);
+ return 0;
+}
+
+static int device_idx;
+static int option_idx;
+
+int add_device(const struct device *dev)
+{
+ printf("[dev %2d] id: %s\n", device_idx, dev->id);
+ printf("[dev %2d] name: %s\n", device_idx, dev->name);
+ printf("[dev %2d] description: %s\n", device_idx, dev->description);
+ printf("[dev %2d] boot_image: %s\n", device_idx, dev->icon_file);
+
+ device_idx++;
+ option_idx = 0;
+ return 0;
+}
+
+
+int add_boot_option(const struct boot_option *opt)
+{
+ if (!device_idx) {
+ fprintf(stderr, "Option (%s) added before device\n",
+ opt->name);
+ exit(EXIT_FAILURE);
+ }
+
+ printf("[opt %2d] name: %s\n", option_idx, opt->name);
+ printf("[opt %2d] description: %s\n", option_idx, opt->description);
+ printf("[opt %2d] boot_image: %s\n", option_idx, opt->boot_image_file);
+ printf("[opt %2d] initrd: %s\n", option_idx, opt->initrd_file);
+ printf("[opt %2d] boot_args: %s\n", option_idx, opt->boot_args);
+
+ option_idx++;
+
+ return 0;
+}
+
+enum generic_icon_type guess_device_type(void)
+{
+ return ICON_TYPE_UNKNOWN;
+}
+
+int main(int argc, char **argv)
+{
+ char *mountpoint, *dev;
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s <basedir> <devname>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ mountpoint = argv[1];
+ dev = argv[2];
+
+ set_mount_base(mountpoint);
+
+ iterate_parsers(dev, mountpoint);
+
+
+ return EXIT_SUCCESS;
+}
OpenPOWER on IntegriCloud