From patchwork Thu Feb 11 14:40:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1439538 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=) 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dbznc1MYNz9rx6 for ; Fri, 12 Feb 2021 01:40:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D03C282663; Thu, 11 Feb 2021 15:40:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 93F7482663; Thu, 11 Feb 2021 15:40:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 468EC82627 for ; Thu, 11 Feb 2021 15:40:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: gVYl724zANoNlGLjP1skImdp9+vFuTr4rgBGQmK/rJeakSiLJG+EYvcfFAxEQE5ucqvRXbHBId 3HPXSEASwMFw== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="161996927" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="161996927" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 06:40:15 -0800 IronPort-SDR: tPiNmlU6b2hEXRY2cbg+wC/N/JRn43vIBA5GCMFPOzdIDbjixdlyuG8phwaFM9e+gZnJQDWZbE bF9oNDB7ZMoA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="588810006" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 11 Feb 2021 06:40:14 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9529ADE; Thu, 11 Feb 2021 16:40:13 +0200 (EET) From: Andy Shevchenko To: Simon Glass , u-boot@lists.denx.de, trini@konsulko.com Cc: Andy Shevchenko , Patrick Delaunay Subject: [PATCH v2 1/4] test: Include /sbin to the PATH when creating ext4 disk image Date: Thu, 11 Feb 2021 16:40:09 +0200 Message-Id: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 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.3 at phobos.denx.de X-Virus-Status: Clean On some distributions the mkfs.ext4 is under /sbin and /sbin is not set for mere users. Include /sbin to the PATH when creating ext4 disk image, so that users won't get a scary traceback from Python. Cc: Patrick Delaunay Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass --- v2: used '/sbin' as is (Simon) test/py/tests/test_env.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index 940279651da0..9bed2f48d77e 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -414,6 +414,8 @@ def mk_env_ext4(state_test_env): if os.path.exists(persistent): c.log.action('Disk image file ' + persistent + ' already exists') else: + # Some distributions do not add /sbin to the default PATH, where mkfs.ext4 lives + os.environ["PATH"] += os.pathsep + '/sbin' try: u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent) u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent) From patchwork Thu Feb 11 14:40:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1439541 X-Patchwork-Delegate: sjg@chromium.org 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4Dbzp70Y8gz9s1l for ; Fri, 12 Feb 2021 01:41:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D3EC2826BC; Thu, 11 Feb 2021 15:40:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 7B9A382687; Thu, 11 Feb 2021 15:40:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 89B4682627 for ; Thu, 11 Feb 2021 15:40:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: DU1gjbJJeidSrs5GYAdA9oKYQtY5zFHi8DYzBFQY6Htt4c57lp25u2zBHV/QMxPWS/+3KXP76R qDg0HyEgRZXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="201377171" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="201377171" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 06:40:18 -0800 IronPort-SDR: UR4dVE9h90VVTMHIBk/Tl6GBkCoNpDQxEVv9w2NkwGzgr+p+M5/SqQEn25JgvOz7u8mp2T4VvR c0x/DoWCh11Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="399546899" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 11 Feb 2021 06:40:14 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A0C6DC5; Thu, 11 Feb 2021 16:40:13 +0200 (EET) From: Andy Shevchenko To: Simon Glass , u-boot@lists.denx.de, trini@konsulko.com Cc: Andy Shevchenko Subject: [PATCH v2 2/4] test: Allow simple glob pattern in the test name Date: Thu, 11 Feb 2021 16:40:10 +0200 Message-Id: <20210211144012.55676-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com> References: <20210211144012.55676-1-andriy.shevchenko@linux.intel.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.3 at phobos.denx.de X-Virus-Status: Clean When run `ut dm [test name]` allow to use simple pattern to run all tests started with given prefix. For example, to run all ACPI test cases: ut dm acpi* Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v2: rebased against dm/test-working branch (Simon) test/test-main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/test-main.c b/test/test-main.c index e1b49e091ab6..8fcbc2361214 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -128,10 +128,17 @@ static bool ut_test_run_on_flattree(struct unit_test *test) static bool test_matches(const char *prefix, const char *test_name, const char *select_name) { + size_t len; + if (!select_name) return true; - if (!strcmp(test_name, select_name)) + /* Allow glob expansion in the test name */ + len = select_name[strlen(select_name) - 1] == '*' ? strlen(select_name) : 0; + if (len-- == 1) + return true; + + if (!strncmp(test_name, select_name, len)) return true; if (!prefix) { @@ -146,7 +153,7 @@ static bool test_matches(const char *prefix, const char *test_name, test_name += strlen(prefix); } - if (!strcmp(test_name, select_name)) + if (!strncmp(test_name, select_name, len)) return true; return false; From patchwork Thu Feb 11 14:40:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1439540 X-Patchwork-Delegate: sjg@chromium.org 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4Dbznw6Vfqz9s1l for ; Fri, 12 Feb 2021 01:40:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 785538269C; Thu, 11 Feb 2021 15:40:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id E59C082673; Thu, 11 Feb 2021 15:40:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE87E82656 for ; Thu, 11 Feb 2021 15:40:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: 0VQhb+KMFXaW/N+wJyAU31BxP0uxNOyQm2dkDy0tVjUjm+r/gghJrged2dar79mZ2Kp4bdgruJ cPF7Y99pWcsw== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="161391069" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="161391069" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 06:40:17 -0800 IronPort-SDR: RLLYsdzxgJGYWuwhBT29ZPqzNXdKf3G+NkO9fImSr4akpvgtL6GZPOG+MrCOJKar1nho9EQzHl QvXIyXpS4BxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="422282558" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 11 Feb 2021 06:40:14 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AC50A1FA; Thu, 11 Feb 2021 16:40:13 +0200 (EET) From: Andy Shevchenko To: Simon Glass , u-boot@lists.denx.de, trini@konsulko.com Cc: Andy Shevchenko Subject: [PATCH v2 3/4] test: Use positive conditional in test_matches() Date: Thu, 11 Feb 2021 16:40:11 +0200 Message-Id: <20210211144012.55676-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com> References: <20210211144012.55676-1-andriy.shevchenko@linux.intel.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.3 at phobos.denx.de X-Virus-Status: Clean It is easier to read the positive conditional. While at it, convert hard coded length of "_test_" to strlen("_test_") which will be converted to a constant bu optimizing compiler. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- v2: new patch test/test-main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-main.c b/test/test-main.c index 8fcbc2361214..344122074e12 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -141,16 +141,16 @@ static bool test_matches(const char *prefix, const char *test_name, if (!strncmp(test_name, select_name, len)) return true; - if (!prefix) { + if (prefix) { + /* All tests have this prefix */ + if (!strncmp(test_name, prefix, strlen(prefix))) + test_name += strlen(prefix); + } else { const char *p = strstr(test_name, "_test_"); /* convert xxx_test_yyy to yyy, i.e. remove the suite name */ if (p) - test_name = p + 6; - } else { - /* All tests have this prefix */ - if (!strncmp(test_name, prefix, strlen(prefix))) - test_name += strlen(prefix); + test_name = p + strlen("_test_"); } if (!strncmp(test_name, select_name, len)) From patchwork Thu Feb 11 14:40:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1439539 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4Dbznk6ws4z9rx6 for ; Fri, 12 Feb 2021 01:40:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7557082675; Thu, 11 Feb 2021 15:40:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 688A582657; Thu, 11 Feb 2021 15:40:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 946A882636 for ; Thu, 11 Feb 2021 15:40:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: dIjMhZzmyZbZ/idbXDqKJi/aQToRfNEd6EXOUutaKRIANkd/72dDZKOCNIFvgeFZGH4CZzUgjc ylk44HVxWoSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="182381220" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="182381220" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 06:40:15 -0800 IronPort-SDR: E3gFDCQ4a/YCiQTm9ZwZ9ChBUHQnFAxPPAMT/Jwdfv2tUrctD++mGYLFUollXGPZ6cz82E+UEV 9m+IZb6B4BDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="397323153" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 11 Feb 2021 06:40:14 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B773C2BE; Thu, 11 Feb 2021 16:40:13 +0200 (EET) From: Andy Shevchenko To: Simon Glass , u-boot@lists.denx.de, trini@konsulko.com Cc: Andy Shevchenko Subject: [PATCH v2 4/4] test: Don't unmount not (yet) mounted system Date: Thu, 11 Feb 2021 16:40:12 +0200 Message-Id: <20210211144012.55676-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211144012.55676-1-andriy.shevchenko@linux.intel.com> References: <20210211144012.55676-1-andriy.shevchenko@linux.intel.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.3 at phobos.denx.de X-Virus-Status: Clean When test suite tries to create a file for a new filesystem test case and fails, the clean up of the exception tries to unmount the image, that has not yet been mounted. When it happens, the fuse_mounted global variable is set to False and inconveniently the test case tries to use sudo, so without this change the admin of the machine gets an (annoying) email: Subject: *** SECURITY information for example.com *** example.com : Feb 5 19:43:47 : ... COMMAND=/bin/umount .../build-sandbox/persistent-data/mnt and second run of the test cases on uncleaned build folder will ask for sudo which is not what expected. Besides that there is a double unmount calls during successfully run test case. All of these due to over engineered Python try-except clause and people didn't get it properly at all. The rule of thumb is that don't use more keywords than try-except in the exception handling code. Nevertheless, here we adjust code to be less intrusive to the initial logic behind that complex and unclear constructions in the test case, although it adds a lot of lines of the code, i.e. splits one exception handler to three, so on each step we know what cleanup shall perform. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass --- v2: new patch test/py/tests/test_fs/conftest.py | 78 ++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py index ec70e8c4ef3f..50af9efcf768 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -270,9 +270,20 @@ def fs_obj_basic(request, u_boot_config): # 3GiB volume fs_img = mk_fs(u_boot_config, fs_type, 0xc0000000, '3GB') + except CalledProcessError as err: + pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) + return - # Mount the image so we can populate it. + try: check_call('mkdir -p %s' % mount_dir, shell=True) + except CalledProcessError as err: + pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + return + finally: + call('rm -f %s' % fs_img, shell=True) + + try: + # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) # Create a subdirectory. @@ -335,18 +346,15 @@ def fs_obj_basic(request, u_boot_config): % big_file, shell=True).decode() md5val.append(out.split()[0]) - umount_fs(mount_dir) except CalledProcessError as err: - pytest.skip('Setup failed for filesystem: ' + fs_type + \ - '. {}'.format(err)) + pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) return else: yield [fs_ubtype, fs_img, md5val] finally: umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) - if fs_img: - call('rm -f %s' % fs_img, shell=True) + call('rm -f %s' % fs_img, shell=True) # # Fixture for extended fs test @@ -378,9 +386,20 @@ def fs_obj_ext(request, u_boot_config): # 128MiB volume fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') + except CalledProcessError as err: + pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) + return - # Mount the image so we can populate it. + try: check_call('mkdir -p %s' % mount_dir, shell=True) + except CalledProcessError as err: + pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + return + finally: + call('rm -f %s' % fs_img, shell=True) + + try: + # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) # Create a test directory @@ -422,7 +441,6 @@ def fs_obj_ext(request, u_boot_config): md5val.append(out.split()[0]) check_call('rm %s' % tmp_file, shell=True) - umount_fs(mount_dir) except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) return @@ -431,8 +449,7 @@ def fs_obj_ext(request, u_boot_config): finally: umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) - if fs_img: - call('rm -f %s' % fs_img, shell=True) + call('rm -f %s' % fs_img, shell=True) # # Fixture for mkdir test @@ -460,11 +477,10 @@ def fs_obj_mkdir(request, u_boot_config): fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') except: pytest.skip('Setup failed for filesystem: ' + fs_type) + return else: yield [fs_ubtype, fs_img] - finally: - if fs_img: - call('rm -f %s' % fs_img, shell=True) + call('rm -f %s' % fs_img, shell=True) # # Fixture for unlink test @@ -493,9 +509,20 @@ def fs_obj_unlink(request, u_boot_config): # 128MiB volume fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') + except CalledProcessError as err: + pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) + return - # Mount the image so we can populate it. + try: check_call('mkdir -p %s' % mount_dir, shell=True) + except CalledProcessError as err: + pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + return + finally: + call('rm -f %s' % fs_img, shell=True) + + try: + # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) # Test Case 1 & 3 @@ -519,7 +546,6 @@ def fs_obj_unlink(request, u_boot_config): check_call('dd if=/dev/urandom of=%s/dir5/file1 bs=1K count=1' % mount_dir, shell=True) - umount_fs(mount_dir) except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) return @@ -528,8 +554,7 @@ def fs_obj_unlink(request, u_boot_config): finally: umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) - if fs_img: - call('rm -f %s' % fs_img, shell=True) + call('rm -f %s' % fs_img, shell=True) # # Fixture for symlink fs test @@ -559,11 +584,22 @@ def fs_obj_symlink(request, u_boot_config): try: - # 3GiB volume + # 1GiB volume fs_img = mk_fs(u_boot_config, fs_type, 0x40000000, '1GB') + except CalledProcessError as err: + pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) + return - # Mount the image so we can populate it. + try: check_call('mkdir -p %s' % mount_dir, shell=True) + except CalledProcessError as err: + pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + return + finally: + call('rm -f %s' % fs_img, shell=True) + + try: + # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) # Create a subdirectory. @@ -587,7 +623,6 @@ def fs_obj_symlink(request, u_boot_config): % medium_file, shell=True).decode() md5val.extend([out.split()[0]]) - umount_fs(mount_dir) except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) return @@ -596,5 +631,4 @@ def fs_obj_symlink(request, u_boot_config): finally: umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) - if fs_img: - call('rm -f %s' % fs_img, shell=True) + call('rm -f %s' % fs_img, shell=True)