diff mbox series

[v2,12/14] test/py: net: add _lwip variants of dhcp, ping and tftpboot tests

Message ID 9acc7630e5768ab9af673981a78ffb84b47aa62e.1716566960.git.jerome.forissier@linaro.org
State New
Headers show
Series Introduce the lwIP network stack | expand

Commit Message

Jerome Forissier May 24, 2024, 4:20 p.m. UTC
WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
therefore the config annotations in the Python test scripts need to be
cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.

The console output of the tftpboot command with lwIP is slightly
different from the non-lwIP implementation. This is taken care of in
test_net_tftpboot().

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 test/py/tests/test_net.py | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Comments

Love Kumar May 28, 2024, 9:41 a.m. UTC | #1
On 24/05/24 9:50 pm, Jerome Forissier wrote:
> WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
> via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
> therefore the config annotations in the Python test scripts need to be
> cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.
> 
> The console output of the tftpboot command with lwIP is slightly
> different from the non-lwIP implementation. This is taken care of in
> test_net_tftpboot().
> 
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>   test/py/tests/test_net.py | 21 +++++++++++++++++----
>   1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
> index 038a473b239..ba30780903f 100644
> --- a/test/py/tests/test_net.py
> +++ b/test/py/tests/test_net.py
> @@ -127,6 +127,10 @@ def test_net_dhcp(u_boot_console):
>       global net_set_up
>       net_set_up = True
>   
> +@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
> +def test_net_dhcp_lwip(u_boot_console):
> +    test_net_dhcp(u_boot_console)
> +
>   @pytest.mark.buildconfigspec('cmd_dhcp')
>   @pytest.mark.buildconfigspec('cmd_mii')
>   def test_net_dhcp_abort(u_boot_console):
> @@ -230,6 +234,10 @@ def test_net_ping(u_boot_console):
>       output = u_boot_console.run_command('ping $serverip')
>       assert 'is alive' in output
>   
> +@pytest.mark.buildconfigspec('cmd_ping_lwip')
> +def test_net_ping_lwip(u_boot_console):
> +    test_net_ping(u_boot_console)
> +
>   @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
>   def test_net_network_discovery(u_boot_console):
>       """Test the network discovery feature of IPv6.
> @@ -255,7 +263,7 @@ def test_net_network_discovery(u_boot_console):
>       assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output
>   
>   @pytest.mark.buildconfigspec('cmd_net')
> -def test_net_tftpboot(u_boot_console):
> +def test_net_tftpboot(u_boot_console, lwip = False):
>       """Test the tftpboot command.
>   
>       A file is downloaded from the TFTP server, its size and optionally its
> @@ -279,10 +287,11 @@ def test_net_tftpboot(u_boot_console):
>           output = u_boot_console.run_command('tftpboot %s' % (fn))
>       else:
>           output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
> -    expected_text = 'Bytes transferred = '
>       sz = f.get('size', None)
> -    if sz:
> -        expected_text += '%d' % sz
> +    if lwip:
> +        expected_text = f'{sz} bytes transferred'
> +    else:
> +        expected_text = f'Bytes transferred = {sz}'
>       assert expected_text in output
>   
>       expected_crc = f.get('crc32', None)
> @@ -295,6 +304,10 @@ def test_net_tftpboot(u_boot_console):
>       output = u_boot_console.run_command('crc32 $fileaddr $filesize')
>       assert expected_crc in output
>   
> +@pytest.mark.buildconfigspec("cmd_net_lwip")
> +def test_net_tftpboot_lwip(u_boot_console):
> +    test_net_tftpboot(u_boot_console, True)
> +
>   @pytest.mark.buildconfigspec('cmd_nfs')
>   def test_net_nfs(u_boot_console):
>       """Test the nfs command.

Reviewed-by: Love Kumar <love.kumar@amd.com>
Maxim Uvarov May 28, 2024, 9:53 a.m. UTC | #2
пт, 24 мая 2024 г. в 19:22, Jerome Forissier <jerome.forissier@linaro.org>:
>
> WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
> via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
> therefore the config annotations in the Python test scripts need to be
> cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.
>
> The console output of the tftpboot command with lwIP is slightly
> different from the non-lwIP implementation. This is taken care of in
> test_net_tftpboot().
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>  test/py/tests/test_net.py | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
> index 038a473b239..ba30780903f 100644
> --- a/test/py/tests/test_net.py
> +++ b/test/py/tests/test_net.py
> @@ -127,6 +127,10 @@ def test_net_dhcp(u_boot_console):
>      global net_set_up
>      net_set_up = True
>
> +@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
> +def test_net_dhcp_lwip(u_boot_console):
> +    test_net_dhcp(u_boot_console)
> +
>  @pytest.mark.buildconfigspec('cmd_dhcp')
>  @pytest.mark.buildconfigspec('cmd_mii')
>  def test_net_dhcp_abort(u_boot_console):
> @@ -230,6 +234,10 @@ def test_net_ping(u_boot_console):
>      output = u_boot_console.run_command('ping $serverip')
>      assert 'is alive' in output
>
> +@pytest.mark.buildconfigspec('cmd_ping_lwip')
> +def test_net_ping_lwip(u_boot_console):
> +    test_net_ping(u_boot_console)
> +
>  @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
>  def test_net_network_discovery(u_boot_console):
>      """Test the network discovery feature of IPv6.
> @@ -255,7 +263,7 @@ def test_net_network_discovery(u_boot_console):
>      assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output
>
>  @pytest.mark.buildconfigspec('cmd_net')
> -def test_net_tftpboot(u_boot_console):
> +def test_net_tftpboot(u_boot_console, lwip = False):
>      """Test the tftpboot command.
>
>      A file is downloaded from the TFTP server, its size and optionally its
> @@ -279,10 +287,11 @@ def test_net_tftpboot(u_boot_console):
>          output = u_boot_console.run_command('tftpboot %s' % (fn))
>      else:
>          output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
> -    expected_text = 'Bytes transferred = '
>      sz = f.get('size', None)
> -    if sz:
> -        expected_text += '%d' % sz
> +    if lwip:
> +        expected_text = f'{sz} bytes transferred'

Why not change patch 5 to print with capital character to match this pattern?

BR,
Maxim.

> +    else:
> +        expected_text = f'Bytes transferred = {sz}'
>      assert expected_text in output
>
>      expected_crc = f.get('crc32', None)
> @@ -295,6 +304,10 @@ def test_net_tftpboot(u_boot_console):
>      output = u_boot_console.run_command('crc32 $fileaddr $filesize')
>      assert expected_crc in output
>
> +@pytest.mark.buildconfigspec("cmd_net_lwip")
> +def test_net_tftpboot_lwip(u_boot_console):
> +    test_net_tftpboot(u_boot_console, True)
> +
>  @pytest.mark.buildconfigspec('cmd_nfs')
>  def test_net_nfs(u_boot_console):
>      """Test the nfs command.
> --
> 2.40.1
>
Jerome Forissier May 30, 2024, 2:11 p.m. UTC | #3
On 5/28/24 11:53, Maxim Uvarov wrote:
> пт, 24 мая 2024 г. в 19:22, Jerome Forissier <jerome.forissier@linaro.org>:
>>
>> WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
>> via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
>> therefore the config annotations in the Python test scripts need to be
>> cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.
>>
>> The console output of the tftpboot command with lwIP is slightly
>> different from the non-lwIP implementation. This is taken care of in
>> test_net_tftpboot().
>>
>> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
>> ---
>>  test/py/tests/test_net.py | 21 +++++++++++++++++----
>>  1 file changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
>> index 038a473b239..ba30780903f 100644
>> --- a/test/py/tests/test_net.py
>> +++ b/test/py/tests/test_net.py
>> @@ -127,6 +127,10 @@ def test_net_dhcp(u_boot_console):
>>      global net_set_up
>>      net_set_up = True
>>
>> +@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
>> +def test_net_dhcp_lwip(u_boot_console):
>> +    test_net_dhcp(u_boot_console)
>> +
>>  @pytest.mark.buildconfigspec('cmd_dhcp')
>>  @pytest.mark.buildconfigspec('cmd_mii')
>>  def test_net_dhcp_abort(u_boot_console):
>> @@ -230,6 +234,10 @@ def test_net_ping(u_boot_console):
>>      output = u_boot_console.run_command('ping $serverip')
>>      assert 'is alive' in output
>>
>> +@pytest.mark.buildconfigspec('cmd_ping_lwip')
>> +def test_net_ping_lwip(u_boot_console):
>> +    test_net_ping(u_boot_console)
>> +
>>  @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
>>  def test_net_network_discovery(u_boot_console):
>>      """Test the network discovery feature of IPv6.
>> @@ -255,7 +263,7 @@ def test_net_network_discovery(u_boot_console):
>>      assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output
>>
>>  @pytest.mark.buildconfigspec('cmd_net')
>> -def test_net_tftpboot(u_boot_console):
>> +def test_net_tftpboot(u_boot_console, lwip = False):
>>      """Test the tftpboot command.
>>
>>      A file is downloaded from the TFTP server, its size and optionally its
>> @@ -279,10 +287,11 @@ def test_net_tftpboot(u_boot_console):
>>          output = u_boot_console.run_command('tftpboot %s' % (fn))
>>      else:
>>          output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
>> -    expected_text = 'Bytes transferred = '
>>      sz = f.get('size', None)
>> -    if sz:
>> -        expected_text += '%d' % sz
>> +    if lwip:
>> +        expected_text = f'{sz} bytes transferred'
> 
> Why not change patch 5 to print with capital character to match this pattern?

I thought unifying the messages of wget and tftp would be a good idea. With
this series, both commands print hash signs followed by:
"xxx bytes transferred (yy MB/s)".

Would a patch updating the tftp message when the legacy stack is used be
acceptable?
Maxim Uvarov May 30, 2024, 2:22 p.m. UTC | #4
чт, 30 мая 2024 г. в 17:11, Jerome Forissier <jerome.forissier@linaro.org>:
>
>
>
> On 5/28/24 11:53, Maxim Uvarov wrote:
> > пт, 24 мая 2024 г. в 19:22, Jerome Forissier <jerome.forissier@linaro.org>:
> >>
> >> WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
> >> via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
> >> therefore the config annotations in the Python test scripts need to be
> >> cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.
> >>
> >> The console output of the tftpboot command with lwIP is slightly
> >> different from the non-lwIP implementation. This is taken care of in
> >> test_net_tftpboot().
> >>
> >> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> >> ---
> >>  test/py/tests/test_net.py | 21 +++++++++++++++++----
> >>  1 file changed, 17 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
> >> index 038a473b239..ba30780903f 100644
> >> --- a/test/py/tests/test_net.py
> >> +++ b/test/py/tests/test_net.py
> >> @@ -127,6 +127,10 @@ def test_net_dhcp(u_boot_console):
> >>      global net_set_up
> >>      net_set_up = True
> >>
> >> +@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
> >> +def test_net_dhcp_lwip(u_boot_console):
> >> +    test_net_dhcp(u_boot_console)
> >> +
> >>  @pytest.mark.buildconfigspec('cmd_dhcp')
> >>  @pytest.mark.buildconfigspec('cmd_mii')
> >>  def test_net_dhcp_abort(u_boot_console):
> >> @@ -230,6 +234,10 @@ def test_net_ping(u_boot_console):
> >>      output = u_boot_console.run_command('ping $serverip')
> >>      assert 'is alive' in output
> >>
> >> +@pytest.mark.buildconfigspec('cmd_ping_lwip')
> >> +def test_net_ping_lwip(u_boot_console):
> >> +    test_net_ping(u_boot_console)
> >> +
> >>  @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
> >>  def test_net_network_discovery(u_boot_console):
> >>      """Test the network discovery feature of IPv6.
> >> @@ -255,7 +263,7 @@ def test_net_network_discovery(u_boot_console):
> >>      assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output
> >>
> >>  @pytest.mark.buildconfigspec('cmd_net')
> >> -def test_net_tftpboot(u_boot_console):
> >> +def test_net_tftpboot(u_boot_console, lwip = False):
> >>      """Test the tftpboot command.
> >>
> >>      A file is downloaded from the TFTP server, its size and optionally its
> >> @@ -279,10 +287,11 @@ def test_net_tftpboot(u_boot_console):
> >>          output = u_boot_console.run_command('tftpboot %s' % (fn))
> >>      else:
> >>          output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
> >> -    expected_text = 'Bytes transferred = '
> >>      sz = f.get('size', None)
> >> -    if sz:
> >> -        expected_text += '%d' % sz
> >> +    if lwip:
> >> +        expected_text = f'{sz} bytes transferred'
> >
> > Why not change patch 5 to print with capital character to match this pattern?
>
> I thought unifying the messages of wget and tftp would be a good idea. With
> this series, both commands print hash signs followed by:
> "xxx bytes transferred (yy MB/s)".
>
> Would a patch updating the tftp message when the legacy stack is used be
> acceptable?
>
> --
> Jerome
>

I think yes.

BR,
Maxim.

> > BR,
> > Maxim.
> >
> >> +    else:
> >> +        expected_text = f'Bytes transferred = {sz}'
> >>      assert expected_text in output
> >>
> >>      expected_crc = f.get('crc32', None)
> >> @@ -295,6 +304,10 @@ def test_net_tftpboot(u_boot_console):
> >>      output = u_boot_console.run_command('crc32 $fileaddr $filesize')
> >>      assert expected_crc in output
> >>
> >> +@pytest.mark.buildconfigspec("cmd_net_lwip")
> >> +def test_net_tftpboot_lwip(u_boot_console):
> >> +    test_net_tftpboot(u_boot_console, True)
> >> +
> >>  @pytest.mark.buildconfigspec('cmd_nfs')
> >>  def test_net_nfs(u_boot_console):
> >>      """Test the nfs command.
> >> --
> >> 2.40.1
> >>
> >
> >
Jerome Forissier June 6, 2024, 9:18 a.m. UTC | #5
On 5/30/24 16:22, Maxim Uvarov wrote:
> чт, 30 мая 2024 г. в 17:11, Jerome Forissier <jerome.forissier@linaro.org>:
>>
>>
>>
>> On 5/28/24 11:53, Maxim Uvarov wrote:
>>> пт, 24 мая 2024 г. в 19:22, Jerome Forissier <jerome.forissier@linaro.org>:
>>>>
>>>> WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
>>>> via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
>>>> therefore the config annotations in the Python test scripts need to be
>>>> cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.
>>>>
>>>> The console output of the tftpboot command with lwIP is slightly
>>>> different from the non-lwIP implementation. This is taken care of in
>>>> test_net_tftpboot().
>>>>
>>>> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
>>>> ---
>>>>  test/py/tests/test_net.py | 21 +++++++++++++++++----
>>>>  1 file changed, 17 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
>>>> index 038a473b239..ba30780903f 100644
>>>> --- a/test/py/tests/test_net.py
>>>> +++ b/test/py/tests/test_net.py
>>>> @@ -127,6 +127,10 @@ def test_net_dhcp(u_boot_console):
>>>>      global net_set_up
>>>>      net_set_up = True
>>>>
>>>> +@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
>>>> +def test_net_dhcp_lwip(u_boot_console):
>>>> +    test_net_dhcp(u_boot_console)
>>>> +
>>>>  @pytest.mark.buildconfigspec('cmd_dhcp')
>>>>  @pytest.mark.buildconfigspec('cmd_mii')
>>>>  def test_net_dhcp_abort(u_boot_console):
>>>> @@ -230,6 +234,10 @@ def test_net_ping(u_boot_console):
>>>>      output = u_boot_console.run_command('ping $serverip')
>>>>      assert 'is alive' in output
>>>>
>>>> +@pytest.mark.buildconfigspec('cmd_ping_lwip')
>>>> +def test_net_ping_lwip(u_boot_console):
>>>> +    test_net_ping(u_boot_console)
>>>> +
>>>>  @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
>>>>  def test_net_network_discovery(u_boot_console):
>>>>      """Test the network discovery feature of IPv6.
>>>> @@ -255,7 +263,7 @@ def test_net_network_discovery(u_boot_console):
>>>>      assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output
>>>>
>>>>  @pytest.mark.buildconfigspec('cmd_net')
>>>> -def test_net_tftpboot(u_boot_console):
>>>> +def test_net_tftpboot(u_boot_console, lwip = False):
>>>>      """Test the tftpboot command.
>>>>
>>>>      A file is downloaded from the TFTP server, its size and optionally its
>>>> @@ -279,10 +287,11 @@ def test_net_tftpboot(u_boot_console):
>>>>          output = u_boot_console.run_command('tftpboot %s' % (fn))
>>>>      else:
>>>>          output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
>>>> -    expected_text = 'Bytes transferred = '
>>>>      sz = f.get('size', None)
>>>> -    if sz:
>>>> -        expected_text += '%d' % sz
>>>> +    if lwip:
>>>> +        expected_text = f'{sz} bytes transferred'
>>>
>>> Why not change patch 5 to print with capital character to match this pattern?
>>
>> I thought unifying the messages of wget and tftp would be a good idea. With
>> this series, both commands print hash signs followed by:
>> "xxx bytes transferred (yy MB/s)".
>>
>> Would a patch updating the tftp message when the legacy stack is used be
>> acceptable?
>>
>> --
>> Jerome
>>
> 
> I think yes.

I changed my mind. As I replied to Tom, I will stick with the older message
format for now.

Thanks,
diff mbox series

Patch

diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index 038a473b239..ba30780903f 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -127,6 +127,10 @@  def test_net_dhcp(u_boot_console):
     global net_set_up
     net_set_up = True
 
+@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
+def test_net_dhcp_lwip(u_boot_console):
+    test_net_dhcp(u_boot_console)
+
 @pytest.mark.buildconfigspec('cmd_dhcp')
 @pytest.mark.buildconfigspec('cmd_mii')
 def test_net_dhcp_abort(u_boot_console):
@@ -230,6 +234,10 @@  def test_net_ping(u_boot_console):
     output = u_boot_console.run_command('ping $serverip')
     assert 'is alive' in output
 
+@pytest.mark.buildconfigspec('cmd_ping_lwip')
+def test_net_ping_lwip(u_boot_console):
+    test_net_ping(u_boot_console)
+
 @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
 def test_net_network_discovery(u_boot_console):
     """Test the network discovery feature of IPv6.
@@ -255,7 +263,7 @@  def test_net_network_discovery(u_boot_console):
     assert '0000:0000:0000:0000:0000:0000:0000:0000' not in output
 
 @pytest.mark.buildconfigspec('cmd_net')
-def test_net_tftpboot(u_boot_console):
+def test_net_tftpboot(u_boot_console, lwip = False):
     """Test the tftpboot command.
 
     A file is downloaded from the TFTP server, its size and optionally its
@@ -279,10 +287,11 @@  def test_net_tftpboot(u_boot_console):
         output = u_boot_console.run_command('tftpboot %s' % (fn))
     else:
         output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
-    expected_text = 'Bytes transferred = '
     sz = f.get('size', None)
-    if sz:
-        expected_text += '%d' % sz
+    if lwip:
+        expected_text = f'{sz} bytes transferred'
+    else:
+        expected_text = f'Bytes transferred = {sz}'
     assert expected_text in output
 
     expected_crc = f.get('crc32', None)
@@ -295,6 +304,10 @@  def test_net_tftpboot(u_boot_console):
     output = u_boot_console.run_command('crc32 $fileaddr $filesize')
     assert expected_crc in output
 
+@pytest.mark.buildconfigspec("cmd_net_lwip")
+def test_net_tftpboot_lwip(u_boot_console):
+    test_net_tftpboot(u_boot_console, True)
+
 @pytest.mark.buildconfigspec('cmd_nfs')
 def test_net_nfs(u_boot_console):
     """Test the nfs command.