summaryrefslogtreecommitdiffstats
path: root/test/parser/test-grub2-search-label.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2019-11-04 14:58:01 +0800
committerJeremy Kerr <jk@ozlabs.org>2019-11-29 13:54:10 +0800
commit1580c6557d4e703348edb0dda83814f8972e9f3d (patch)
treee4e47b215814831e3eefd409388c47131ac665d4 /test/parser/test-grub2-search-label.c
parent76e97c5d9dab40236a589cd96a69967d3ef17cab (diff)
downloadtalos-petitboot-1580c6557d4e703348edb0dda83814f8972e9f3d.tar.gz
talos-petitboot-1580c6557d4e703348edb0dda83814f8972e9f3d.zip
discover/grub2: Add support for UUID and label for 'search' command
This change adds support for searching by UUID and filesystem label. We still fall back to passthrough if the UUID is not found, but we now resolve to device ID strings. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test/parser/test-grub2-search-label.c')
-rw-r--r--test/parser/test-grub2-search-label.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/parser/test-grub2-search-label.c b/test/parser/test-grub2-search-label.c
new file mode 100644
index 0000000..b9ee034
--- /dev/null
+++ b/test/parser/test-grub2-search-label.c
@@ -0,0 +1,47 @@
+/* check for grub2 search command, searching by partition label */
+
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+
+# valid label
+search --set=v1 --label testlabel
+
+v2=prev
+# invalid label: does not alter v2
+search --set=v2 --label invalidlabel
+
+menuentry $v1 {
+ linux /vmlinux
+}
+
+menuentry $v2 {
+ linux /vmlinux
+}
+
+#endif
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt;
+ struct discover_context *ctx;
+ struct discover_device *dev;
+
+ ctx = test->ctx;
+
+ dev = test_create_device(test, "testdev");
+ dev->label = "testlabel";
+ device_handler_add_device(test->handler, dev);
+
+ test_read_conf_embedded(test, "/grub/grub.cfg");
+
+ test_run_parser(test, "grub2");
+
+ check_boot_option_count(ctx, 2);
+
+ opt = get_boot_option(ctx, 0);
+ check_name(opt, "testdev");
+
+ opt = get_boot_option(ctx, 1);
+ check_name(opt, "prev");
+}
OpenPOWER on IntegriCloud