]> arthur.barton.de Git - bup.git/commitdiff
metadata: fix test failure with xattrs
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 26 May 2020 22:29:23 +0000 (00:29 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sun, 5 Jul 2020 16:16:22 +0000 (11:16 -0500)
The test_apply_to_path_restricted_access() is broken because
the expected string doesn't take into account that it's now
a u'' string (on python2) due to path_msg(), but this doesn't
appear on any non-selinux systems because the original file
never has any xattr, so the test passes, just not on my Fedora
system.

Change the expected message and remove the quote entirely as
it's different between python 2 and 3, and also try to set an
xattr in the test - if that fails, just continue as it used
to be without reading/setting it.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/t/tmetadata.py

index e14e0107c1c09fe7ec721a717ac1b178d20f4567..be9c7729dce0ea898b2a3fde293fa8ffab79e97f 100644 (file)
@@ -221,6 +221,13 @@ def test_apply_to_path_restricted_access():
             os.mkdir(parent)
             os.mkdir(path)
             clear_errors()
+            if metadata.xattr:
+                try:
+                    metadata.xattr.set(path, b'user.buptest', b'bup')
+                except:
+                    print("failed to set test xattr")
+                    # ignore any failures here - maybe FS cannot do it
+                    pass
             m = metadata.from_path(path, archive_path=path, save_symlinks=True)
             WVPASSEQ(m.path, path)
             os.chmod(parent, 0o000)
@@ -230,7 +237,7 @@ def test_apply_to_path_restricted_access():
             if m.linux_attr and _linux_attr_supported(tmpdir):
                 expected_errors.append('Linux chattr: ')
             if metadata.xattr and m.linux_xattr:
-                expected_errors.append("xattr.set '")
+                expected_errors.append("xattr.set ")
             WVPASS(len(helpers.saved_errors) == len(expected_errors))
             for i in range(len(expected_errors)):
                 WVPASS(str(helpers.saved_errors[i]).startswith(expected_errors[i]))