* [PATCH] test/py: net: Add dhcp abort test
@ 2023-10-03 12:46 Love Kumar
2023-10-06 20:26 ` Ramon Fried
2023-10-09 14:14 ` Michal Simek
0 siblings, 2 replies; 3+ messages in thread
From: Love Kumar @ 2023-10-03 12:46 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>
---
test/py/tests/test_net.py | 44 +++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index cd4b4dc53cbc..1e8eb0357eef 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -6,6 +6,7 @@
import pytest
import u_boot_utils
+import re
"""
Note: This test relies on boardenv_* containing configuration values to define
@@ -104,6 +105,49 @@ def test_net_dhcp(u_boot_console):
global net_set_up
net_set_up = True
+@pytest.mark.buildconfigspec("cmd_dhcp")
+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: [PATCH] test/py: net: Add dhcp abort test
2023-10-03 12:46 [PATCH] test/py: net: Add dhcp abort test Love Kumar
@ 2023-10-06 20:26 ` Ramon Fried
2023-10-09 14:14 ` Michal Simek
1 sibling, 0 replies; 3+ messages in thread
From: Ramon Fried @ 2023-10-06 20:26 UTC (permalink / raw)
To: Love Kumar
Cc: u-boot, michal.simek, git, v.v.mitrofanov, seanedmond, emohandesi
On Tue, Oct 3, 2023 at 3:46 PM Love Kumar <love.kumar@amd.com> 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>
> ---
> test/py/tests/test_net.py | 44 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
> index cd4b4dc53cbc..1e8eb0357eef 100644
> --- a/test/py/tests/test_net.py
> +++ b/test/py/tests/test_net.py
> @@ -6,6 +6,7 @@
>
> import pytest
> import u_boot_utils
> +import re
>
> """
> Note: This test relies on boardenv_* containing configuration values to define
> @@ -104,6 +105,49 @@ def test_net_dhcp(u_boot_console):
> global net_set_up
> net_set_up = True
>
> +@pytest.mark.buildconfigspec("cmd_dhcp")
> +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
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] test/py: net: Add dhcp abort test
2023-10-03 12:46 [PATCH] test/py: net: Add dhcp abort test Love Kumar
2023-10-06 20:26 ` Ramon Fried
@ 2023-10-09 14:14 ` Michal Simek
1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2023-10-09 14:14 UTC (permalink / raw)
To: Love Kumar, u-boot
Cc: git, rfried.dev, v.v.mitrofanov, seanedmond, emohandesi
On 10/3/23 14:46, 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>
> ---
> test/py/tests/test_net.py | 44 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
> index cd4b4dc53cbc..1e8eb0357eef 100644
> --- a/test/py/tests/test_net.py
> +++ b/test/py/tests/test_net.py
> @@ -6,6 +6,7 @@
>
> import pytest
> import u_boot_utils
> +import re
>
> """
> Note: This test relies on boardenv_* containing configuration values to define
> @@ -104,6 +105,49 @@ def test_net_dhcp(u_boot_console):
> global net_set_up
> net_set_up = True
>
> +@pytest.mark.buildconfigspec("cmd_dhcp")
Similar issue is visible here too.
There should be CMD_MII dependency.
> +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.
qemu_arm64 test.py is showing this issue.
____________________________ test_net_dhcp_abort ______________________________
test/py/tests/test_net.py:138: in test_net_dhcp_abort
eth_num = re.search(r"Current device: '(.+?)'", output).groups()[0]
E AttributeError: 'NoneType' object has no attribute 'groups'
M
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-09 14:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 12:46 [PATCH] test/py: net: Add dhcp abort test Love Kumar
2023-10-06 20:26 ` Ramon Fried
2023-10-09 14:14 ` Michal Simek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.