From patchwork Tue Sep 4 07:49:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 145867 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3370953ljw; Tue, 4 Sep 2018 01:01:18 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdao/xVnrsrTTyH4EgP7Uwm/9MHxgnd+8E+eZomi8tXOCujn+Xn+9WY90GJeafiUfzr3vuGG X-Received: by 2002:a50:a6c7:: with SMTP id f7-v6mr34956318edc.225.1536048078686; Tue, 04 Sep 2018 01:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536048078; cv=none; d=google.com; s=arc-20160816; b=BJUpbLHBMzqB+sfu6Lp++QdZrYHp86mKtL171SzA299YJ/ihJTA+czyklY9WTGtno5 kejxMmEu2SZPCH4DqtsaO93yOBFw/jjQ7BfdkP2+9SjVpVpbwTe1XHlOFJtyX5WHxiSf zORvLjnsSctarCS4eZDx+Epd9FJWnHgc4MIxrlYzpxI2ntsbPbwFEAsMqKVaG1fA6gWT vEO5K4yRdUEuLvV0IVbDAFCjj4Cm5OXlzBl65gNbDasWOFA0PkJ+cvlAU5zkkPQQgmk2 JGdz2VuK+d36sqC57hbs7oR+ebxauROFoRoC3O2r2VrZ50+7TXKcgFHeCdpWOdZfZna9 7wNA== 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=hQNSktGtweKigB3KZ18RE4VSCNW4cYTpfBBoJkFhfaM=; b=SOlDxUAIPpn6fG13fwYRjGK/QOi2pJm7UcdsAI05ENz7mYY9bzT/6DiEZ2aaj0Oftz QA/MsdQqPaETGzleb/A6PhHx6hmGPxlQkq1SXpu7tgu3SxFUM5pjRVJF19y24rtUke5Y /j36QqfRpzonhAkDEAf7polrvHl7mXwpXH7JG/s3+CWHo00vWTJam6XmrKz/GFdjaszL fnXVYkJdnJqSHyS0TeZ+ojRDUxiGayMGsvnZlV1L8to0MrhddhmAKTtQzR02brDXe+Lj 8FFUVj86Jv7JN1kzYe3bduJRV2wko6LorgFJ2T+p/UtsLtPpLj+kAjXeU5uBN9uRkTzv 5Vkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a+SJ2axV; 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 z42-v6si5893043edb.410.2018.09.04.01.01.18; Tue, 04 Sep 2018 01:01:18 -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=a+SJ2axV; 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 4008AC21F2A; Tue, 4 Sep 2018 07:55:41 +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 375BCC21F04; Tue, 4 Sep 2018 07:54:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 46C67C21F29; Tue, 4 Sep 2018 07:53:27 +0000 (UTC) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by lists.denx.de (Postfix) with ESMTPS id 4F84CC21EF1 for ; Tue, 4 Sep 2018 07:53:23 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id y4-v6so1245744pgp.9 for ; Tue, 04 Sep 2018 00:53:23 -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=LNqXESH8xabfDZs8ZJyhu6rbAdvR4aGrl3UkX0OxcCU=; b=a+SJ2axVtIZmpJWEPA5rKZ60Fb2pozhNQuxffqK4cioj7joCg3uEpG9blz+NqORnUY bgK2vJHRVdxh1X/02wCkNYg1siSDEr8EgPPy8hQB6ocqzjM268S5Cs7jWhbHzaPHNUKy dRA150+l9gAe+DQoLB7hhZQocgxQPo+dF6SGs= 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=LNqXESH8xabfDZs8ZJyhu6rbAdvR4aGrl3UkX0OxcCU=; b=Kaje3ORJ+hqv/sbBnZJrQzKozXp5wTh0AWMdtOiAebnE752DacunZQcFgGjrSF5bGh DBm/EVCmpgO+1AWecats9qBEYUldtbFWxWB6iGdnZP7Lji2Axe6L/ZUtnF1ZKEwTtCpJ i03sfqW9IAR7H7F/AllU2Ccb4jF3hkODv1b4gs4NApajYAIC1jmbSoqmYlv2VA6TFZFv 9qbYdHA7oORNiaebfeTmqlRDKBROKFsRo/TXzsS76AvejCtQOxExMrGMPMEhwFIA0Nz1 s4IakWBXuYFXT8TalruMLqUojTpLmNxBkBeX91FlAKOwn6Jhk9/QX5pxDmJ6M5HqQGp+ saYA== X-Gm-Message-State: APzg51AU3udH/+ovrw2gVW+2+/n8mPLPQaxbjjwkmSdTgYicELhW272j D6qyv1AKHzHzxbuN+kzm/xyjLA== X-Received: by 2002:a63:6485:: with SMTP id y127-v6mr29593990pgb.393.1536047601859; Tue, 04 Sep 2018 00:53:21 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id t12-v6sm35062042pgg.72.2018.09.04.00.53.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 00:53:21 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Tue, 4 Sep 2018 16:49:48 +0900 Message-Id: <20180904074948.18146-24-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904074948.18146-1-takahiro.akashi@linaro.org> References: <20180904074948.18146-1-takahiro.akashi@linaro.org> Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 23/23] 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 | 112 ++++++++++++++++++++++++++++ 2 files changed, 143 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 f72d53d88fc8..0d909ed7789a 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 @@ -298,3 +304,28 @@ 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: + 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..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)