public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Frank Wunderlich <linux@fw-web.de>
To: Tom Rini <trini@konsulko.com>
Cc: Frank Wunderlich <frank-w@public-files.de>,
	u-boot@lists.denx.de, Daniel Golle <daniel@makrotopia.org>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH v7 2/3] test: cmd: add test for memsize
Date: Wed,  4 Feb 2026 19:40:43 +0100	[thread overview]
Message-ID: <20260204184045.111808-3-linux@fw-web.de> (raw)
In-Reply-To: <20260204184045.111808-1-linux@fw-web.de>

From: Frank Wunderlich <frank-w@public-files.de>

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

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
v7: guard test with config option

tested via:
$ ./u-boot -T -c "ut cmd cmd_test_memsize"
...
Test: memsize: meminfo.c
Tests run: 1, 0 ms, average: 0 ms, failures: 0
---
 cmd/Kconfig        |  1 +
 test/cmd/meminfo.c | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2717cbad5f1e..f16397238b3e 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -927,6 +927,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
diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c
index 53b41e3b49e0..a199c1dc3c74 100644
--- a/test/cmd/meminfo.c
+++ b/test/cmd/meminfo.c
@@ -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
-- 
2.43.0


  parent reply	other threads:[~2026-02-04 18:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 18:40 [PATCH v7 0/3] Add command for getting ramsize in scripts Frank Wunderlich
2026-02-04 18:40 ` [PATCH v7 1/3] cmd: mem: add command for getting ram size for use " Frank Wunderlich
2026-02-04 18:40 ` Frank Wunderlich [this message]
2026-02-04 18:40 ` [PATCH v7 3/3] doc: cmd: add usage doc for memsize Frank Wunderlich
2026-02-08  0:27 ` [PATCH v7 0/3] Add command for getting ramsize in scripts Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260204184045.111808-3-linux@fw-web.de \
    --to=linux@fw-web.de \
    --cc=daniel@makrotopia.org \
    --cc=frank-w@public-files.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox