From patchwork Wed Sep 14 08:29:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume GARDET X-Patchwork-Id: 669800 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sYvq31wZyz9sC3 for ; Wed, 14 Sep 2016 18:29:34 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 16A754BA29; Wed, 14 Sep 2016 10:29:31 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BYqR9mTj3Gvz; Wed, 14 Sep 2016 10:29:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A453D4B99D; Wed, 14 Sep 2016 10:29:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 70DB54B99D for ; Wed, 14 Sep 2016 10:29:27 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eJwP_-USQQSI for ; Wed, 14 Sep 2016 10:29:27 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [212.27.42.2]) by theia.denx.de (Postfix) with ESMTPS id 3DC834B624 for ; Wed, 14 Sep 2016 10:29:23 +0200 (CEST) Received: from OLI01.site (unknown [82.244.147.214]) by smtp2-g21.free.fr (Postfix) with ESMTP id 351E12003B1; Wed, 14 Sep 2016 10:29:22 +0200 (CEST) From: Guillaume GARDET To: u-boot@lists.denx.de Date: Wed, 14 Sep 2016 10:29:12 +0200 Message-Id: <1473841752-13223-1-git-send-email-guillaume.gardet@free.fr> X-Mailer: git-send-email 1.8.4.5 Cc: Tom Rini , Guillaume GARDET , Joe Hershberger Subject: [U-Boot] [PATCH] test: add NFS download test X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a NFS download test, based on TFTP test. Tested on i.MX6 SabreLite board. Signed-off-by: Guillaume GARDET Cc: Tom Rini Cc: Joe Hershberger Cc: Stephen Warren Cc: Simon Glass Reviewed-by: Stephen Warren Acked-by: Joe Hershberger --- test/py/tests/test_net.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index 4ab58b4..0884051 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -47,6 +47,15 @@ env__net_tftp_readable_file = { "size": 5058624, "crc32": "c2244b26", } + +# Details regarding a file that may be read from a NFS server. This variable +# may be omitted or set to None if NFS testing is not possible or desired. +env__net_nfs_readable_file = { + "fn": "ubtest-readable.bin", + "addr": 0x10000000, + "size": 5058624, + "crc32": "c2244b26", +} """ net_set_up = False @@ -157,3 +166,43 @@ def test_net_tftpboot(u_boot_console): output = u_boot_console.run_command('crc32 %x $filesize' % addr) assert expected_crc in output + +@pytest.mark.buildconfigspec('cmd_nfs') +def test_net_nfs(u_boot_console): + """Test the nfs command. + + A file is downloaded from the NFS server, its size and optionally 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_nfs_readable_file', None) + if not f: + pytest.skip('No NFS readable file to read') + + addr = f.get('addr', None) + if not addr: + addr = u_boot_utils.find_ram_base(u_boot_console) + + fn = f['fn'] + output = u_boot_console.run_command('nfs %x %s' % (addr, fn)) + expected_text = 'Bytes transferred = ' + sz = f.get('size', None) + if sz: + expected_text += '%d' % sz + assert expected_text in output + + expected_crc = f.get('crc32', None) + if not expected_crc: + return + + if u_boot_console.config.buildconfig.get('config_cmd_crc32', 'n') != 'y': + return + + output = u_boot_console.run_command('crc32 %x $filesize' % addr) + assert expected_crc in output