diff mbox series

[v2,08/11] sandbox: Allow selection of SPL unit tests

Message ID 20201026023836.1629465-9-sjg@chromium.org
State Accepted
Commit 22b29cc8fb15f611e8e2af6fde8627a32abea76d
Delegated to: Simon Glass
Headers show
Series dm: test: Add unit tests for SPL | expand

Commit Message

Simon Glass Oct. 26, 2020, 2:38 a.m. UTC
Now that we have more than one test, add a way to select the test to run.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/sandbox/cpu/spl.c           | 2 +-
 arch/sandbox/cpu/start.c         | 9 +++++++++
 arch/sandbox/include/asm/state.h | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

Comments

Simon Glass Oct. 30, 2020, 3:34 a.m. UTC | #1
Now that we have more than one test, add a way to select the test to run.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/sandbox/cpu/spl.c           | 2 +-
 arch/sandbox/cpu/start.c         | 9 +++++++++
 arch/sandbox/include/asm/state.h | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 48fd1265afe..81b217a1d70 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -72,7 +72,7 @@  void spl_board_init(void)
 	if (state->run_unittests) {
 		int ret;
 
-		ret = dm_test_main(NULL);
+		ret = dm_test_main(state->select_unittests);
 		/* continue execution into U-Boot */
 	}
 }
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index f5e104b127b..569dafbcfee 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -383,6 +383,15 @@  static int sandbox_cmdline_cb_unittests(struct sandbox_state *state,
 }
 SANDBOX_CMDLINE_OPT_SHORT(unittests, 'u', 0, "Run unit tests");
 
+static int sandbox_cmdline_cb_select_unittests(struct sandbox_state *state,
+					       const char *arg)
+{
+	state->select_unittests = arg;
+
+	return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(select_unittests, 'k', 1, "Select unit tests to run");
+
 static void setup_ram_buf(struct sandbox_state *state)
 {
 	/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index f828d9d2447..7547602dd1c 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -93,6 +93,7 @@  struct sandbox_state {
 	bool show_of_platdata;		/* Show of-platdata in SPL */
 	bool ram_buf_read;		/* true if we read the RAM buffer */
 	bool run_unittests;		/* Run unit tests */
+	const char *select_unittests;	/* Unit test to run */
 
 	/* Pointer to information for each SPI bus/cs */
 	struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]