Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
discover/grub2: Use getopt for
search
argument parsing
The search command will be extended to add the full set of grub2-style arguments, so switch to using getopt, rather than manual parsing. This means we now support `--set=foo` and `--set foo` style arguments, both of which appear in the docs and common grub configs. Also, add a small test for the search argument handling. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
- Loading branch information
Showing
3 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
/* check for multiple styles of option parsing for the 'search' command */ | ||
|
||
#include "parser-test.h" | ||
|
||
#if 0 /* PARSER_EMBEDDED_CONFIG */ | ||
|
||
# no --set arugment will set the 'root' var | ||
search a | ||
search --set=v1 b | ||
search --set v2 c | ||
|
||
menuentry $root$v1$v2 { | ||
linux /vmlinux | ||
} | ||
|
||
#endif | ||
|
||
void run_test(struct parser_test *test) | ||
{ | ||
struct discover_boot_option *opt; | ||
struct discover_context *ctx; | ||
|
||
ctx = test->ctx; | ||
|
||
test_read_conf_embedded(test, "/grub/grub.cfg"); | ||
|
||
test_run_parser(test, "grub2"); | ||
|
||
check_boot_option_count(ctx, 1); | ||
opt = get_boot_option(ctx, 0); | ||
check_name(opt, "abc"); | ||
} |