From e5a5d67bff5b23f683212f5c17a0c00b528df919 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 22 Sep 2025 21:01:01 +0200 Subject: [PATCH] read_only CM: skip test if cmd_immutable is unsuccessful, fixes #9021 --- src/borg/testsuite/archiver/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py index 180f1f013..0a5073f9e 100644 --- a/src/borg/testsuite/archiver/__init__.py +++ b/src/borg/testsuite/archiver/__init__.py @@ -440,7 +440,12 @@ def read_only(path): pytest.skip(message) try: os.system('LD_PRELOAD= chmod -R ugo-w "%s"' % path) - os.system(cmd_immutable) + rc = os.system(cmd_immutable) + if rc != 0: + # If we cannot make the path immutable (e.g., missing CAP_LINUX_IMMUTABLE + # in containers or restricted environments), the read-only tests would + # not be meaningful. Skip them instead of failing. + pytest.skip(f"Unable to make path immutable with: {cmd_immutable} (rc={rc})") yield finally: # Restore permissions to ensure clean-up doesn't fail