u-boot/test/py/tests/test_fs
Alper Nebi Yasak 99f5303c8b test/py: Wait for guestmount worker to exit after running guestunmount
Some filesystem tests are failing when their image is prepared with
guestmount, but succeeding if loop mounts are used instead. The reason
seems to be a race condition the guestmount(1) manual page explains:

    When guestunmount(1)/fusermount(1) exits, guestmount may still be
    running and cleaning up the mountpoint.  The disk image will not be
    fully finalized.

    This means that scripts like the following have a nasty race condition:

     guestmount -a disk.img -i /mnt
     # copy things into /mnt
     guestunmount /mnt
     # immediately try to use 'disk.img' ** UNSAFE **

    The solution is to use the --pid-file option to write the guestmount
    PID to a file, then after guestunmount spin waiting for this PID to
    exit.

The Python standard library has an os.waitpid() function for waiting a
child to terminate, but it cannot wait on non-child processes. Implement
a utility function that can do this by polling the process repeatedly
for a given duration, optionally killing the process if it won't
terminate on its own. Apply the suggested solution with this utility
function, which makes the failing tests succeed again.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-05 15:28:32 -04:00
..
test_squashfs test/py: Add tests for LZO and ZSTD 2020-08-24 14:11:31 -04:00
conftest.py test/py: Wait for guestmount worker to exit after running guestunmount 2021-07-05 15:28:32 -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