dm: core: Add tests for dev_read_alias_highest_id()
authorMichal Simek <michal.simek@xilinx.com>
Thu, 31 Jan 2019 15:31:00 +0000 (16:31 +0100)
committerHeiko Schocher <hs@denx.de>
Fri, 8 Feb 2019 05:25:49 +0000 (06:25 +0100)
It is checking the highest alias ID for eth, gpio, pci, i2c and error
code on non existing alias.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/dm/test-fdt.c

index 984b80c02c8104280aad2ef7f61b2b4530e5ccf4..be16c99e170eb6e1783ec5cd4b42a2d623a747ae 100644 (file)
@@ -219,6 +219,29 @@ static int dm_test_fdt(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_fdt, 0);
 
+static int dm_test_alias_highest_id(struct unit_test_state *uts)
+{
+       int ret;
+
+       ret = dev_read_alias_highest_id("eth");
+       ut_asserteq(5, ret);
+
+       ret = dev_read_alias_highest_id("gpio");
+       ut_asserteq(2, ret);
+
+       ret = dev_read_alias_highest_id("pci");
+       ut_asserteq(2, ret);
+
+       ret = dev_read_alias_highest_id("i2c");
+       ut_asserteq(0, ret);
+
+       ret = dev_read_alias_highest_id("deadbeef");
+       ut_asserteq(-1, ret);
+
+       return 0;
+}
+DM_TEST(dm_test_alias_highest_id, 0);
+
 static int dm_test_fdt_pre_reloc(struct unit_test_state *uts)
 {
        struct uclass *uc;