[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/5] tests: Ensure that loopback devices and zfs devices are c
From: |
Glenn Washburn |
Subject: |
[PATCH v3 5/5] tests: Ensure that loopback devices and zfs devices are cleaned up |
Date: |
Sun, 6 Feb 2022 16:00:12 -0600 |
ZFS file systems are not unmounted using umount, but instead by exporting
them. So export the ZFS file system that has the same label as the one that
was created during the test, if such one exists. This is required to delete
the loopback device that uses the ZFS image file. Otherwise the added code
to delete all loopback devices setup during the test run will never be able
to finish because the loopback device can not be deleted while in use.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
tests/util/grub-fs-tester.in | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index 5c722209d..3bc3006de 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -14,10 +14,27 @@ tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` ||
XORRISOFS_CHARSET="-input-charset UTF-8 -output-charset UTF-8"
MOUNTS=
+LODEVICES=
cleanup() {
+ if [ -n "$fs" -a -z "${fs##*zfs*}" -a -n "$FSLABEL" ]; then
+ zpool list "$FSLABEL" 2>/dev/null &&
+ while ! zpool export "$FSLABEL" ; do
+ sleep 1;
+ done
+ fi
+
for i in $MOUNTS; do
umount "$i" || :
done
+
+ for lodev in $LODEVICES; do
+ local i=600
+ while losetup -l -O NAME | grep -q "^$lodev\$"; do
+ losetup -d "$lodev" || sleep 1
+ [ "$((i--))" = "0" ] && break
+ done
+ done
+ return 0
}
trap cleanup EXIT INT
# This is for bash, dash and ash do not recognize ERR
--
2.27.0
- [PATCH v3 0/5] Various test fixes and improvements, Glenn Washburn, 2022/02/06
- [PATCH v3 1/5] tests: Do not remove image file on error in pata_test, Glenn Washburn, 2022/02/06
- [PATCH v3 5/5] tests: Ensure that loopback devices and zfs devices are cleaned up,
Glenn Washburn <=
- [PATCH v3 4/5] tests: Ensure that mountpoints are unmounted before exiting, Glenn Washburn, 2022/02/06
- [PATCH v3 3/5] tests: Remove $((BASE#NUM)) bashism in grub-fs-tester, Glenn Washburn, 2022/02/06
- [PATCH v3 2/5] tests: Skip pata_test on i386-efi, Glenn Washburn, 2022/02/06
- Re: [PATCH v3 0/5] Various test fixes and improvements, Daniel Kiper, 2022/02/08