[PATCH 17/30] test: Move delay skipping to test_pre_run()
Simon Glass
sjg at chromium.org
Thu Jan 28 16:11:58 CET 2021
This allows delays to be skipped in sandbox tests. Move it to the
common pre-init function.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
include/test/ut.h | 11 +++++++++++
test/dm/test-dm.c | 2 --
test/test-main.c | 2 ++
test/ut.c | 7 +++++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/include/test/ut.h b/include/test/ut.h
index 7cb5e10f3af..e5ec18e60b0 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -356,6 +356,17 @@ void ut_silence_console(struct unit_test_state *uts);
*/
void ut_unsilence_console(struct unit_test_state *uts);
+/**
+ * ut_set_skip_delays() - Sets whether delays should be skipped
+ *
+ * Normally functions like mdelay() cause U-Boot to wait for a while. This
+ * allows all such delays to be skipped on sandbox, to speed up tests
+ *
+ * @uts: Test state (in case in future we want to keep state here)
+ * @skip_delays: true to skip delays, false to process them normally
+ */
+void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays);
+
/**
* test_pre_run() - Handle any preparation needed to run a test
*
diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c
index 3ffbc382358..398216b6c76 100644
--- a/test/dm/test-dm.c
+++ b/test/dm/test-dm.c
@@ -77,8 +77,6 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
ut_assertok(test_post_run(uts, test));
- state_set_skip_delays(false);
-
ut_assertok(dm_test_destroy(uts));
return 0;
diff --git a/test/test-main.c b/test/test-main.c
index e273777b6e2..6f0d32f7e27 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -30,6 +30,8 @@ static int do_autoprobe(struct unit_test_state *uts)
int test_pre_run(struct unit_test_state *uts, struct unit_test *test)
{
+ ut_set_skip_delays(uts, false);
+
uts->start = mallinfo();
if (test->flags & UT_TESTF_SCAN_PDATA)
diff --git a/test/ut.c b/test/ut.c
index 44ed1ba2d31..e18d85e556c 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -132,3 +132,10 @@ void ut_unsilence_console(struct unit_test_state *uts)
{
gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
}
+
+void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays)
+{
+#ifdef CONFIG_SANDBOX
+ state_set_skip_delays(skip_delays);
+#endif
+}
--
2.30.0.280.ga3ce27912f-goog
More information about the U-Boot
mailing list