Skip to contentSkip to conversation

test/py: mii: Add tests for mii command

PATCH Superseded Love Kumar 2 participants 3 messages Nov 21, 2023

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Love Kumar

author
#0 lore raw

PATCH 1/1 test/py: mii: Add tests for mii command

Add below test cases for mii commands:
mii_info -To display MII PHY info
mii_list - To list MII devices
mii_set_device - To set MII device
mii_read - To reads register from MII PHY address
mii_dump - To display data from MII PHY address

---
 test/py/tests/test_mii.py | 68 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 test/py/tests/test_mii.py
test/py/tests/test_mii.py new file +68 -0
new file mode 100644
index 000000000000..b213df3e3f2e
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: GPL-2.0
+# (C) Copyright 2023, Advanced Micro Devices, Inc.
+
+import pytest
+import re
+
+"""
+Note: This test doesn't rely on boardenv_* configuration value but they can
+change test behavior.
+
+For example:
+
+# Setup env__mii_deive_test_skip to True if tests with ethernet PHY devices
+# should be skipped. For example: Missing PHY device
+env__mii_device_test_skip = True
+
+It also checks for MII PHY device exist or not, it skips the test if PHY device
+does not exist.
+"""
+
[email protected]("cmd_mii")
+def test_mii_info(u_boot_console):
+    if u_boot_console.config.env.get("env__mii_device_test_skip", False):
+        pytest.skip("MII device test is not enabled!")
+    expected_output = "PHY"
+    output = u_boot_console.run_command("mii info")
+    if not re.search(r"PHY (.+?):", output):
+        pytest.skip("PHY device does not exist!")
+    assert expected_output in output
+
[email protected]("cmd_mii")
+def test_mii_list(u_boot_console):
+    if u_boot_console.config.env.get("env__mii_device_test_skip", False):
+        pytest.skip("MII device test is not enabled!")
+    expected_output = "Current device"
+    output = u_boot_console.run_command("mii device")
+    if not re.search(r"Current device: '(.+?)'", output):
+        pytest.skip("PHY device does not exist!")
+    assert expected_output in output
+
[email protected]("cmd_mii")
+def test_mii_set_device(u_boot_console):
+    test_mii_list(u_boot_console)
+    output = u_boot_console.run_command("mii device")
+    eth_num = re.search(r"MII devices: '(.+?)'", output).groups()[0]
+    u_boot_console.run_command(f"mii device {eth_num}")
+    output = u_boot_console.run_command("echo $?")
+    assert output.endswith("0")
+
[email protected]("cmd_mii")
+def test_mii_read(u_boot_console):
+    test_mii_list(u_boot_console)
+    output = u_boot_console.run_command("mii info")
+    eth_addr = hex(int(re.search(r"PHY (.+?):", output).groups()[0], 16))
+    u_boot_console.run_command(f"mii read {eth_addr} 0")
+    output = u_boot_console.run_command("echo $?")
+    assert output.endswith("0")
+
[email protected]("cmd_mii")
+def test_mii_dump(u_boot_console):
+    test_mii_list(u_boot_console)
+    expected_response = "PHY control register"
+    output = u_boot_console.run_command("mii info")
+    eth_addr = hex(int(re.search(r"PHY (.+?):", output).groups()[0], 16))
+    response = u_boot_console.run_command(f"mii dump {eth_addr} 0")
+    assert expected_response in response
+    output = u_boot_console.run_command("echo $?")
+    assert output.endswith("0")
Signature · 1 line
2.25.1
#1 lore raw
Quoted 56 lines · Love Kumar

Add below test cases for mii commands:
mii_info -To display MII PHY info
mii_list - To list MII devices
mii_set_device - To set MII device
mii_read - To reads register from MII PHY address
mii_dump - To display data from MII PHY address

---
 test/py/tests/test_mii.py | 68 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 test/py/tests/test_mii.py
test/py/tests/test_mii.py new file +37 -0
new file mode 100644
index 000000000000..b213df3e3f2e
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: GPL-2.0
+# (C) Copyright 2023, Advanced Micro Devices, Inc.
+
+import pytest
+import re
+
+"""
+Note: This test doesn't rely on boardenv_* configuration value but they can
+change test behavior.
+
+For example:
+
+# Setup env__mii_deive_test_skip to True if tests with ethernet PHY devices
+# should be skipped. For example: Missing PHY device
+env__mii_device_test_skip = True
+
+It also checks for MII PHY device exist or not, it skips the test if PHY device
+does not exist.
+"""
+
[email protected]("cmd_mii")
+def test_mii_info(u_boot_console):
+    if u_boot_console.config.env.get("env__mii_device_test_skip", False):
+        pytest.skip("MII device test is not enabled!")
+    expected_output = "PHY"
+    output = u_boot_console.run_command("mii info")
+    if not re.search(r"PHY (.+?):", output):
+        pytest.skip("PHY device does not exist!")
+    assert expected_output in output
+
[email protected]("cmd_mii")
+def test_mii_list(u_boot_console):
+    if u_boot_console.config.env.get("env__mii_device_test_skip", False):
+        pytest.skip("MII device test is not enabled!")
+    expected_output = "Current device"
+    output = u_boot_console.run_command("mii device")
+    if not re.search(r"Current device: '(.+?)'", output):

test/py/tests/test_mii.py line 47

Quoted 10 lines
test/py/tests/test_mii.py new file +10 -0
+        pytest.skip("PHY device does not exist!")
+    assert expected_output in output
+
[email protected]("cmd_mii")
+def test_mii_set_device(u_boot_console):
+    test_mii_list(u_boot_console)
+    output = u_boot_console.run_command("mii device")
+    eth_num = re.search(r"MII devices: '(.+?)'", output).groups()[0]
+    u_boot_console.run_command(f"mii device {eth_num}")
+    output = u_boot_console.run_command("echo $?")

OK, so this here breaks the next test for me:
=> mii device FEC0
=> mii info
Incorrect PHY address. Range should be 0-31
mii - MII utility commands
...

But doing "mii info 0" next does work. However, what also works if I have not done "mii device FEC0" but just "mii device" then "mii info" works. And if I do "mii info 0" and then "mii info" it also works, because I assume there's some struct member being set somewhere or similar?

So good news / bad news, the test looks good and seems to have found an issue that needs to be resolved. The question is, does this patch work as-is on your platforms? I suspect it does and this is just a problem on the FEC driver as it looked OK on another platform here real quick, and I just want to confirm.

Signature · 1 line
Tom
#2 lore raw
In reply to Love Kumar
Quoted 8 lines · Love Kumar

Add below test cases for mii commands:
mii_info -To display MII PHY info
mii_list - To list MII devices
mii_set_device - To set MII device
mii_read - To reads register from MII PHY address
mii_dump - To display data from MII PHY address

A thing I'm not sure about now is on my j721e_evm_a72:
=> mii device
MII devices: 'mdio@f00' 'ethernet@46000000port@1' Current device: 'mdio@f00'
=> mii info
=>
=> mii device 'ethernet@46000000port@1'
=> mii info 0
PHY 0x00: OUI = 0x80028, Model = 0x23, Rev = 0x01, 100baseT, FDX

Which I think matches how things are overall on this platform. So, I don't know if it's reasonable to say I should just disable the test here entirely, or if the test should be able to / require device to be set. Especially since I think as-written it's finding a bug in FEC stuff.

Signature · 1 line
Tom