[PATCH 2/3] test: add tests for left-bracket alias for 'test' command
Simon Glass
sjg at chromium.org
Mon Mar 16 03:43:49 CET 2026
Hi Rasmus,
On Wed, 11 Mar 2026 at 06:09, Rasmus Villemoes <ravi at prevas.dk> wrote:
>
> Duplicate a few of the existing test cases, using the [ spelling, and
> also ensure that the presence of a matching ] as a separate and last
> argument is enforced.
>
> Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
> ---
> test/hush/if.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/test/hush/if.c b/test/hush/if.c
> index ea615b246a9..148e9a53e90 100644
> --- a/test/hush/if.c
> +++ b/test/hush/if.c
> @@ -315,3 +315,34 @@ static int hush_test_if_z_operator(struct unit_test_state *uts)
> return 0;
> }
> HUSH_TEST(hush_test_if_z_operator, 0);
> +
> +static int hush_test_lbracket_alias(struct unit_test_state *uts)
> +{
> + char if_formatted[128];
> + const char *missing_rbracket_error = "[: missing terminating ]";
> +
> + sprintf(if_formatted, if_format, "[ aaa = aaa ]");
> + ut_assertok(run_command(if_formatted, 0));
How about using run_commandf() so you can do this in one line? Looks
good apart from that.
> +
> + sprintf(if_formatted, if_format, "[ aaa = bbb ]");
> + ut_asserteq(1, run_command(if_formatted, 0));
> +
> + sprintf(if_formatted, if_format, "[ aaa = aaa");
> + ut_asserteq(1, run_command(if_formatted, 0));
> + ut_assert_nextline(missing_rbracket_error);
> +
> + sprintf(if_formatted, if_format, "[ aaa = bbb");
> + ut_asserteq(1, run_command(if_formatted, 0));
> + ut_assert_nextline(missing_rbracket_error);
> +
> + sprintf(if_formatted, if_format, "[ aaa = aaa]");
> + ut_asserteq(1, run_command(if_formatted, 0));
> + ut_assert_nextline(missing_rbracket_error);
> +
> + sprintf(if_formatted, if_format, "[ aaa = bbb]");
> + ut_asserteq(1, run_command(if_formatted, 0));
> + ut_assert_nextline(missing_rbracket_error);
> +
> + return 0;
> +}
> +HUSH_TEST(hush_test_lbracket_alias, UTF_CONSOLE);
> --
> 2.53.0
>
Regards,
Simon
More information about the U-Boot
mailing list