test: cmd: add test for memsize

Add a test for memsize command in same way as meminfo.

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
This commit is contained in:
Frank Wunderlich
2026-02-04 19:40:43 +01:00
committed by Tom Rini
parent e202eca183
commit 8acc8a6546
2 changed files with 21 additions and 0 deletions

View File

@@ -942,6 +942,7 @@ config CMD_MEMINFO_MAP
config CMD_MEMSIZE
bool "memsize"
default y if SANDBOX
depends on CMD_MEMINFO
help
Get RAM via command for use in scripts. Print or assign decimal value

View File

@@ -7,6 +7,7 @@
*/
#include <dm/test.h>
#include <env.h>
#include <test/cmd.h>
#include <test/ut.h>
@@ -39,4 +40,23 @@ static int cmd_test_meminfo(struct unit_test_state *uts)
return 0;
}
CMD_TEST(cmd_test_meminfo, UTF_CONSOLE);
/* Test 'memsize' command */
#ifdef CONFIG_CMD_MEMSIZE
static int cmd_test_memsize(struct unit_test_state *uts)
{
ut_assertok(run_command("memsize", 0));
ut_assert_nextline("256 MiB");
ut_assert_console_end();
ut_assertok(run_command("memsize memsz", 0));
ut_asserteq_str("256", env_get("memsz"));
ut_assert_console_end();
return 0;
}
CMD_TEST(cmd_test_memsize, UTF_CONSOLE);
#endif