[PATCH 1/6] test_metadata.setup_testfs: don't modprobe loop

0 views
Skip to first unread message

Rob Browning

unread,
Jan 16, 2026, 3:14:49 PMJan 16
to bup-...@googlegroups.com
Suspect this is no longer needed and it was causing failures in some
environments where modprobe wasn't available:
https://bugs.debian.org/1111625

Instead, just skip the tests if the attempt to mount the loopback
device fails.

Thanks to Jochen Sprickerhof for the report.

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
(cherry picked from commit 13f8721849c9f6a11f59e423e5c96ae2d98d25fe)
---
.cirrus.yml | 2 ++
README.md | 11 +++++++++++
test/ext/test-fuse | 5 -----
test/ext/test-index-check-device | 16 ++++++++++------
test/ext/test-meta | 16 ++++++++++------
test/ext/test-xdev | 16 ++++++++++------
test/int/test_metadata.py | 30 ++++++++++--------------------
7 files changed, 53 insertions(+), 43 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 08f78fff..d2039a5a 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -11,6 +11,8 @@ task:
dev/prep-for-debianish-build python3
export LANG=C.UTF-8
dev/system-info
+ modprobe -q fuse || true
+ modprobe -q loop || true
BUP_PYTHON_CONFIG=python3-config ./configure --with-pylint=yes
make -j6 check
on_failure:
diff --git a/README.md b/README.md
index d4f56706..4974cb93 100644
--- a/README.md
+++ b/README.md
@@ -206,6 +206,17 @@ From source
make check
```

+ Additional (and some slightly differing) tests will be run if
+ you're either root, or running under fakeroot, and for the root
+ case, in order to include all of the tests, you'll want to make
+ sure the fuse and loop modules are loaded, which you can do for
+ Linux via (as root):
+
+ ```sh
+ modprobe fuse
+ modprobe loop
+ ```
+
If you have the Python xdist module installed, then you can
probably run the tests faster by adding the make -j option (see <a
href="HACKING">./HACKING</a> for additional information):
diff --git a/test/ext/test-fuse b/test/ext/test-fuse
index 0f25b9e9..7dbcbd26 100755
--- a/test/ext/test-fuse
+++ b/test/ext/test-fuse
@@ -18,11 +18,6 @@ if [ $? -eq 2 ]; then
exit 0
fi

-if test -n "$(type -p modprobe)" && ! modprobe fuse; then
- WVSKIP 'Unable to load fuse module; skipping dependent tests.'
- exit 0
-fi
-
if ! fusermount -V; then
WVSKIP 'skipping FUSE tests: fusermount does not appear to work'
exit 0
diff --git a/test/ext/test-index-check-device b/test/ext/test-index-check-device
index 3bba9999..85f0e045 100755
--- a/test/ext/test-index-check-device
+++ b/test/ext/test-index-check-device
@@ -11,11 +11,6 @@ if [ "$root_status" != root ]; then
exit 0
fi

-if test -n "$(type -p modprobe)" && ! modprobe loop; then
- WVSKIP 'Unable to load loopback module; skipping --check-device test.'
- exit 0
-fi
-
if test -z "$(type -p losetup)"; then
WVSKIP 'Unable to find losetup: skipping --check-device tests.'
exit 0
@@ -43,7 +38,16 @@ WVPASS cd "$tmpdir"

WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
WVPASS mke2fs -F -j -m 0 testfs.img
-WVPASS mount -o loop testfs.img "$tmpmnt1"
+
+set -x
+mount -o loop testfs.img "$tmpmnt1"
+rc=$?
+set +x
+if test "$rc" -ne 0; then
+ WVSKIP 'Unable to mount via loopback: skipping --check-device tests.'
+ exit 0
+fi
+
# Hide, so that tests can't create risks.
WVPASS chown root:root "$tmpmnt1"
WVPASS chmod 0700 "$tmpmnt1"
diff --git a/test/ext/test-meta b/test/ext/test-meta
index 9e0d5ebe..fd2aa064 100755
--- a/test/ext/test-meta
+++ b/test/ext/test-meta
@@ -637,11 +637,6 @@ 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 # FIXME: allow intermixed WVSKIPs
- fi
-
testfs="$(WVPASS wvmkmountpt)" || exit $?
testfs_limited="$(WVPASS wvmkmountpt)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?
@@ -659,7 +654,16 @@ if [ "$root_status" = root ]; then
-I 256 \
-O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize \
testfs.img
- WVPASS mount -o loop,acl,user_xattr testfs.img "$testfs"
+
+ set -x
+ mount -o loop,acl,user_xattr testfs.img "$testfs"
+ rc=$?
+ set +x
+ if test "$rc" -ne 0; then
+ echo 'Unable to mount via loopback; skipping dependent tests.' 1>&2
+ exit 0 # FIXME: allow intermixed WVSKIPs
+ fi
+
# Hide, so that tests can't create risks.
WVPASS chown root:root "$testfs"
WVPASS chmod 0700 "$testfs"
diff --git a/test/ext/test-xdev b/test/ext/test-xdev
index cc5a2c08..7f8f4c17 100755
--- a/test/ext/test-xdev
+++ b/test/ext/test-xdev
@@ -10,11 +10,6 @@ if [ "$root_status" != root ]; then
exit 0
fi

-if ! modprobe loop; then
- WVSKIP 'unable to load loopback module; skipping tests'
- exit 0
-fi
-
# These tests are only likely to work under Linux for now
# (patches welcome).
if ! [[ $(uname) =~ Linux ]]; then
@@ -40,7 +35,16 @@ WVPASS dd if=/dev/zero of=testfs-2.img bs=1M count=32
WVPASS mkfs -F testfs-1.img # Don't care what type (though must have symlinks)
WVPASS mkfs -F testfs-2.img # Don't care what type (though must have symlinks)
WVPASS mkdir -p src/mnt-1/hidden-1 src/mnt-2/hidden-2
-WVPASS mount -o loop testfs-1.img src/mnt-1
+
+set -x
+mount -o loop testfs-1.img src/mnt-1
+rc=$?
+set +x
+if test "$rc" -ne 0; then
+ WVSKIP 'Unable to mount via loopback: skipping xdev tests.'
+ exit 0
+fi
+
WVPASS mount -o loop testfs-2.img src/mnt-2

WVPASS touch src/1
diff --git a/test/int/test_metadata.py b/test/int/test_metadata.py
index 3fefbd4e..b3b10577 100644
--- a/test/int/test_metadata.py
+++ b/test/int/test_metadata.py
@@ -8,11 +8,12 @@ from wvpytest import *

from bup import git, metadata
from bup import vfs
+from bup.compat import fsencode
from bup.helpers import clear_errors, detect_fakeroot, is_superuser, resolve_parent
from bup.repo import LocalRepo
from bup.xstat import utime, lutime
import bup.helpers as helpers
-from bup.compat import fsencode
+import buptest

lib_t_dir = os.path.dirname(fsencode(__file__))

@@ -21,33 +22,22 @@ top_dir = os.path.realpath(os.path.join(lib_t_dir, b'..', b'..'))
bup_path = top_dir + b'/bup'


-def ex(*cmd):
- try:
- cmd_str = b' '.join(cmd)
- print(cmd_str, file=sys.stderr)
- rc = subprocess.call(cmd)
- if rc < 0:
- print('terminated by signal', - rc, file=sys.stderr)
- sys.exit(1)
- elif rc > 0:
- print('returned exit status', rc, file=sys.stderr)
- sys.exit(1)
- except OSError as e:
- print('subprocess call failed:', e, file=sys.stderr)
- sys.exit(1)
+def ex(*args, **kwargs):
+ return buptest.ex(args, **kwargs)


def setup_testfs():
+ # Try to set up testfs with user_xattr, etc.
assert(sys.platform.startswith('linux'))
- # Set up testfs with user_xattr, etc.
- if subprocess.call([b'modprobe', b'loop']) != 0:
- return False
subprocess.call([b'umount', b'testfs'])
ex(b'dd', b'if=/dev/zero', b'of=testfs.img', b'bs=1M', b'count=32')
ex(b'mke2fs', b'-F', b'-j', b'-m', b'0', b'testfs.img')
ex(b'rm', b'-rf', b'testfs')
os.mkdir(b'testfs')
- ex(b'mount', b'-o', b'loop,acl,user_xattr', b'testfs.img', b'testfs')
+ exr = ex(b'mount', b'-o', b'loop,acl,user_xattr', b'testfs.img', b'testfs',
+ check=False)
+ if exr.rc != 0:
+ return False
# Hide, so that tests can't create risks.
os.chown(b'testfs', 0, 0)
os.chmod(b'testfs', 0o700)
@@ -273,7 +263,7 @@ if xattr:
pytest.skip('skipping test -- not superuser')
return
if not setup_testfs():
- pytest.skip('unable to load loop module; skipping dependent tests')
+ pytest.skip('unable to set up test fs; skipping dependent tests')
return
for f in glob.glob(b'testfs/*'):
ex(b'rm', b'-rf', f)
--
2.47.3

Reply all
Reply to author
Forward
0 new messages