From patchwork Mon May 24 02:31:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jo=C3=A3o_Marcos_Costa?= X-Patchwork-Id: 1482602 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=SSGsAmwH; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FpLpM4LsRz9sRf for ; Mon, 24 May 2021 12:32:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE5DE82EA2; Mon, 24 May 2021 04:32:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SSGsAmwH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0F34282E94; Mon, 24 May 2021 04:32:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7E50282AD8 for ; Mon, 24 May 2021 04:31:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jmcosta944@gmail.com Received: by mail-qk1-x72b.google.com with SMTP id c20so25768102qkm.3 for ; Sun, 23 May 2021 19:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SumFhDcQo3Zw11+l7vUqk3sldCiuun1QcSyCV/ncZpY=; b=SSGsAmwHGmUN2EH7HnhmGd78arV4QRquhOOnSS2lEn2T4NnOD5nux6qX4ZKRIBK1ei 5sr4/ecTFNeUJyKXngMCIzwj8wqXWTCls+DP/AX7bq2CIQ244Bg9ZyJ/nyHxUbMxhAJU ETTYbbBOK0vxi59IO4yofBhW6dKXsMZYcquWDorkFh5avyJIEUz8fuAURCJE7VF295LZ KcJTPOqKc03v1b9gcXZCLohfbQ2/T25OuHDCnJkAdDUTja+xVj+h36/cQKPB7revw8P8 RoZ/azHTItstQu1avVFbpqb5rUhiTTDvlmmP/5d12aC12PkubANK/Kk/Qp7yNxNGxu2t 6brA== 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:mime-version:content-transfer-encoding; bh=SumFhDcQo3Zw11+l7vUqk3sldCiuun1QcSyCV/ncZpY=; b=M6mnnw8keVY1ohX8aFuj80Bhj8wMvIrQ5ACmVdQQBKKrvZ3YI5U8Dyh2J6gJ2ZU5/I JyFpWsAsfz8Pfo9iAcX+eIG+HkqCZdqFsjUdOGdjiQoI0FnMdNGv9yhsH49h76JGPoE9 TXdum3dfTHA/NeF0f6quI8rDgVErR8lsXmp4r7BZU39kztQ9aTjH2WJAWGaCjd8atUZe jtdTAASttXFQiKWZZIi98TBxoFaw3KxbQP2xy/UXVOIJCHU5sDHYoQNP9k1KrVSRFETL z+50ZYhS9qXGwxNmQsx9tPO8OGgpH64okcXXTiQHrjY/fsVmkIHdMgJCVbC0lGN+ouoz iZ1Q== X-Gm-Message-State: AOAM530LdN6D4LTkWK726ANx46s3eCISNS+HQ33WUIicxT2+IgzZbR+8 pnDsNWHfsp6wRcKgmCcIz7YeDFq0nVvSpdE8 X-Google-Smtp-Source: ABdhPJwwV6vTPMqKSRgcOX8F7cPx9w385sEsEoy+HHZ6/AuI68FpmpLa10buvJCVNzMHksGy0Txyow== X-Received: by 2002:a05:620a:2e4:: with SMTP id a4mr17201495qko.250.1621823514271; Sun, 23 May 2021 19:31:54 -0700 (PDT) Received: from localhost.localdomain ([177.194.32.83]) by smtp.googlemail.com with ESMTPSA id h5sm10385647qkg.122.2021.05.23.19.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 19:31:54 -0700 (PDT) From: Joao Marcos Costa To: u-boot@lists.denx.de Cc: thomas.petazzoni@bootlin.com, miquel.raynal@bootlin.com, richard.genoud@posteo.net, sjg@chromium.org, Joao Marcos Costa Subject: [PATCH 3/3] test/py: rewrite sqfsls command test suite Date: Sun, 23 May 2021 23:31:33 -0300 Message-Id: <20210524023133.22100-4-jmcosta944@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210524023133.22100-1-jmcosta944@gmail.com> References: <20210524023133.22100-1-jmcosta944@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Add more details to test cases by comparing each expected line with the command's output. Add new test cases: - sqfsls at an empty directory - sqfsls at a sub-directory Signed-off-by: Joao Marcos Costa --- .../test_fs/test_squashfs/test_sqfs_ls.py | 80 ++++++++++++++----- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py index a0dca2e2fc..2895aefc3b 100644 --- a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py +++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py @@ -6,6 +6,52 @@ import os import pytest from sqfs_common import * +def sqfs_ls_at_root(u_boot_console): + # first and most basic test is to check if these two give the same output + no_slash = u_boot_console.run_command('sqfsls host 0') + slash = u_boot_console.run_command('sqfsls host 0 /') + assert no_slash == slash + + expected_lines = ['empty-dir/', '1000 f1000', '4096 f4096', '5096 f5096', + 'subdir/', ' sym', '4 file(s), 2 dir(s)'] + + output = u_boot_console.run_command('sqfsls host 0') + for line in expected_lines: + assert line in output + +def sqfs_ls_at_empty_dir(u_boot_console): + assert u_boot_console.run_command('sqfsls host 0 empty-dir') == 'Empty directory.' + +def sqfs_ls_at_subdir(u_boot_console): + expected_lines = ['100 subdir-file', '1 file(s), 0 dir(s)'] + output = u_boot_console.run_command('sqfsls host 0 subdir') + for line in expected_lines: + assert line in output + +def sqfs_ls_at_symlink(u_boot_console): + # since sym -> subdir, the following outputs must be equal + output = u_boot_console.run_command('sqfsls host 0 sym') + output_subdir= u_boot_console.run_command('sqfsls host 0 subdir') + assert output == output_subdir + + expected_lines = ['100 subdir-file', '1 file(s), 0 dir(s)'] + for line in expected_lines: + assert line in output + +# output should be the same for non-existent directories and files +def sqfs_ls_at_non_existent_dir(u_boot_console): + out_non_existent = u_boot_console.run_command('sqfsls host 0 fff') + out_not_dir = u_boot_console.run_command('sqfsls host 0 f1000') + assert out_non_existent == out_not_dir + assert '** Cannot find directory. **' in out_non_existent + +def sqfs_run_all_ls_tests(u_boot_console): + sqfs_ls_at_root(u_boot_console) + sqfs_ls_at_empty_dir(u_boot_console) + sqfs_ls_at_subdir(u_boot_console) + sqfs_ls_at_symlink(u_boot_console) + sqfs_ls_at_non_existent_dir(u_boot_console) + @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_fs_generic') @pytest.mark.buildconfigspec('cmd_squashfs') @@ -13,24 +59,22 @@ from sqfs_common import * @pytest.mark.requiredtool('mksquashfs') def test_sqfs_ls(u_boot_console): build_dir = u_boot_console.config.build_dir - for opt in comp_opts: - try: - opt.gen_image(build_dir) - except RuntimeError: - opt.clean_source(build_dir) - # skip unsupported compression types - continue - path = os.path.join(build_dir, "sqfs-" + opt.name) - output = u_boot_console.run_command("host bind 0 " + path) + # setup test environment + generate_sqfs_src_dir(build_dir) + make_all_images(build_dir) + + # run all tests for each image + for image in standard_table.keys(): try: - # list files in root directory - output = u_boot_console.run_command("sqfsls host 0") - assert str(len(opt.files) + 1) + " file(s), 0 dir(s)" in output - assert " sym" in output - output = u_boot_console.run_command("sqfsls host 0 xxx") - assert "** Cannot find directory. **" in output + image_path = os.path.join(build_dir, image) + u_boot_console.run_command('host bind 0 {}'.format(image_path)) + sqfs_run_all_ls_tests(u_boot_console) except: - opt.cleanup(build_dir) - assert False - opt.cleanup(build_dir) + clean_all_images(build_dir) + clean_sqfs_src_dir(build_dir) + raise AssertionError + + # clean test environment + clean_all_images(build_dir) + clean_sqfs_src_dir(build_dir)