u-boot/test/py/tests/test_fs
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
..
test_squashfs test/py: Add tests for LZO and ZSTD 2020-08-24 14:11:31 -04:00
conftest.py test: Fix filesystem tests always being skipped 2021-05-26 17:26:07 -04:00
fstest_defs.py test: fs: Added tests for symlinks 2019-04-09 20:04:03 -04:00
fstest_helpers.py test.py: Disable fsck for FAT tests for now 2019-04-10 08:15:56 -04:00
test_basic.py test: fs: Add filesystem integrity checks 2019-04-09 15:34:15 -04:00
test_ext.py cmd: fat: Use do_save() for fatwrite 2020-10-23 13:33:07 -04:00
test_fs_cmd.py cmd: fs: Add command to list supported fs types 2020-07-07 15:36:59 -04:00
test_mkdir.py test: fs: Add filesystem integrity checks 2019-04-09 15:34:15 -04:00
test_symlink.py test: fs: Added tests for symlinks 2019-04-09 20:04:03 -04:00
test_unlink.py test: fs: Add filesystem integrity checks 2019-04-09 15:34:15 -04:00