diff mbox series

[06/27] dm: test: Add support for new sequence numbers

Message ID 20201130015402.2328621-5-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series dm: Change the way sequence numbers are implemented | expand

Commit Message

Simon Glass Nov. 30, 2020, 1:53 a.m. UTC
Tests need to rebuild the driver model data structures to avoid being
affected by the operation of an earlier test. Do the same for the new
bind-time sequence numbers.

Also add a test that the new sequence numbers work as expected. Every
device should get one.

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

 test/dm/core.c      | 19 +++++++++++++++++++
 test/dm/test-main.c |  6 ++++++
 2 files changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/test/dm/core.c b/test/dm/core.c
index 71ebb36d88b..0514813b817 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1066,3 +1066,22 @@  static int dm_test_inactive_child(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_inactive_child, UT_TESTF_SCAN_PDATA);
+
+/* Make sure all bound devices have a sequence number */
+static int dm_test_all_have_seq(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	struct uclass *uc;
+
+	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
+		list_for_each_entry(dev, &uc->dev_head, uclass_node) {
+			if (dev->sqq == -1)
+				printf("Device '%s' has no seq (%d)\n",
+				       dev->name, dev->sqq);
+			ut_assert(dev->sqq != -1);
+		}
+	}
+
+	return 0;
+}
+DM_TEST(dm_test_all_have_seq, UT_TESTF_SCAN_PDATA);
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 4814e186cb7..4ff7a01d5aa 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -88,6 +88,7 @@  static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
 	ut_assertok(dm_test_init(uts, of_live));
 
 	uts->start = mallinfo();
+	gd->flags |= GD_FLG_DM_NO_SEQ;
 	if (test->flags & UT_TESTF_SCAN_PDATA)
 		ut_assertok(dm_scan_platdata(false));
 	if (test->flags & UT_TESTF_PROBE_TEST)
@@ -95,6 +96,8 @@  static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
 	if (!CONFIG_IS_ENABLED(OF_PLATDATA) &&
 	    (test->flags & UT_TESTF_SCAN_FDT))
 		ut_assertok(dm_extended_scan(false));
+	uclass_alloc_all_seqs();
+	gd->flags &= ~GD_FLG_DM_NO_SEQ;
 
 	/*
 	 * Silence the console and rely on console recording to get
@@ -208,12 +211,15 @@  int dm_test_main(const char *test_name)
 		printf("Failures: %d\n", uts->fail_count);
 
 	/* Put everything back to normal so that sandbox works as expected */
+	gd->flags |= GD_FLG_DM_NO_SEQ;
 	gd_set_of_root(uts->of_root);
 	gd->dm_root = NULL;
 	ut_assertok(dm_init(CONFIG_IS_ENABLED(OF_LIVE)));
 	dm_scan_platdata(false);
 	if (!CONFIG_IS_ENABLED(OF_PLATDATA))
 		dm_scan_fdt(false);
+	uclass_alloc_all_seqs();
+	gd->flags &= ~GD_FLG_DM_NO_SEQ;
 
 	return uts->fail_count ? CMD_RET_FAILURE : 0;
 }