]> arthur.barton.de Git - bup.git/commitdiff
Skip dependent tests if we can't load loop or fuse
authorRob Browning <rlb@defaultvalue.org>
Thu, 20 Nov 2014 16:47:58 +0000 (10:47 -0600)
committerRob Browning <rlb@defaultvalue.org>
Wed, 31 Dec 2014 17:24:27 +0000 (11:24 -0600)
When modprobe is available (or when we know we're on Linux), try to load
the loop(back) and fuse modules before using them, and skip the relevant
tests if the load fails.  This allows the tests to proceed on systems
lacking those modules.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/t/tmetadata.py
t/test-fuse.sh
t/test-index-check-device.sh
t/test-meta.sh
t/test-xdev.sh

index e992ccc5255cd58731ec93bf04ce607a6d2ee848..8f670f7454a4c44c28528c2825aee07aad1cc42a 100644 (file)
@@ -31,6 +31,8 @@ def ex(*cmd):
 def setup_testfs():
     assert(sys.platform.startswith('linux'))
     # Set up testfs with user_xattr, etc.
+    if subprocess.call(['modprobe', 'loop']) != 0:
+        return False
     subprocess.call(['umount', 'testfs'])
     ex('dd', 'if=/dev/zero', 'of=testfs.img', 'bs=1M', 'count=32')
     ex('mke2fs', '-F', '-j', '-m', '0', 'testfs.img')
@@ -40,6 +42,7 @@ def setup_testfs():
     # Hide, so that tests can't create risks.
     os.chown('testfs', 0, 0)
     os.chmod('testfs', 0700)
+    return True
 
 
 def cleanup_testfs():
@@ -272,7 +275,9 @@ if xattr:
         if not is_superuser() or detect_fakeroot():
             WVMSG('skipping test -- not superuser')
             return
-        setup_testfs()
+        if not setup_testfs():
+            WVMSG('unable to load loop module; skipping dependent tests')
+            return
         for f in glob.glob('testfs/*'):
             ex('rm', '-rf', f)
         path = 'testfs/foo'
index cd3043707b662a8b2f03c33fc16238b550c9e372..3e2b3b288752e2f4e1c46ec05634ae2c63887d63 100755 (executable)
@@ -3,6 +3,11 @@
 
 set -o pipefail
 
+if test -n "$(type -p modprobe)" && ! modprobe fuse; then
+    echo 'Unable to load fuse module; skipping dependent tests.' 1>&2
+    exit 0
+fi
+
 if ! fusermount -V; then
     echo 'skipping FUSE tests: fusermount does not appear to work'
     exit 0
index a45f8c7e3685d1b0678b25dd894b9ff15efda942..9c50534a8d92157ad34f1f94e5a2f45340515ff3 100755 (executable)
@@ -9,13 +9,18 @@ if [ $(t/root-status) != root ]; then
     exit 0 # FIXME: add WVSKIP.
 fi
 
+if test -n "$(type -p modprobe)" && ! modprobe loop; then
+    echo 'Unable to load loopback module; skipping --check-device test.' 1>&2
+    exit 0
+fi
+
 if test -z "$(type -p losetup)"; then
-    echo 'Unable to find losetup: skipping --check-device tests.'
+    echo 'Unable to find losetup: skipping --check-device tests.' 1>&2
     exit 0 # FIXME: add WVSKIP.
 fi
 
 if test -z "$(type -p mke2fs)"; then
-    echo 'Unable to find mke2fs: skipping --check-device tests.'
+    echo 'Unable to find mke2fs: skipping --check-device tests.' 1>&2
     exit 0 # FIXME: add WVSKIP.
 fi
 
index 7241041dc19ed4424ecb0dd9604d528860073646..0c11ee936d7e0472da30f6d044425b4e83f51c90 100755 (executable)
@@ -624,6 +624,11 @@ if [ "$root_status" = root ]; then
         # (patches welcome).
         [[ $(uname) =~ Linux ]] || exit 0
 
+        if ! modprobe loop; then
+            echo 'Unable to load loopback module; skipping dependent tests.' 1>&2
+            exit 0
+        fi
+
         WVSTART 'meta - general (as root)'
         WVPASS setup-test-tree
         WVPASS cd "$TOP/bupmeta.tmp"
index 747fd0b874e839f27201110570708c73d818949e..15bdd7acb748094f6ce948691b28b3b65a65cc78 100755 (executable)
@@ -8,6 +8,11 @@ if [ $(t/root-status) != root ]; then
     exit 0 # FIXME: add WVSKIP.
 fi
 
+if ! modprobe loop; then
+    echo 'Unable to load loopback module; skipping dependent tests.' 1>&2
+    exit 0
+fi
+
 # These tests are only likely to work under Linux for now
 # (patches welcome).
 if ! [[ $(uname) =~ Linux ]]; then