mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-08 14:14:32 +00:00
401d1c4f5d
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Tests for echo command
|
|
*
|
|
* Copyright 2020, Heinrich Schuchadt <xypron.glpk@gmx.de>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <command.h>
|
|
#include <asm/global_data.h>
|
|
#include <display_options.h>
|
|
#include <test/lib.h>
|
|
#include <test/test.h>
|
|
#include <test/ut.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
struct test_data {
|
|
char *cmd;
|
|
char *expected;
|
|
};
|
|
|
|
static struct test_data echo_data[] = {
|
|
{"echo 1 2 3",
|
|
"1 2 3"},
|
|
/* Test new line handling */
|
|
{"echo -n 1 2 3; echo a b c",
|
|
"1 2 3a b c"},
|
|
/*
|
|
* Test handling of environment variables.
|
|
*
|
|
* j, q, x are among the least frequent letters in English.
|
|
* Hence no collision for the variable name jQx is expected.
|
|
*/
|
|
{"setenv jQx X; echo \"a)\" ${jQx} 'b)' '${jQx}' c) ${jQx}; setenv jQx",
|
|
"a) X b) ${jQx} c) X"},
|
|
/* Test handling of shell variables. */
|
|
{"setenv jQx; for jQx in 1 2 3; do echo -n \"${jQx}, \"; done; echo;",
|
|
"1, 2, 3, "},
|
|
};
|
|
|
|
static int lib_test_hush_echo(struct unit_test_state *uts)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(echo_data); ++i) {
|
|
console_record_reset_enable();
|
|
ut_assertok(run_command(echo_data[i].cmd, 0));
|
|
gd->flags &= ~GD_FLG_RECORD;
|
|
console_record_readline(uts->actual_str,
|
|
sizeof(uts->actual_str));
|
|
ut_asserteq_str(echo_data[i].expected, uts->actual_str);
|
|
ut_assertok(ut_check_console_end(uts));
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
LIB_TEST(lib_test_hush_echo, 0);
|