summaryrefslogtreecommitdiffstats
path: root/test/parser
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2019-10-31 17:31:10 +0800
committerJeremy Kerr <jk@ozlabs.org>2019-11-29 13:54:10 +0800
commit61ede5e0bea7d999acfdda9931e5c1f3c13c0694 (patch)
treec04dd631b7fff42b2b6511016b9e056d80102f27 /test/parser
parente558da19475d747e6f8e83d07305d35da33102f9 (diff)
downloadtalos-petitboot-61ede5e0bea7d999acfdda9931e5c1f3c13c0694.tar.gz
talos-petitboot-61ede5e0bea7d999acfdda9931e5c1f3c13c0694.zip
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>
Diffstat (limited to 'test/parser')
-rw-r--r--test/parser/Makefile.am1
-rw-r--r--test/parser/test-grub2-search-args.c33
2 files changed, 34 insertions, 0 deletions
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index 748c836..df9c539 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -29,6 +29,7 @@ parser_TESTS = \
test/parser/test-grub2-multiple-id \
test/parser/test-grub2-single-line-if \
test/parser/test-grub2-pos-param \
+ test/parser/test-grub2-search-args \
test/parser/test-grub2-load-env \
test/parser/test-grub2-save-env \
test/parser/test-grub2-save-env-dash-f \
diff --git a/test/parser/test-grub2-search-args.c b/test/parser/test-grub2-search-args.c
new file mode 100644
index 0000000..ffce853
--- /dev/null
+++ b/test/parser/test-grub2-search-args.c
@@ -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");
+}
OpenPOWER on IntegriCloud