From: Rob Browning Date: Thu, 20 Nov 2014 16:47:58 +0000 (-0600) Subject: Skip dependent tests if we can't load loop or fuse X-Git-Tag: 0.27-rc1~20 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=7cdde9af1222ddcf65b02a8ba3be184ca90d2dc8;hp=9d6a70f48926fcbb84e39c909c0e8a8843a17154 Skip dependent tests if we can't load loop or fuse 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 Tested-by: Rob Browning --- diff --git a/lib/bup/t/tmetadata.py b/lib/bup/t/tmetadata.py index e992ccc..8f670f7 100644 --- a/lib/bup/t/tmetadata.py +++ b/lib/bup/t/tmetadata.py @@ -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' diff --git a/t/test-fuse.sh b/t/test-fuse.sh index cd30437..3e2b3b2 100755 --- a/t/test-fuse.sh +++ b/t/test-fuse.sh @@ -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 diff --git a/t/test-index-check-device.sh b/t/test-index-check-device.sh index a45f8c7..9c50534 100755 --- a/t/test-index-check-device.sh +++ b/t/test-index-check-device.sh @@ -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 diff --git a/t/test-meta.sh b/t/test-meta.sh index 7241041..0c11ee9 100755 --- a/t/test-meta.sh +++ b/t/test-meta.sh @@ -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" diff --git a/t/test-xdev.sh b/t/test-xdev.sh index 747fd0b..15bdd7a 100755 --- a/t/test-xdev.sh +++ b/t/test-xdev.sh @@ -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