Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7373CC04FF3 for ; Mon, 24 May 2021 19:17:12 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1544C613F5 for ; Mon, 24 May 2021 19:17:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1544C613F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 05C4C82D61; Mon, 24 May 2021 21:17:08 +0200 (CEST) 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 84E4582D61; Mon, 24 May 2021 21:17:06 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 DCD8682AA0 for ; Mon, 24 May 2021 21:17:01 +0200 (CEST) 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: lTxXxcCuqOC+Ad0VLI9mKdYx89PGR316Mvu77TleakE8VT50SPOA52SWIxYzXtKSG/PrxfS84Q GBynZWXGAagQ== X-IronPort-AV: E=McAfee;i="6200,9189,9993"; a="189133038" X-IronPort-AV: E=Sophos;i="5.82,325,1613462400"; d="scan'208";a="189133038" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2021 12:16:58 -0700 IronPort-SDR: L2srsVRBWPRSwRUy2zD2/gx6JS5H0PIEW3YHVPOK2ldk8lqmmzeQ1bn7U+WPHHtVIQj+lEpc/t AyawopQo5f9Q== X-IronPort-AV: E=Sophos;i="5.82,325,1613462400"; d="scan'208";a="435390840" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2021 12:16:56 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1llG4I-00EPlh-Ff; Mon, 24 May 2021 22:16:50 +0300 Date: Mon, 24 May 2021 22:16:50 +0300 From: Andy Shevchenko To: Alper Nebi Yasak Cc: u-boot@lists.denx.de, Simon Glass , Tom Rini , Stephen Warren , Heinrich Schuchardt Subject: Re: [PATCH] test: Fix filesystem tests always being skipped Message-ID: References: <20210520190947.21773-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210520190947.21773-1-alpernebiyasak@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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 On Thu, May 20, 2021 at 10:09:46PM +0300, Alper Nebi Yasak wrote: > Commit 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") > fixes an issue in the filesystem tests where the test setup may fail > to mount an image and still attempt to unmount it. However, the commit > unintentionally breaks the test setups in two ways. > > The newly created unmounted filesystem images are being immediately > deleted due to some cleanup steps being misplaced into finally blocks, > which makes them always run instead of only on failures. The mount calls > always fail since the images never exist, causing the tests to be always > skipped. This patch moves these cleanup calls into the except blocks to > fix this and makes the tests run again. > > There are also unmount calls misplaced into finally blocks, making them > run after the tests instead of before the tests. These unmount calls > make the filesystem image file consistent with the changes made to it as > part of the test setup, and this misplacement is making a number of > tests fail unexpectedly. > > The unmount calls must be run before the tests use the image, meaning > before the yield call and not in the finally block. They must also be > run as a cleanup step when the filesystem setup fails, so they can't be > placed as the final call in the try blocks since they would be skipped > on such failures. For these reasons, this patch places the unmount calls > both in the except blocks and the else blocks of the final setup step. > This makes the unexpectedly failing tests to succeed again. > > Furthermore, this isolates the mount calls to their own try-except > statement to avoid reintroducing the original issue of unmounting a > not-mounted image while fixing the unmount misplacement. > > After these fixes, running "make tests" with guestmount available results > in two test failures not related to the mentioned commit. If the > guestmount executables are unavailable, the mounts fallback to using > sudo and result in no failures. > > Fixes: 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") > Signed-off-by: Alper Nebi Yasak > --- > There is more discussion at Heinrich's revert-patch [1] of the mentioned > commit. This patch is an alternative to the revert. > > Andy: I don't think unmounting the failed-to-mount image was the cause > of the sudo call you described in that commit, so I believe this would > end up running sudo on your system. Wanted to warn in advance, but looks > like your issue needs a different solution. Thanks for doing this! If you think this fix is a right thing to do, go ahead for it, I prefer it over revert. Acked-by: Andy Shevchenko > [1] https://patchwork.ozlabs.org/project/uboot/patch/20210513114035.177293-1-xypron.glpk@gmx.de/ > > test/py/tests/test_fs/conftest.py | 48 +++++++++++++++++++++++-------- > 1 file changed, 36 insertions(+), 12 deletions(-) > > diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py > index 50af9efcf768..410a675b9714 100644 > --- a/test/py/tests/test_fs/conftest.py > +++ b/test/py/tests/test_fs/conftest.py > @@ -278,14 +278,19 @@ def fs_obj_basic(request, u_boot_config): > 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) > + return > > try: > # Mount the image so we can populate it. > mount_fs(fs_type, fs_img, mount_dir) > + except CalledProcessError as err: > + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) > + call('rmdir %s' % mount_dir, shell=True) > + call('rm -f %s' % fs_img, shell=True) > + return > > + try: > # Create a subdirectory. > check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) > > @@ -348,11 +353,12 @@ def fs_obj_basic(request, u_boot_config): > > except CalledProcessError as err: > pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) > + umount_fs(mount_dir) > return > else: > + umount_fs(mount_dir) > yield [fs_ubtype, fs_img, md5val] > finally: > - umount_fs(mount_dir) > call('rmdir %s' % mount_dir, shell=True) > call('rm -f %s' % fs_img, shell=True) > > @@ -394,14 +400,19 @@ def fs_obj_ext(request, u_boot_config): > 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) > + return > > try: > # Mount the image so we can populate it. > mount_fs(fs_type, fs_img, mount_dir) > + except CalledProcessError as err: > + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) > + call('rmdir %s' % mount_dir, shell=True) > + call('rm -f %s' % fs_img, shell=True) > + return > > + try: > # Create a test directory > check_call('mkdir %s/dir1' % mount_dir, shell=True) > > @@ -443,11 +454,12 @@ def fs_obj_ext(request, u_boot_config): > check_call('rm %s' % tmp_file, shell=True) > except CalledProcessError: > pytest.skip('Setup failed for filesystem: ' + fs_type) > + umount_fs(mount_dir) > return > else: > + umount_fs(mount_dir) > yield [fs_ubtype, fs_img, md5val] > finally: > - umount_fs(mount_dir) > call('rmdir %s' % mount_dir, shell=True) > call('rm -f %s' % fs_img, shell=True) > > @@ -517,14 +529,19 @@ def fs_obj_unlink(request, u_boot_config): > 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) > + return > > try: > # Mount the image so we can populate it. > mount_fs(fs_type, fs_img, mount_dir) > + except CalledProcessError as err: > + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) > + call('rmdir %s' % mount_dir, shell=True) > + call('rm -f %s' % fs_img, shell=True) > + return > > + try: > # Test Case 1 & 3 > check_call('mkdir %s/dir1' % mount_dir, shell=True) > check_call('dd if=/dev/urandom of=%s/dir1/file1 bs=1K count=1' > @@ -548,11 +565,12 @@ def fs_obj_unlink(request, u_boot_config): > > except CalledProcessError: > pytest.skip('Setup failed for filesystem: ' + fs_type) > + umount_fs(mount_dir) > return > else: > + umount_fs(mount_dir) > yield [fs_ubtype, fs_img] > finally: > - umount_fs(mount_dir) > call('rmdir %s' % mount_dir, shell=True) > call('rm -f %s' % fs_img, shell=True) > > @@ -594,14 +612,19 @@ def fs_obj_symlink(request, u_boot_config): > 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) > + return > > try: > # Mount the image so we can populate it. > mount_fs(fs_type, fs_img, mount_dir) > + except CalledProcessError as err: > + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) > + call('rmdir %s' % mount_dir, shell=True) > + call('rm -f %s' % fs_img, shell=True) > + return > > + try: > # Create a subdirectory. > check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) > > @@ -625,10 +648,11 @@ def fs_obj_symlink(request, u_boot_config): > > except CalledProcessError: > pytest.skip('Setup failed for filesystem: ' + fs_type) > + umount_fs(mount_dir) > return > else: > + umount_fs(mount_dir) > yield [fs_ubtype, fs_img, md5val] > finally: > - umount_fs(mount_dir) > call('rmdir %s' % mount_dir, shell=True) > call('rm -f %s' % fs_img, shell=True) > -- > 2.31.1 > -- With Best Regards, Andy Shevchenko