diff options
author | Simon Glass <sjg@chromium.org> | 2023-10-25 07:17:36 +1300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-11-01 12:26:44 -0400 |
commit | 19248dcec53d19184ce1207962edd54109d28b01 (patch) | |
tree | de9df100693120473e7275c0c8f2bb16ac8aaa9a /test/boot/bootflow.c | |
parent | f2bfa0cb17948aa4a0fa20fdf9014296b9c4d9c7 (diff) |
bootstd: Handle a few special cases in cmdline_set_arg()
Two bugs have appeared:
- arguments can have an equals sign embedded in them, which must be
considered part of the value
- arguments must fully match the name; partial matches should be
ignored
Fix these and add a test to cover both.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/boot/bootflow.c')
-rw-r--r-- | test/boot/bootflow.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index f5b2059140..f640db8a24 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -973,6 +973,26 @@ static int bootflow_cmdline(struct unit_test_state *uts) } BOOTSTD_TEST(bootflow_cmdline, 0); +/* test a few special changes to a long command line */ +static int bootflow_cmdline_special(struct unit_test_state *uts) +{ + char buf[500]; + int pos; + + /* + * check handling of an argument which has an embedded '=', as well as + * handling of a argument which partially matches ("ro" and "root") + */ + ut_asserteq(32, cmdline_set_arg( + buf, sizeof(buf), + "loglevel=7 root=PARTUUID=d68352e3 rootwait ro noinitrd", + "root", NULL, &pos)); + ut_asserteq_str("loglevel=7 rootwait ro noinitrd", buf); + + return 0; +} +BOOTSTD_TEST(bootflow_cmdline_special, 0); + /* Test ChromiumOS bootmeth */ static int bootflow_cros(struct unit_test_state *uts) { |