[PATCH v2 4/4] test: Don't unmount not (yet) mounted system

Andy Shevchenko
2021-05-17T06:36:44Z

On Thu, May 13, 2021 at 2:32 PM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> On 2/11/21 3:40 PM, Andy Shevchenko wrote:
> > 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 <andriy.shevchenko@linux.intel.com>
>
> Dear Andy,
>
> with this merged patch the following tests are not executed anymore locally:
>
> test/py/tests/test_fs/test_basic.py
> test/py/tests/test_fs/test_ext.py
>
> SKIPPED [13] test/py/tests/test_fs/conftest.py:350: Setup failed for
> filesystem: ext4. Command 'guestmount -a
> build-sandbox/persistent-data/3GB.ext4.img -m /dev/sda
> build-sandbox/persistent-data/mnt' returned non-zero exit status 1.
>
> Please, revert the patch or fix it.

Thanks for the report, let's investigate it.
And for the consistency let's continue this under the revert thread,

--
With Best Regards,
Andy Shevchenko