From: Alasdair Kergon Date: Thu, 30 Jun 2011 01:17:37 +0000 (+0000) Subject: Try to remove any stray loop devices left behind by earlier aborted tests. X-Git-Tag: v2_02_91~782 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=5f30b9f4c874a388cd904120873be7d4191d0d1f;p=lvm2.git Try to remove any stray loop devices left behind by earlier aborted tests. --- diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 16a5d674c..cb8e038dd 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -90,10 +90,13 @@ teardown_devs() { rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP - # Remove any loop devices that failed to get torn down - losetup -a - echo losetup -d `losetup -a | grep $COMMON_PREFIX | cut -d: -f1` 2>/dev/null || true - losetup -a + # Remove any loop devices that failed to get torn down if earlier tests aborted + STRAY_LOOPS=`losetup -a | grep $COMMON_PREFIX | cut -d: -f1` + if test -n "$STRAY_LOOPS"; then + echo "Removing stray loop devices containing $COMMON_PREFIX:" + losetup -a | grep $COMMON_PREFIX + losetup -d $STRAY_LOOPS 2>/dev/null || true + fi } teardown() {