diff mbox series

[v2,03/21] test: dm: Add a case to test ofnode_phy_is_fixed_link()

Message ID 20210312133602.31105-4-bmeng.cn@gmail.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series ppc: qemu: Add eTSEC support | expand

Commit Message

Bin Meng March 12, 2021, 1:35 p.m. UTC
This adds a test case to test the new ofnode_phy_is_fixed_link() API.
Both the new and old DT bindings are covered.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/sandbox/dts/test.dts | 11 +++++++++++
 test/dm/of_extra.c        | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)

Comments

Vladimir Oltean March 13, 2021, 1:13 p.m. UTC | #1
On Fri, Mar 12, 2021 at 09:35:44PM +0800, Bin Meng wrote:
> This adds a test case to test the new ofnode_phy_is_fixed_link() API.
> Both the new and old DT bindings are covered.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---

The DSA sandbox patch adds three fixed-link nodes already. Can't you
convert one of those three fixed-link nodes to an old-style binding, and
modify your test case to cover those existing nodes?
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 2600360224..995c93c95a 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -478,6 +478,17 @@ 
 		fake-host-hwaddr = [00 00 66 44 22 22];
 	};
 
+	fixed-link-test1 {
+		fixed-link {
+			speed = <1000>;
+			full-duplex;
+		};
+	};
+
+	fixed-link-test2 {
+		fixed-link = <0 1 1000 0 0>;
+	};
+
 	firmware {
 		sandbox_firmware: sandbox-firmware {
 			compatible = "sandbox,firmware";
diff --git a/test/dm/of_extra.c b/test/dm/of_extra.c
index b19cd3787d..d7c584fa33 100644
--- a/test/dm/of_extra.c
+++ b/test/dm/of_extra.c
@@ -36,3 +36,21 @@  static int dm_test_ofnode_read_fmap_entry(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_read_fmap_entry, 0);
+
+static int dm_test_ofnode_phy_is_fixed_link(struct unit_test_state *uts)
+{
+	ofnode eth_node, phy_node, node;
+
+	eth_node = ofnode_path("/fixed-link-test1");
+	ut_assert(ofnode_phy_is_fixed_link(eth_node, &phy_node));
+	node = ofnode_path("/fixed-link-test1/fixed-link");
+	ut_asserteq_mem(&phy_node, &node, sizeof(ofnode));
+
+	eth_node = ofnode_path("/fixed-link-test2");
+	ut_assert(ofnode_phy_is_fixed_link(eth_node, &phy_node));
+	node = eth_node;
+	ut_asserteq_mem(&phy_node, &node, sizeof(ofnode));
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_phy_is_fixed_link, 0);