summaryrefslogtreecommitdiffstats
path: root/test/parser
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-05-10 15:48:21 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-07-10 14:42:56 +1000
commitd30872fe40c87300e62ef2aea484b9cea618c9de (patch)
tree95aaf70cfc2f04fd4826aeaf9aef9c432cc0db55 /test/parser
parent3ac4c8727c54c020014f0731549c80400476a138 (diff)
downloadtalos-petitboot-d30872fe40c87300e62ef2aea484b9cea618c9de.tar.gz
talos-petitboot-d30872fe40c87300e62ef2aea484b9cea618c9de.zip
discover/pxe-parser: Parse simple iPXE scripts
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'test/parser')
-rw-r--r--test/parser/Makefile.am3
-rw-r--r--test/parser/test-pxe-ipxe-default.c40
-rw-r--r--test/parser/test-pxe-ipxe-named.c39
-rw-r--r--test/parser/test-pxe-ipxe.c40
4 files changed, 122 insertions, 0 deletions
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index 6ff3972..1732158 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -64,6 +64,9 @@ parser_TESTS = \
test/parser/test-pxe-initrd-in-append \
test/parser/test-pxe-mac-without-conf \
test/parser/test-pxe-ip-without-conf \
+ test/parser/test-pxe-ipxe \
+ test/parser/test-pxe-ipxe-named \
+ test/parser/test-pxe-ipxe-default \
test/parser/test-pxe-non-url-conf \
test/parser/test-pxe-local \
test/parser/test-pxe-ipappend \
diff --git a/test/parser/test-pxe-ipxe-default.c b/test/parser/test-pxe-ipxe-default.c
new file mode 100644
index 0000000..d80cc41
--- /dev/null
+++ b/test/parser/test-pxe-ipxe-default.c
@@ -0,0 +1,40 @@
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+#!ipxe
+kernel vmlinux --name test-option
+initrd initrd
+boot
+#endif
+
+/**
+ * Test that we recognise an ipxe-formatted script obtained from bootfile_url
+ * (DHCPv6 option 59) that some vendors use, and that we set it as default.
+ */
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt;
+ struct discover_context *ctx;
+
+ test_read_conf_embedded_url(test, "tftp://host/dir1/conf");
+
+ test_set_event_source(test);
+ test_set_event_param(test->ctx->event, "bootfile_url", "tftp://host/dir1/conf");
+
+ test_run_parser(test, "pxe");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 1);
+ opt = get_boot_option(ctx, 0);
+
+ check_name(opt, "test-option");
+
+ check_resolved_url_resource(opt->boot_image,
+ "tftp://host/dir1/vmlinux");
+ check_resolved_url_resource(opt->initrd,
+ "tftp://host/dir1/initrd");
+ check_args(opt, NULL);
+ check_is_default(opt);
+}
diff --git a/test/parser/test-pxe-ipxe-named.c b/test/parser/test-pxe-ipxe-named.c
new file mode 100644
index 0000000..dae2fc6
--- /dev/null
+++ b/test/parser/test-pxe-ipxe-named.c
@@ -0,0 +1,39 @@
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+#!ipxe
+kernel vmlinux --name test-option append kernel args
+initrd initrd
+#endif
+
+/**
+ * Test that we recognise an ipxe-formatted script obtained from bootfile_url
+ * (DHCPv6 option 59) that some vendors use, and that we correctly parse the
+ * --name parameter from the kernel arguments.
+ */
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt;
+ struct discover_context *ctx;
+
+ test_read_conf_embedded_url(test, "tftp://host/dir1/conf");
+
+ test_set_event_source(test);
+ test_set_event_param(test->ctx->event, "bootfile_url", "tftp://host/dir1/conf");
+
+ test_run_parser(test, "pxe");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 1);
+ opt = get_boot_option(ctx, 0);
+
+ check_name(opt, "test-option");
+
+ check_resolved_url_resource(opt->boot_image,
+ "tftp://host/dir1/vmlinux");
+ check_resolved_url_resource(opt->initrd,
+ "tftp://host/dir1/initrd");
+ check_args(opt, "append kernel args");
+}
diff --git a/test/parser/test-pxe-ipxe.c b/test/parser/test-pxe-ipxe.c
new file mode 100644
index 0000000..e3bc202
--- /dev/null
+++ b/test/parser/test-pxe-ipxe.c
@@ -0,0 +1,40 @@
+
+
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+#!ipxe
+kernel vmlinux append kernel args
+initrd initrd
+#endif
+
+/**
+ * Test that we recognise an ipxe-formatted script obtained from bootfile_url
+ * (DHCPv6 option 59) that some vendors use.
+ */
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt;
+ struct discover_context *ctx;
+
+ test_read_conf_embedded_url(test, "tftp://host/dir1/conf");
+
+ test_set_event_source(test);
+ test_set_event_param(test->ctx->event, "bootfile_url", "tftp://host/dir1/conf");
+
+ test_run_parser(test, "pxe");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 1);
+ opt = get_boot_option(ctx, 0);
+
+ check_name(opt, "ipxe option (tftp://host/dir1/vmlinux)");
+
+ check_resolved_url_resource(opt->boot_image,
+ "tftp://host/dir1/vmlinux");
+ check_resolved_url_resource(opt->initrd,
+ "tftp://host/dir1/initrd");
+ check_args(opt, "append kernel args");
+}
OpenPOWER on IntegriCloud