]> www.infradead.org Git - users/hch/xfstests-dev.git/commit
fstests: clean up loop device instantiation
authorDave Chinner <dchinner@redhat.com>
Tue, 26 Nov 2024 20:56:57 +0000 (07:56 +1100)
committerZorro Lang <zlang@kernel.org>
Sun, 8 Dec 2024 14:06:46 +0000 (22:06 +0800)
commitce79de11337e38bca2607024ea71c71fc42f8aac
tree99dea9ad92e0513d596928bdca9213bfb09800e2
parent4c6bc4565105e6a6844664cbcd0171678a6deeda
fstests: clean up loop device instantiation

Lots of tests do there own special thing with loop devices rather
than using _create_loop_device() and _destroy_loop_device(). This
oftens means they do not clean up after themselves properly,
leaving stale loop devices around that result in unmountable test or
scratch devices. This is common when tests are killed by user
interrupt.

Even the tests that do use _destroy_loop_device and try to clean up
often do it incorrectly, leading to spurious error messages.

Some tests try to use dynamic instantiation via "mount -o loop",
but then don't clean up in the correct order or hack around to find
the loop device that was instantiated because the test needs to know
the instantiated device name

Clean this up by converting all the tests to use
_create_loop_device() and _destroy_loop_device(). In all the tests,
use the variable "loop_dev" for the device consistently. In
_destroy_loop_device(), test that a device name has been passed
so that we don't try to clean up the same device twice (e.g. once
before test exit and again from the _cleanup() function). When we
destroy a loop device, unset the variable used to hold the loop
device name so that we don't try to destroy it twice.

This results in much more reliable cleanup and clean exit from
fstests when killed by the user.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
26 files changed:
common/metadump
tests/generic/067
tests/generic/361
tests/generic/563
tests/generic/564
tests/generic/590
tests/generic/744
tests/generic/746
tests/xfs/014
tests/xfs/049
tests/xfs/073
tests/xfs/074
tests/xfs/078
tests/xfs/148
tests/xfs/149
tests/xfs/216
tests/xfs/217
tests/xfs/250
tests/xfs/259
tests/xfs/513
tests/xfs/521
tests/xfs/528
tests/xfs/530
tests/xfs/606
tests/xfs/613
tests/xfs/613.out