From patchwork Tue Sep 11 06:59:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 146424 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3324746ljw; Tue, 11 Sep 2018 00:16:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZskw9iTMxnexnLW6N9AaYp3VEBKG6g69CSEOo/nT2hNbg9K0r3+ytRaa2vpv4c2VBGQin9 X-Received: by 2002:aa7:da19:: with SMTP id r25-v6mr27395323eds.54.1536650197467; Tue, 11 Sep 2018 00:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536650197; cv=none; d=google.com; s=arc-20160816; b=WN5s29Ne5hMyFRehAgMYuqWHnh5ctVeqVmAbvWUvEP9/5O7ng1vzsgDXRwY5mZ6qpk kk2bU6TkPjN2SnQhox5Ix4NStM8/LcJ/OZbwtFStZX9mRebJ/b+87FhlTcoFfrW7HzoA 7/WuZ2zS4szoO2RH455h74KIwPGxu56IFeQhvBakTZfNTnb94OswfeXGBX3CPSD19US1 PbDKzZXhcEtcI5QQ2F1PtkKxmlqg34NHEG2ZffAAPxYc9l9GiwxaC3iiVU3TocJXIK6N vsBH5f+5Fb/4IQ+k670vghQc7p+bdhwxf9kVIVqj+lJIovujHPpozje8mCdiPEqbg95z R5hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature; bh=+8Cx8d6weufEkRT4WK5/G/iVIM4i28kCmZnay2JT2Ns=; b=u4bCXSXDRSczpeCCGKWWGQKMVEcLR4ekuPCyh+cKA/BGrv/aBIKNAn/yBDU6FL+FZT axB2zdoL3Hd9Znw74ikpikkOGqusoaxT/XabMJEBLIOWfX8FJk86MGJ/tXYrj5jUvFVY 8v7qWs2YLn7zocmc8TRxmGEY93xrbf09brd4UX2rixwjfCOfPw7kMoF4LKHkIbm9p21y YcTeChrIAr49k3w1QwX+fpBQa80KD42yi0QQMF+aZRq2SYm9h/5oWrsfcJV1tmWwtdYD 3ARIL/t0MByGUIHSWawPZGOgmUJF+0bFOfcnWWnnZwc1K690t6zk6nqFaJtJhnJGjk6v G2Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=e68yMH34; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id f32-v6si8366613edb.230.2018.09.11.00.16.37; Tue, 11 Sep 2018 00:16:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=e68yMH34; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 1A88AC21E1A; Tue, 11 Sep 2018 07:09:33 +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 34F2DC21EE3; Tue, 11 Sep 2018 07:01:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8B212C21E3B; Tue, 11 Sep 2018 07:00:47 +0000 (UTC) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by lists.denx.de (Postfix) with ESMTPS id BCDADC21E38 for ; Tue, 11 Sep 2018 07:00:40 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id t19-v6so10888092ply.13 for ; Tue, 11 Sep 2018 00:00:40 -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=VEtfDqQ5Vcsg6Xb/VtHu5sYaXNDDu1AZt8pqzhwgvLo=; b=e68yMH347UwF2cjUrsKTRmV4k5T19akgGKYq8GiVrwXdtA67wkQPcvFazbM7u3On5O 1rJ3ZD6YW4adAxexvTAJtnM82G6K+2MEmTBwRwUg031mP63xw0XpWx78Oepj665WFHBG sEo4bDPYnKOi/BCoB0d2JX79pxCtBgdTLUo0U= 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=VEtfDqQ5Vcsg6Xb/VtHu5sYaXNDDu1AZt8pqzhwgvLo=; b=fEt4+N03s24sZIVpuD+DXtZZAFFVnDxuJ4RkxMoEZLm+etuqtBzVJmSjJvLuXSddoy PkwbK5a90ne91+9F62Uf6kxgHUJu5+7iy5JHBeusF9X+k8FHnoXahrhySfRtlD4lkrOi znlhskKYtE4ugLPQzthMsoukOGzCEDa4n7FF1koDN4VA83o6Fx6T6v6/xiWCpUiPZnIx wq63VnZ8PJ+Gqn87RiQlgXdtiKDCutM7ypUWWlbAAzvprhppCQUQsQ5SmKEmgI+/1AkI zI2EBxQnhfQqs57TyaOsP6OfGA+OqRmr2qYrXceB3p5EvyKQwBDb7y2pl861fcOKmHDO +2DQ== X-Gm-Message-State: APzg51DP8MkDRhnwkMXQCMy6PPVUOhbTLSbd/Ouzh7CKxbV4zJnc50ny Pb+MP2uh9ZLcwD+Lz49nAf4h/Q== X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr25898099plb.58.1536649238750; Tue, 11 Sep 2018 00:00:38 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j15-v6sm21897381pfn.52.2018.09.11.00.00.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 00:00:37 -0700 (PDT) From: "Akashi, Takahiro" To: trini@konsulko.com Date: Tue, 11 Sep 2018 15:59:21 +0900 Message-Id: <20180911065922.19141-26-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180911065922.19141-1-takahiro.akashi@linaro.org> References: <20180911065922.19141-1-takahiro.akashi@linaro.org> Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, agraf@suse.de Subject: [U-Boot] [PATCH v3 25/26] 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" From: AKASHI Takahiro 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 | 29 +++++++ test/py/tests/test_fs/test_mkdir.py | 112 ++++++++++++++++++++++++++++ 2 files changed, 141 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 d2908590be16..71abf8fa4222 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -11,6 +11,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 @@ -22,6 +23,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] @@ -31,6 +33,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: @@ -39,6 +42,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 @@ -299,3 +305,26 @@ def fs_obj_ext(request, u_boot_config): call('rmdir %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: + # 128MiB volume + fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') + except: + pytest.skip('Setup failed for filesystem: ' + fs_type) + else: + yield [fs_ubtype, fs_img] + finally: + 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..d9da97b56b5e --- /dev/null +++ b/test/py/tests/test_fs/test_mkdir.py @@ -0,0 +1,112 @@ +# 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): + """ + Test Case 1 - create a directory under a root + """ + 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): + """ + Test Case 2 - create a directory under a sub-directory + """ + 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)) + + output = u_boot_console.run_command( + '%sls host 0:0 dir1/dir2' % fs_type) + assert('./' in output) + assert('../' in output) + + def test_mkdir3(self, u_boot_console, fs_obj_mkdir): + """ + Test Case 3 - trying to create a directory with a non-existing + path should fail + """ + 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): + """ + Test Case 4 - trying to create "." should fail + """ + 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): + """ + Test Case 5 - trying to create ".." should fail + """ + 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): + """ + 'Test Case 6 - create as many directories as amount of directory + entries goes beyond a cluster size)' + """ + 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) + + output = u_boot_console.run_command( + '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type) + assert('./' in output) + assert('../' in output) + + output = u_boot_console.run_command( + '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type) + assert('0123456789abcdef00/' in output) + assert('0123456789abcdef13/' in output)