All of lore.kernel.org
 help / color / mirror / Atom feed
* [UBOOT PATCH v3] test/py: net: Add a TFTP put test
@ 2023-11-08  7:10 Love Kumar
  2023-11-08 16:53 ` Tom Rini
  2023-11-29 16:57 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Love Kumar @ 2023-11-08  7:10 UTC (permalink / raw)
  To: u-boot
  Cc: michal.simek, git, rfried.dev, v.v.mitrofanov, seanedmond, emohandesi

Execute tftpput command for uploading files to a server and validate its
size & CRC32.

Signed-off-by: Love Kumar <love.kumar@amd.com>
---
Changes in v2:
- Add marking for cmd_tftpput config

Chnages in v3:
- Add filename to upload as part of env file
---
 test/py/tests/test_net.py | 71 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index b2241ae6a482..2495608786de 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 datetime
 
 """
 Note: This test relies on boardenv_* containing configuration values to define
@@ -51,6 +52,8 @@ env__net_tftp_readable_file = {
     'addr': 0x10000000,
     'size': 5058624,
     'crc32': 'c2244b26',
+    'timeout': 50000,
+    'fnu': 'ubtest-upload.bin',
 }
 
 # Details regarding a file that may be read from a NFS server. This variable
@@ -326,3 +329,71 @@ def test_net_pxe_get(u_boot_console):
 
     assert expected_text_default in output
     assert "Config file 'default.boot' found" in output
+
+@pytest.mark.buildconfigspec("cmd_crc32")
+@pytest.mark.buildconfigspec("cmd_net")
+@pytest.mark.buildconfigspec("cmd_tftpput")
+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 = f.get("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
+
+    output = u_boot_console.run_command("crc32 $fileaddr $filesize")
+    assert expected_tftpb_crc in output
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [UBOOT PATCH v3] test/py: net: Add a TFTP put test
  2023-11-08  7:10 [UBOOT PATCH v3] test/py: net: Add a TFTP put test Love Kumar
@ 2023-11-08 16:53 ` Tom Rini
  2023-11-29 16:57 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-11-08 16:53 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: 393 bytes --]

On Wed, Nov 08, 2023 at 12:40:31PM +0530, Love Kumar wrote:

> Execute tftpput command for uploading files to a server and validate its
> size & CRC32.
> 
> Signed-off-by: Love Kumar <love.kumar@amd.com>

Thanks for reworking this. After changing tftp server so I could upload
files, this is working as I was hoping it would.

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [UBOOT PATCH v3] test/py: net: Add a TFTP put test
  2023-11-08  7:10 [UBOOT PATCH v3] test/py: net: Add a TFTP put test Love Kumar
  2023-11-08 16:53 ` Tom Rini
@ 2023-11-29 16:57 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-11-29 16:57 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: 303 bytes --]

On Wed, Nov 08, 2023 at 12:40:31PM +0530, Love Kumar wrote:

> Execute tftpput command for uploading files to a server and validate its
> size & CRC32.
> 
> Signed-off-by: Love Kumar <love.kumar@amd.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-29 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08  7:10 [UBOOT PATCH v3] test/py: net: Add a TFTP put test Love Kumar
2023-11-08 16:53 ` Tom Rini
2023-11-29 16:57 ` Tom Rini

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.