aboutsummaryrefslogtreecommitdiff
path: root/test/dm/test-fdt.c
diff options
context:
space:
mode:
authorSimon Glass2020-12-16 21:20:27 -0700
committerSimon Glass2020-12-18 20:32:21 -0700
commit93f44e8a8c8c7878c76d3415f1d425d4fa418287 (patch)
tree9477adec99460b27cdc1fa95c5e0d9ad14f90a20 /test/dm/test-fdt.c
parent981426e350801f2de93f385a371270f27dfeeb14 (diff)
dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ
Check that this flag operates as expected. This patch is not earlier in this series since is uses the new behaviour of dev_seq(). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/test-fdt.c')
-rw-r--r--test/dm/test-fdt.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index f73cc33d9be..87e09f19cd1 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -126,6 +126,23 @@ UCLASS_DRIVER(testfdt) = {
.flags = DM_UC_FLAG_SEQ_ALIAS,
};
+static const struct udevice_id testfdtm_ids[] = {
+ { .compatible = "denx,u-boot-fdtm-test" },
+ { }
+};
+
+U_BOOT_DRIVER(testfdtm_drv) = {
+ .name = "testfdtm_drv",
+ .of_match = testfdtm_ids,
+ .id = UCLASS_TEST_FDT_MANUAL,
+};
+
+UCLASS_DRIVER(testfdtm) = {
+ .name = "testfdtm",
+ .id = UCLASS_TEST_FDT_MANUAL,
+ .flags = DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
+};
+
struct dm_testprobe_pdata {
int probe_err;
};
@@ -399,6 +416,31 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
}
DM_TEST(dm_test_fdt_uclass_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+/* More tests for sequence numbers */
+static int dm_test_fdt_uclass_seq_manual(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ /*
+ * Since DM_UC_FLAG_NO_AUTO_SEQ is set for this uclass, only testfdtm1
+ * should get a sequence number assigned
+ */
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT_MANUAL, 0, &dev));
+ ut_asserteq_str("testfdtm0", dev->name);
+ ut_asserteq(-1, dev_seq(dev));
+
+ ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT_MANUAL, 1, &dev));
+ ut_asserteq_str("testfdtm1", dev->name);
+ ut_asserteq(1, dev_seq(dev));
+
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT_MANUAL, 2, &dev));
+ ut_asserteq_str("testfdtm2", dev->name);
+ ut_asserteq(-1, dev_seq(dev));
+
+ return 0;
+}
+DM_TEST(dm_test_fdt_uclass_seq_manual, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
/* Test that we can find a device by device tree offset */
static int dm_test_fdt_offset(struct unit_test_state *uts)
{