From cde31cc6bbc32fc3c5405c63243697e1cdd21884 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 26 Jul 2019 16:00:38 -0700 Subject: losetup.test: bail out if loopback devices are already in use. There's probably a way to filter out the existing ones, but it's likely to be pretty painful and isn't immediately necessary. (I hit this case on Android cloud x86 devices.) --- tests/losetup.test | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/losetup.test') diff --git a/tests/losetup.test b/tests/losetup.test index 7968ecd9..2f72b920 100755 --- a/tests/losetup.test +++ b/tests/losetup.test @@ -2,13 +2,18 @@ [ -f testing.sh ] && . testing.sh -if [ "$(id -u)" -ne 0 ] -then +if [ "$(id -u)" -ne 0 ]; then echo "$SHOWSKIP: losetup (not root)" return 2>/dev/null exit fi +if [ "$(losetup -a | wc -l)" -ne 0 ]; then + echo "$SHOWSKIP: losetup (devices already in use)" + return 2>/dev/null + exit +fi + # Android's loopback devices are only in /dev/block/loop*. # Debian has symlinks like /dev/block/7:0 back to ../loop*. if [ -b /dev/block/sda ]; then -- cgit v1.2.3