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: 144896 Delivered-To: patch@linaro.org Received: by 2002:a2e:164a:0:0:0:0:0 with SMTP id 10-v6csp780051ljw; Thu, 23 Aug 2018 00:27:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxfzDoU4MjZ1wcxPgvnAnKCLDZPUhd7ET3vQD8s6JgTv0Js/6SZZRm70vKlVrjBihb07DDA X-Received: by 2002:a50:a402:: with SMTP id u2-v6mr67596759edb.237.1535009260216; Thu, 23 Aug 2018 00:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535009260; cv=none; d=google.com; s=arc-20160816; b=ZH/Djx2ZpVySub12YpfL6XqGi9i5PTXE9+IpwjI3czt3xE9yJtD3tY6A4/emOKxwuP galjd9BPENMWRIfM+GAHkC8IkUrLwxzxkCUKunhCUZj/FHLnuRXHZ8vHlgRPOu+oj8M3 QY/rrbjucjUJ74nL1xZlfx9yKcg7ivpoSasKb8sm0ltUEcM1nNjiD0vsTOlyzbM7rIFf jqujGXSe+BiMo+Jv3MxZOFFMCv7hoYp/6hcLSAQi8ZSny+ZK91MmpBeBJS1bIfytjduZ n1Fd26fs5+9SZH+FNDDLfneKMKPt/Tn2zV2CFsHtF+oanmkN4ifmk0b5/PB0v8oPdrp9 kg3Q== 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:arc-authentication-results; bh=u5/G3aGxfLi50R3hDnJNepl9Wd7yuIkbL4FZyKkDsOg=; b=j2XcFf7b9Tu6R2MYqEpgaiujYCEtV/DxDs9IIKIHAsgNGMXOIGVghyISyRNNol8gt+ irthctqyBZIMummAlpvlO7GGkmqNYkNWfgkRhmJPZvrJOq8a7lklKD7VT1xXn60uh7i0 fLGBcii+KJMdVyeHh2YE42fZQTf4sIErDclIDzUblfAYOLWXceKjRxl/T1pcN355CdCU I+aVMdSamYuMsGnKgGZkVg8ycxz5Jz0d90NKfn/7ofGaByeZ4TL3pfcNegsvBFh5OMe6 tlsdO0IKyoxuAU1uW+evAg63/ZsUpPFizzurL6lo1fn68aGmwrk0oomqvXmM6v0tuPY4 mmzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hnBP2zYz; 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 h25-v6si229465edb.423.2018.08.23.00.27.39; Thu, 23 Aug 2018 00:27:40 -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=hnBP2zYz; 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 BEE19C21E6C; Thu, 23 Aug 2018 07:27:31 +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-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)