summaryrefslogtreecommitdiffstats
path: root/test/parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/parser')
-rw-r--r--test/parser/Makefile.am3
-rw-r--r--test/parser/test-grub2-default-index.c34
-rw-r--r--test/parser/test-grub2-default-multiword.c30
-rw-r--r--test/parser/test-grub2-default.c27
4 files changed, 94 insertions, 0 deletions
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index fbf9c50..8159bd6 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -28,6 +28,9 @@ LDADD = $(top_builddir)/lib/libpbcore.la libtest.ro
TESTS = \
test-null \
test-grub2-single \
+ test-grub2-default \
+ test-grub2-default-index \
+ test-grub2-default-multiword \
test-grub2-multiple-resolve \
test-grub2-single-line-if \
test-grub2-f18-ppc64 \
diff --git a/test/parser/test-grub2-default-index.c b/test/parser/test-grub2-default-index.c
new file mode 100644
index 0000000..78835cd
--- /dev/null
+++ b/test/parser/test-grub2-default-index.c
@@ -0,0 +1,34 @@
+
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+set default=1
+menuentry 'test-option-0' {
+ linux /vmlinux.0
+}
+menuentry 'test-option-1' {
+ linux /vmlinux.1
+}
+menuentry 'test-option-2' {
+ linux /vmlinux.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, "grub2");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 3);
+ opt = get_boot_option(ctx, 1);
+
+ check_name(opt, "test-option-1");
+ check_resolved_local_resource(opt->boot_image, ctx->device,
+ "/vmlinux.1");
+ check_is_default(opt);
+}
diff --git a/test/parser/test-grub2-default-multiword.c b/test/parser/test-grub2-default-multiword.c
new file mode 100644
index 0000000..f7993fe
--- /dev/null
+++ b/test/parser/test-grub2-default-multiword.c
@@ -0,0 +1,30 @@
+
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+set default="Multiple word option"
+menuentry 'Non-defalt option' {
+ linux /vmlinux.non-default
+}
+menuentry 'Multiple word option' {
+ linux /vmlinux
+}
+#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, "grub2");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 2);
+
+ opt = get_boot_option(ctx, 1);
+ check_name(opt, "Multiple word option");
+ check_resolved_local_resource(opt->boot_image, ctx->device, "/vmlinux");
+ check_is_default(opt);
+}
diff --git a/test/parser/test-grub2-default.c b/test/parser/test-grub2-default.c
new file mode 100644
index 0000000..b3359d0
--- /dev/null
+++ b/test/parser/test-grub2-default.c
@@ -0,0 +1,27 @@
+
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+set default="test-option"
+menuentry 'test-option' {
+ linux /vmlinux
+}
+#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, "grub2");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 1);
+ opt = get_boot_option(ctx, 0);
+
+ check_name(opt, "test-option");
+ check_resolved_local_resource(opt->boot_image, ctx->device, "/vmlinux");
+ check_is_default(opt);
+}
OpenPOWER on IntegriCloud