From patchwork Thu Aug 23 07:25:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 961196 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="hnBP2zYz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41wwx9321Cz9s3C for ; Thu, 23 Aug 2018 17:27:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1C679C21F00; Thu, 23 Aug 2018 07:27:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E2098C21ECA; Thu, 23 Aug 2018 07:26:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9684CC21F06; Thu, 23 Aug 2018 07:26:18 +0000 (UTC) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by lists.denx.de (Postfix) with ESMTPS id 12A89C21F27 for ; Thu, 23 Aug 2018 07:26:09 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id u10-v6so418920pgr.1 for ; Thu, 23 Aug 2018 00:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2zDJ8R2eRf+sEHdvhDe4MX5EGlA8eG3oWkUoIPZUhs0=; b=hnBP2zYzBPHYtjvvXnWZDfjUmB1ZcaZ5mgJiTSHIxsZIKFcj8eRMRcFr0eJF8pdfsJ MePDJOuWs+S1amtUvoAn5vdOYIyVoNyVfctr8BWfnYpu1miBqYyw+ZSeWzrZWGeDkDoU LBB07vICtq1PIW2caXRZs7Hcj4CTZQjmZZTbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2zDJ8R2eRf+sEHdvhDe4MX5EGlA8eG3oWkUoIPZUhs0=; b=pLAk5ehlQ8a60Sg2UWiAcFwC0WIdPiBOTmZBR+TkgQs+zNs4+CpQJeTPKdkq/ixonS eTPRCx5lyd60Xz06am6BvZMN+o4iWnIBKQm2/mIYqgQIQTzS9HqcPDFUBoet5MjSdkYg RTbZkJMLQ1EtYk4jfzJOg4eITV/dktGMJWukNhcbdBGxEfLqmCM/4JMlqYyb3s8cQwpR 6KCsgJ3AfDxqW+43QXxXxjWlPGkvxbaxIKRpDHBpkUKBHxgIq/od97smAIJwSU/Jyd02 ili+JibMuNv5O+HwWxPKCQeMDTYITpsRQZVfoW8xa/f+Nf/I55E+bLdWEeqJysp3g5Az cLJg== X-Gm-Message-State: AOUpUlFdhtiTWP8XfIdmJB/Q60q5uneub8ZAF6b130v8ofXoEDHfPx4v 71rDyJI5gjiIxjhUlMEtEXLSmw== X-Google-Smtp-Source: AA+uWPzIar27ppKmsd4DEgPItEoZ3AFFqDk57hqPl7GRTNmfAyCfDifj4r6MraMOuYgdtw2rBgJQAQ== X-Received: by 2002:a63:26c5:: with SMTP id m188-v6mr20128730pgm.200.1535009167672; Thu, 23 Aug 2018 00:26:07 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j184-v6sm4723684pge.77.2018.08.23.00.26.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 00:26:07 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Thu, 23 Aug 2018 16:25:22 +0900 Message-Id: <20180823072522.15735-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823072522.15735-1-takahiro.akashi@linaro.org> References: <20180823072522.15735-1-takahiro.akashi@linaro.org> Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, agraf@suse.de Subject: [U-Boot] [RFC 3/3] test/py: fs: add fstest/mkdir test X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" In this commit, test cases for mkdir interfaces are added as part of "test_fs" test suite. Signed-off-by: AKASHI Takahiro --- test/py/tests/test_fs/conftest.py | 31 ++++++++++++ test/py/tests/test_fs/test_mkdir.py | 77 +++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 test/py/tests/test_fs/test_mkdir.py diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py index 087c9d30255c..6cb308eca596 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -9,6 +9,7 @@ from fstest_defs import * supported_fs_basic = ['fat16', 'fat32', 'ext4'] supported_fs_ext = ['fat16', 'fat32'] +supported_fs_mkdir = ['fat16', 'fat32'] # # Filesystem test specific setup @@ -20,6 +21,7 @@ def pytest_addoption(parser): def pytest_configure(config): global supported_fs_basic global supported_fs_ext + global supported_fs_mkdir def intersect(listA, listB): return [x for x in listA if x in listB] @@ -29,6 +31,7 @@ def pytest_configure(config): print("*** FS TYPE modified: %s" % supported_fs) supported_fs_basic = intersect(supported_fs, supported_fs_basic) supported_fs_ext = intersect(supported_fs, supported_fs_ext) + supported_fs_mkdir = intersect(supported_fs, supported_fs_mkdir) def pytest_generate_tests(metafunc): if 'fs_obj_basic' in metafunc.fixturenames: @@ -37,6 +40,9 @@ def pytest_generate_tests(metafunc): if 'fs_obj_ext' in metafunc.fixturenames: metafunc.parametrize('fs_obj_ext', supported_fs_ext, indirect=True, scope='module') + if 'fs_obj_mkdir' in metafunc.fixturenames: + metafunc.parametrize('fs_obj_mkdir', supported_fs_mkdir, + indirect=True, scope='module') # # Helper functions @@ -256,3 +262,28 @@ def fs_obj_ext(request, u_boot_config): call('rmdir -rf %s' % mount_dir, shell=True) # if fs_img: # call('rm -f %s' % fs_img, shell=True) + + +# +# Fixture for mkdir test +# +# NOTE: yield_fixture was deprecated since pytest-3.0 +@pytest.yield_fixture() +def fs_obj_mkdir(request, u_boot_config): + fs_type = request.param + fs_img = '' + + fs_ubtype = fstype_to_ubname(fs_type) + check_ubconfig(u_boot_config, fs_ubtype) + + try: + # 256KiB volume + fs_img = mk_fs(u_boot_config, fs_type, 0x40000, '256KB') + except: + pytest.skip('Setup failed for filesystem: ' + fs_type) + else: + yield [fs_ubtype, fs_img] + finally: + print 'Dummy' +# if fs_img: +# call('rm -f %s' % fs_img, shell=True) diff --git a/test/py/tests/test_fs/test_mkdir.py b/test/py/tests/test_fs/test_mkdir.py new file mode 100644 index 000000000000..f42d461e84cb --- /dev/null +++ b/test/py/tests/test_fs/test_mkdir.py @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2018, Linaro Limited +# Author: Takahiro Akashi +# +# U-Boot File System:mkdir Test + +""" +This test verifies mkdir operation on file system. +""" + +import pytest + +@pytest.mark.boardspec('sandbox') +class TestMkdir(object): + def test_mkdir1(self, u_boot_console, fs_obj_mkdir): + fs_type,fs_img = fs_obj_mkdir + with u_boot_console.log.section('Test Case 1 - mkdir'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + '%smkdir host 0:0 dir1' % fs_type, + '%sls host 0:0 /' % fs_type]) + assert('dir1/' in ''.join(output)) + + output = u_boot_console.run_command( + '%sls host 0:0 dir1' % fs_type) + assert('./' in output) + assert('../' in output) + + def test_mkdir2(self, u_boot_console, fs_obj_mkdir): + fs_type,fs_img = fs_obj_mkdir + with u_boot_console.log.section('Test Case 2 - mkdir (sub-sub directory)'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + '%smkdir host 0:0 dir1/dir2' % fs_type, + '%sls host 0:0 dir1' % fs_type]) + assert('dir2/' in ''.join(output)) + + def test_mkdir3(self, u_boot_console, fs_obj_mkdir): + fs_type,fs_img = fs_obj_mkdir + with u_boot_console.log.section('Test Case 3 - mkdir (non-existing path)'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + '%smkdir host 0:0 none/dir3' % fs_type]) + assert('Unable to create a directory' in ''.join(output)) + + def test_mkdir4(self, u_boot_console, fs_obj_mkdir): + fs_type,fs_img = fs_obj_mkdir + with u_boot_console.log.section('Test Case 4 - mkdir (".")'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + '%smkdir host 0:0 .' % fs_type]) + assert('Unable to create a directory' in ''.join(output)) + + def test_mkdir5(self, u_boot_console, fs_obj_mkdir): + fs_type,fs_img = fs_obj_mkdir + with u_boot_console.log.section('Test Case 5 - mkdir ("..")'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + '%smkdir host 0:0 ..' % fs_type]) + assert('Unable to create a directory' in ''.join(output)) + + def test_mkdir6(self, u_boot_console, fs_obj_mkdir): + fs_type,fs_img = fs_obj_mkdir + with u_boot_console.log.section('Test Case 6 - mkdir (create many)'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + '%smkdir host 0:0 dir6' % fs_type, + '%sls host 0:0 /' % fs_type]) + assert('dir6/' in ''.join(output)) + + for i in range(0, 20): + output = u_boot_console.run_command( + '%smkdir host 0:0 dir6/0123456789abcdef%02x' + % (fs_type, i)) + output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_type) + assert('0123456789abcdef00/' in output) + assert('0123456789abcdef13/' in output)