[PATCH v2 34/40] test: Allow SPL to run any available test
Simon Glass
sjg at chromium.org
Sun Jan 31 04:32:42 CET 2021
At present SPL only runs driver model tests. Update it to run all
available tests, i.e. in any test suite.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 7 +++++--
include/test/test.h | 16 +++++-----------
test/dm/test-dm.c | 11 ++++++++++-
3 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index fa5055bb9fc..3ef612ea9c2 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -12,7 +12,7 @@
#include <spl.h>
#include <asm/spl.h>
#include <asm/state.h>
-#include <test/test.h>
+#include <test/ut.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -58,9 +58,12 @@ void spl_board_init(void)
preloader_console_init();
if (state->run_unittests) {
+ struct unit_test *tests = UNIT_TEST_ALL_START();
+ const int count = UNIT_TEST_ALL_COUNT();
int ret;
- ret = dm_test_run(state->select_unittests);
+ ret = ut_run_list("spl", NULL, tests, count,
+ state->select_unittests);
/* continue execution into U-Boot */
}
}
diff --git a/include/test/test.h b/include/test/test.h
index 3330dcc72d3..0b124edd601 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -99,6 +99,11 @@ struct unit_test {
#define UNIT_TEST_SUITE_COUNT(_suite) \
ll_entry_count(struct unit_test, ut_ ## _suite)
+/* Use ! and ~ so that all tests will be sorted between these two values */
+#define UNIT_TEST_ALL_START() ll_entry_start(struct unit_test, ut_!)
+#define UNIT_TEST_ALL_END() ll_entry_start(struct unit_test, ut_~)
+#define UNIT_TEST_ALL_COUNT() (UNIT_TEST_ALL_END() - UNIT_TEST_ALL_START())
+
/* Sizes for devres tests */
enum {
TEST_DEVRES_SIZE = 100,
@@ -119,15 +124,4 @@ enum {
*/
struct udevice *testbus_get_clear_removed(void);
-/**
- * dm_test_run() - Run driver model tests
- *
- * Run all the available driver model tests, or a selection
- *
- * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just
- * "fdt_pre_reloc"), or NULL to run all
- * @return 0 if all tests passed, 1 if not
- */
-int dm_test_run(const char *test_name);
-
#endif /* __TEST_TEST_H */
diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c
index f1f1b0f0149..a23ea232463 100644
--- a/test/dm/test-dm.c
+++ b/test/dm/test-dm.c
@@ -19,7 +19,16 @@
DECLARE_GLOBAL_DATA_PTR;
-int dm_test_run(const char *test_name)
+/**
+ * dm_test_run() - Run driver model tests
+ *
+ * Run all the available driver model tests, or a selection
+ *
+ * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just
+ * "fdt_pre_reloc"), or NULL to run all
+ * @return 0 if all tests passed, 1 if not
+ */
+static int dm_test_run(const char *test_name)
{
struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test);
const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test);
--
2.30.0.365.g02bc693789-goog
More information about the U-Boot
mailing list