]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: cmd: add test for memsize
authorFrank Wunderlich <frank-w@public-files.de>
Wed, 4 Feb 2026 18:40:43 +0000 (19:40 +0100)
committerTom Rini <trini@konsulko.com>
Sat, 7 Feb 2026 17:51:33 +0000 (11:51 -0600)
Add a test for memsize command in same way as meminfo.

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
cmd/Kconfig
test/cmd/meminfo.c

index f12fcf6631e0ef5234c70ab6160fde39f1fbe96e..8bdd04f348f7d62a8b670de2337003b85ac87583 100644 (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
index 40c3520496ed2f60914200170acd110e2478270d..af2c19fa67d4a727c0e8ae36cf9c8eed32740259 100644 (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