[PATCH] test/py: net: Add a TFTP put test
Michal Simek
michal.simek at amd.com
Mon Oct 9 13:10:53 CEST 2023
On 10/3/23 11:02, Love Kumar wrote:
> Execute tftpput command for uploading files to a server and validate its
> size & CRC32.
>
> Signed-off-by: Love Kumar <love.kumar at amd.com>
> ---
> test/py/tests/test_net.py | 69 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
> index cd4b4dc53cbc..f69e3ea2dbba 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 datetime
>
> """
> Note: This test relies on boardenv_* containing configuration values to define
> @@ -50,6 +51,7 @@ env__net_tftp_readable_file = {
> 'addr': 0x10000000,
> 'size': 5058624,
> 'crc32': 'c2244b26',
> + 'timeout': 50000,
> }
>
> # Details regarding a file that may be read from a NFS server. This variable
> @@ -260,3 +262,70 @@ def test_net_nfs(u_boot_console):
>
> output = u_boot_console.run_command('crc32 %x $filesize' % addr)
> assert expected_crc in output
> +
> + at pytest.mark.buildconfigspec("cmd_crc32")
> + at pytest.mark.buildconfigspec("cmd_net")
Here should be CMD_TFTPPUT marking.
> +def test_net_tftpput(u_boot_console):
> + """Test the tftpput command.
> + A file is downloaded from the TFTP server and then uploaded to the TFTP
> + server, its size and its CRC32 are validated.
> + The details of the file to download are provided by the boardenv_* file;
> + see the comment at the beginning of this file.
> + """
> +
> + if not net_set_up:
> + pytest.skip("Network not initialized")
> +
> + f = u_boot_console.config.env.get("env__net_tftp_readable_file", None)
> + if not f:
> + pytest.skip("No TFTP readable file to read")
> +
> + addr = f.get("addr", None)
> + if not addr:
> + addr = u_boot_utils.find_ram_base(u_boot_console)
> +
> + sz = f.get("size", None)
> + timeout = f.get("timeout", u_boot_console.p.timeout)
> + fn = f["fn"]
> + fnu = "_".join([datetime.datetime.now().strftime("%y%m%d%H%M%S"), fn])
> + expected_text = "Bytes transferred = "
> + if sz:
> + expected_text += "%d" % sz
> +
> + with u_boot_console.temporary_timeout(timeout):
> + output = u_boot_console.run_command("tftpboot %x %s" % (addr, fn))
> +
> + assert "TIMEOUT" not in output
> + assert expected_text in output
> +
> + expected_tftpb_crc = f.get("crc32", None)
> +
> + output = u_boot_console.run_command("crc32 $fileaddr $filesize")
> + assert expected_tftpb_crc in output
> +
> + with u_boot_console.temporary_timeout(timeout):
> + output = u_boot_console.run_command(
> + "tftpput $fileaddr $filesize $serverip:%s" % (fnu)
> + )
> +
> + expected_text = "Bytes transferred = "
> + if sz:
> + expected_text += "%d" % sz
> + addr = addr + sz
> + assert "TIMEOUT" not in output
> + assert "Access violation" not in output
> + assert expected_text in output
> +
> + with u_boot_console.temporary_timeout(timeout):
> + output = u_boot_console.run_command("tftpboot %x %s" % (addr, fnu))
> +
> + expected_text = "Bytes transferred = "
> + if sz:
> + expected_text += "%d" % sz
> + assert "TIMEOUT" not in output
> + assert expected_text in output
> +
> + expected_tftpp_crc = expected_tftpb_crc
> +
> + output = u_boot_console.run_command("crc32 $fileaddr $filesize")
> + assert expected_tftpp_crc in output
I pushed this to CI to see if that goes through and I see couple of failures
like this.
test/py/tests/test_net.py:409: in test_net_tftpput
assert expected_text in output
E assert 'Bytes transferred = 5181868' in "smc911x: detected LAN9118
controller\r\r\nsmc911x: phy initialized\r\r\nsmc911x: MAC
52:54:00:12:34:56\r\r\n*** ERROR: `serverip' not set\r\r\nsmc911x: MAC
52:54:00:12:34:56"
_______________________________ test_net_tftpput _______________________________
test/py/tests/test_net.py:417: in test_net_tftpput
output = u_boot_console.run_command(
test/py/u_boot_console_base.py:269: in run_command
raise Exception('Bad pattern found on console: ' +
E Exception: Bad pattern found on console: unknown_command
test/py/tests/test_net.py:409: in test_net_tftpput
assert expected_text in output
E assert 'Bytes transferred = 6096080' in "*** ERROR: `serverip' not set"
M
More information about the U-Boot
mailing list