* [UBOOT PATCH v2] test/py: net: Add dhcp abort test
@ 2023-10-31 12:59 Love Kumar
2023-11-08 14:41 ` Tom Rini
0 siblings, 1 reply; 3+ messages in thread
From: Love Kumar @ 2023-10-31 12:59 UTC (permalink / raw)
To: u-boot
Cc: michal.simek, git, rfried.dev, v.v.mitrofanov, seanedmond,
emohandesi
Abort the dhcp request in the middle by pressing ctrl + c on u-boot
prompt and validate the abort status.
Signed-off-by: Love Kumar <love.kumar@amd.com>
---
Changes in v2:
- Mark CMD_MII command dependency
---
test/py/tests/test_net.py | 45 +++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index b2241ae6a482..6d32ad2db687 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -7,6 +7,7 @@
import pytest
import u_boot_utils
import uuid
+import re
"""
Note: This test relies on boardenv_* containing configuration values to define
@@ -115,6 +116,50 @@ def test_net_dhcp(u_boot_console):
global net_set_up
net_set_up = True
+@pytest.mark.buildconfigspec("cmd_dhcp")
+@pytest.mark.buildconfigspec("cmd_mii")
+def test_net_dhcp_abort(u_boot_console):
+ """Test the dhcp command by pressing ctrl+c in the middle of dhcp request
+
+ The boardenv_* file may be used to enable/disable this test; see the
+ comment at the beginning of this file.
+ """
+
+ test_dhcp = u_boot_console.config.env.get("env__net_dhcp_server", False)
+ if not test_dhcp:
+ pytest.skip("No DHCP server available")
+
+ u_boot_console.run_command("setenv autoload no")
+
+ # Phy reset before running dhcp command
+ output = u_boot_console.run_command("mii device")
+ eth_num = re.search(r"Current device: '(.+?)'", output).groups()[0]
+ u_boot_console.run_command(f"mii device {eth_num}")
+ 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 modify {eth_addr} 0 0x8000 0x8000")
+
+ u_boot_console.run_command("dhcp", wait_for_prompt=False)
+ try:
+ u_boot_console.wait_for("Waiting for PHY auto negotiation to complete")
+ except:
+ pytest.skip("Timeout waiting for PHY auto negotiation to complete")
+
+ u_boot_console.wait_for("done")
+
+ # Sending Ctrl-C
+ output = u_boot_console.run_command(
+ chr(3), wait_for_echo=False, send_nl=False
+ )
+
+ assert "TIMEOUT" not in output
+ assert "DHCP client bound to address " not in output
+ assert "Abort" in output
+
+ # Provide a time to recover from Abort - if it is not performed
+ # There is message like: ethernet@ff0e0000: No link.
+ u_boot_console.run_command("sleep 1")
+
@pytest.mark.buildconfigspec('cmd_dhcp6')
def test_net_dhcp6(u_boot_console):
"""Test the dhcp6 command.
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [UBOOT PATCH v2] test/py: net: Add dhcp abort test
2023-10-31 12:59 [UBOOT PATCH v2] test/py: net: Add dhcp abort test Love Kumar
@ 2023-11-08 14:41 ` Tom Rini
2023-11-09 11:42 ` Michal Simek
0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2023-11-08 14:41 UTC (permalink / raw)
To: Love Kumar
Cc: u-boot, michal.simek, git, rfried.dev, v.v.mitrofanov, seanedmond,
emohandesi
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
On Tue, Oct 31, 2023 at 06:29:20PM +0530, Love Kumar wrote:
> Abort the dhcp request in the middle by pressing ctrl + c on u-boot
> prompt and validate the abort status.
>
> Signed-off-by: Love Kumar <love.kumar@amd.com>
> ---
> Changes in v2:
> - Mark CMD_MII command dependency
This doesn't work for me on a raspberry pi 3 in 32bit mode (and I
suspect fails on the rest of the Pi families and builds as well):
test/py/tests/test_net.py ..F
========================================== FAILURES ===========================================
_____________________________________ test_net_dhcp_abort _____________________________________
test/py/tests/test_net.py:139: in test_net_dhcp_abort
eth_num = re.search(r"Current device: '(.+?)'", output).groups()[0]
E AttributeError: 'NoneType' object has no attribute 'groups'
------------------------------------ Captured stdout call -------------------------------------
U-Boot> setenv autoload no
U-Boot> U-Boot> mii device
MII devices:
U-Boot>
=================================== short test summary info ===================================
FAILED test/py/tests/test_net.py::test_net_dhcp_abort - AttributeError: 'NoneType' object ha...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================= 1 failed, 101 passed, 86 skipped in 39.89s ==========================
Perhaps the method you use to interrupt the dhcp attempt needs
re-thinking? I don't know if we can reliably inject control-c instead
quick enough to the console.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [UBOOT PATCH v2] test/py: net: Add dhcp abort test
2023-11-08 14:41 ` Tom Rini
@ 2023-11-09 11:42 ` Michal Simek
0 siblings, 0 replies; 3+ messages in thread
From: Michal Simek @ 2023-11-09 11:42 UTC (permalink / raw)
To: Tom Rini
Cc: Love Kumar, u-boot, michal.simek, git, rfried.dev, v.v.mitrofanov,
seanedmond, emohandesi
st 8. 11. 2023 v 15:42 odesílatel Tom Rini <trini@konsulko.com> napsal:
>
> On Tue, Oct 31, 2023 at 06:29:20PM +0530, Love Kumar wrote:
>
> > Abort the dhcp request in the middle by pressing ctrl + c on u-boot
> > prompt and validate the abort status.
> >
> > Signed-off-by: Love Kumar <love.kumar@amd.com>
> > ---
> > Changes in v2:
> > - Mark CMD_MII command dependency
>
> This doesn't work for me on a raspberry pi 3 in 32bit mode (and I
> suspect fails on the rest of the Pi families and builds as well):
> test/py/tests/test_net.py ..F
>
> ========================================== FAILURES ===========================================
> _____________________________________ test_net_dhcp_abort _____________________________________
> test/py/tests/test_net.py:139: in test_net_dhcp_abort
> eth_num = re.search(r"Current device: '(.+?)'", output).groups()[0]
> E AttributeError: 'NoneType' object has no attribute 'groups'
> ------------------------------------ Captured stdout call -------------------------------------
> U-Boot> setenv autoload no
> U-Boot> U-Boot> mii device
> MII devices:
You have mii command enabled but you don't have any device there.
I expect you have any ethernet phy on RPI3.
Love should check that the actual phy device at the passed address
exists to be able to abort it.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-09 11:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-31 12:59 [UBOOT PATCH v2] test/py: net: Add dhcp abort test Love Kumar
2023-11-08 14:41 ` Tom Rini
2023-11-09 11:42 ` Michal Simek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox