u-boot-brain/test/py
Alper Nebi Yasak 77bfaad048 test: Fix filesystem tests always being skipped
Commit 1ba21bb06b ("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: 1ba21bb06b ("test: Don't unmount not (yet) mounted system")
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-05-26 17:26:07 -04:00
..
tests test: Fix filesystem tests always being skipped 2021-05-26 17:26:07 -04:00
.gitignore test/py: Implement pytest infrastructure 2016-01-20 19:06:23 -07:00
conftest.py test/py: improve regular expression for ut subtest symbol matcher 2021-05-24 14:21:30 -04:00
multiplexed_log.css SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
multiplexed_log.py test/py: Manual python3 fixes 2019-10-30 17:48:47 -04:00
pytest.ini test/py: Manual python3 fixes 2019-10-30 17:48:47 -04:00
requirements.txt tests: patman: Add requests to the module list 2021-04-29 03:23:39 -07:00
test.py test: correct entry point to pytest 2021-01-29 10:36:49 -05:00
u_boot_console_base.py test/py: Add test support for three stage boot 2020-08-04 23:30:02 -04:00
u_boot_console_exec_attach.py SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
u_boot_console_sandbox.py test/py: Add a way to pass flags to sandbox 2018-11-26 08:25:35 -05:00
u_boot_spawn.py test/py: Use raw strings more to avoid deprecation warnings 2019-10-30 17:48:47 -04:00
u_boot_utils.py test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memory 2020-04-10 15:54:16 -04:00