mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 20:56:12 +02:00
test: add tests for left-bracket alias for 'test' command
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@prevas.dk> Tested-by: Anshul Dalal <anshuld@ti.com>
This commit is contained in:
parent
d44f615829
commit
6f9cc3310a
@ -315,3 +315,46 @@ 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));
|
||||
|
||||
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);
|
||||
|
||||
sprintf(if_formatted, if_format, "[ aaa != aaa -o bbb != bbb ]");
|
||||
ut_asserteq(1, run_command(if_formatted, 0));
|
||||
|
||||
sprintf(if_formatted, if_format, "[ aaa != aaa -o bbb = bbb ]");
|
||||
ut_assertok(run_command(if_formatted, 0));
|
||||
|
||||
sprintf(if_formatted, if_format, "[ ! aaa != aaa -o ! bbb != bbb ]");
|
||||
ut_assertok(run_command(if_formatted, 0));
|
||||
|
||||
sprintf(if_formatted, if_format, "[ ! aaa != aaa -o ! bbb = bbb ]");
|
||||
ut_assertok(run_command(if_formatted, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
HUSH_TEST(hush_test_lbracket_alias, UTF_CONSOLE);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user