From 9087ace2af0461f4ed9480df41c8b43f932d57cc Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 2 Sep 2023 21:36:34 +0200 Subject: [PATCH] aux: teardown also devices with testing UUID Hunt also for devices with LVMTEST prefix in UUID. Call teardown_devs_prefixed - so if they hold RAM or SCSI they are closed before trying to remove kernel modules. --- test/lib/aux.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 3f66e9290..e624c9fc9 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -403,7 +403,7 @@ teardown_devs_prefixed() { # HACK: sort also by minors - so we try to close 'possibly later' created device first test "$i" = 0 || sortby="-minor" - for dm in $(dm_info name,open --separator ';' --nameprefixes --unquoted --sort open,"$sortby" -S "name=~$prefix" --mangle none || true) ; do + for dm in $(dm_info name,open --separator ';' --nameprefixes --unquoted --sort open,"$sortby" -S "name=~$prefix || uuid=~$prefix" --mangle none || true) ; do test "$dm" != "No devices found" || break 2 eval "$dm" local force="-f" @@ -436,10 +436,14 @@ teardown_devs() { restore_dm_mirror test ! -f MD_DEV || cleanup_md_dev - test ! -f DEVICES || teardown_devs_prefixed "$PREFIX" + + if [ -f DEVICES ] || [ -f RAMDISK ] || [ -f SCSI_DEBUG_DEV ]; then + teardown_devs_prefixed "$PREFIX" + fi + if test -f RAMDISK ; then for i in 1 2 ; do - modprobe -r brd && break + modprobe -r brd && { rm -f RAMDISK ; break ; } sleep .1 udev_wait done @@ -451,7 +455,7 @@ teardown_devs() { udev_wait test "${LVM_TEST_PARALLEL:-0}" -eq 1 || { for i in 1 2 ; do - modprobe -r scsi_debug && break + modprobe -r scsi_debug && { rm -f SCSI_DEBUG_DEV ; break ; } sleep .1 udev_wait done @@ -741,7 +745,7 @@ prepare_scsi_debug_dev() { cleanup_scsi_debug_dev() { teardown_devs - rm -f SCSI_DEBUG_DEV LOOP + rm -f LOOP } mdadm_create() { -- 2.43.5