Skip to content

Commit 677eaaf

Browse files
no_selinux -> filter_xattrs
Originally, we only wanted to get rid of selinux xattrs, but macOS also uses some xattr keys that disturb our test results, so we filter them also. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013bFWgq2KV6oYxmfH6Zqvp3 (cherry picked from commit ac51d3e)
1 parent 11a0a9c commit 677eaaf

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎src/borg/testsuite/__init__.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ def is_birthtime_fully_supported():
156156
return False
157157

158158

159-
def no_selinux(x):
160-
# selinux fails our FUSE tests, thus ignore selinux xattrs
161-
SELINUX_KEY = b'security.selinux'
159+
def filter_xattrs(x):
160+
# selinux and com.apple.provenance fail our FUSE tests, thus ignore them
161+
UNWANTED_KEYS = {b"security.selinux", b"com.apple.provenance"}
162162
if isinstance(x, dict):
163-
return {k: v for k, v in x.items() if k != SELINUX_KEY}
163+
return {k: v for k, v in x.items() if k not in UNWANTED_KEYS}
164164
if isinstance(x, list):
165-
return [k for k in x if k != SELINUX_KEY]
165+
return [k for k in x if k not in UNWANTED_KEYS]
166+
raise ValueError("Unsupported type: %s" % type(x))
166167

167168

168169
class BaseTestCase(unittest.TestCase):
@@ -233,8 +234,8 @@ def _assert_dirs_equal_cmp(self, diff, ignore_flags=False, ignore_xattrs=False,
233234
d1.append(round(s1.st_mtime_ns, st_mtime_ns_round))
234235
d2.append(round(s2.st_mtime_ns, st_mtime_ns_round))
235236
if not ignore_xattrs:
236-
d1.append(no_selinux(get_all(path1, follow_symlinks=False)))
237-
d2.append(no_selinux(get_all(path2, follow_symlinks=False)))
237+
d1.append(filter_xattrs(get_all(path1, follow_symlinks=False)))
238+
d2.append(filter_xattrs(get_all(path2, follow_symlinks=False)))
238239
self.assert_equal(d1, d2)
239240
for sub_diff in diff.subdirs.values():
240241
self._assert_dirs_equal_cmp(sub_diff, ignore_flags=ignore_flags, ignore_xattrs=ignore_xattrs, ignore_ns=ignore_ns)

‎src/borg/testsuite/archiver.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from ..remote import RemoteRepository, PathNotAllowed
5656
from ..repository import Repository
5757
from . import has_lchflags, llfuse
58-
from . import BaseTestCase, changedir, environment_variable, no_selinux, same_ts_ns
58+
from . import BaseTestCase, changedir, environment_variable, filter_xattrs, same_ts_ns
5959
from . import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported, is_utime_fully_supported, is_birthtime_fully_supported
6060
from .platform import fakeroot_detected, is_darwin, is_freebsd, is_win32
6161
from .upgrader import make_attic_repo
@@ -2743,11 +2743,11 @@ def has_noatime(some_file):
27432743
in_fn = 'input/fusexattr'
27442744
out_fn = os.fsencode(os.path.join(mountpoint, 'input', 'fusexattr'))
27452745
if not xattr.XATTR_FAKEROOT and xattr.is_enabled(self.input_path):
2746-
assert sorted(no_selinux(xattr.listxattr(out_fn))) == [b'user.empty', b'user.foo', ]
2746+
assert sorted(filter_xattrs(xattr.listxattr(out_fn))) == [b'user.empty', b'user.foo', ]
27472747
assert xattr.getxattr(out_fn, b'user.foo') == b'bar'
27482748
assert xattr.getxattr(out_fn, b'user.empty') == b''
27492749
else:
2750-
assert no_selinux(xattr.listxattr(out_fn)) == []
2750+
assert filter_xattrs(xattr.listxattr(out_fn)) == []
27512751
try:
27522752
xattr.getxattr(out_fn, b'user.foo')
27532753
except OSError as e:

0 commit comments

Comments
 (0)