From 1580c6557d4e703348edb0dda83814f8972e9f3d Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 4 Nov 2019 14:58:01 +0800 Subject: 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 --- test/parser/test-grub2-search-label.c | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/parser/test-grub2-search-label.c (limited to 'test/parser/test-grub2-search-label.c') 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"); +} -- cgit v1.2.1